Merge branch 'feat/game-ui-tests' into 'main'
Add: Game UI Taskbar tests See merge request cs108-fs26/Gruppe-13!158
This commit was merged in pull request #314.
This commit is contained in:
+13
-13
@@ -412,7 +412,7 @@ public class TaskbarController {
|
|||||||
boolean phaseChanged) {
|
boolean phaseChanged) {
|
||||||
|
|
||||||
// boolean firstPlayerNewRound =
|
// boolean firstPlayerNewRound =
|
||||||
// phaseChanged && isFirstPreflopPlayerInputOnly(state, me);
|
// phaseChanged && isFirstPreflopPlayer(state, me);
|
||||||
inputActionAllowed = false;
|
inputActionAllowed = false;
|
||||||
if (!isMyTurn || isOutOrFinished || state == null || me == null) {
|
if (!isMyTurn || isOutOrFinished || state == null || me == null) {
|
||||||
setBetButtonVisible(false);
|
setBetButtonVisible(false);
|
||||||
@@ -433,20 +433,20 @@ public class TaskbarController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if (isFirstPreflopPlayerInputOnly(state, me)) {
|
if (isFirstPreflopPlayer(state, me)) {
|
||||||
// setActionEnabled(betButton, true);
|
setActionEnabled(betButton, true);
|
||||||
// setActionEnabled(callButton, false);
|
setActionEnabled(callButton, false);
|
||||||
// setActionEnabled(foldButton, false);
|
setActionEnabled(foldButton, false);
|
||||||
// setActionEnabled(raiseButton, false);
|
setActionEnabled(raiseButton, false);
|
||||||
// activateInputField(taskbarInput);
|
activateInputField(taskbarInput);
|
||||||
// inputActionAllowed = true;
|
inputActionAllowed = true;
|
||||||
// return;
|
return;
|
||||||
// }
|
}
|
||||||
|
|
||||||
if (isFirstPlayerOfPhase(state, me)) {
|
if (isFirstPlayerOfPhase(state, me)) {
|
||||||
setActionEnabled(betButton, true);
|
setActionEnabled(betButton, true);
|
||||||
setActionEnabled(callButton, false);
|
setActionEnabled(callButton, false);
|
||||||
setActionEnabled(foldButton, false);
|
// setActionEnabled(foldButton, false);
|
||||||
setActionEnabled(raiseButton, false);
|
setActionEnabled(raiseButton, false);
|
||||||
activateInputField(taskbarInput);
|
activateInputField(taskbarInput);
|
||||||
inputActionAllowed = true;
|
inputActionAllowed = true;
|
||||||
@@ -605,7 +605,7 @@ public class TaskbarController {
|
|||||||
* @return A boolean value indicating whether the current player is the first to act in the
|
* @return A boolean value indicating whether the current player is the first to act in the
|
||||||
* pre-flop phase with only the initial blind layout in place.
|
* pre-flop phase with only the initial blind layout in place.
|
||||||
*/
|
*/
|
||||||
private boolean isFirstPreflopPlayerInputOnly(GameState state, Player me) {
|
private boolean isFirstPreflopPlayer(GameState state, Player me) {
|
||||||
if (state == null || me == null || !isPreflop(state.phase) || state.players == null) {
|
if (state == null || me == null || !isPreflop(state.phase) || state.players == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1078,7 @@ public class TaskbarController {
|
|||||||
return ValidationResult.blocked("Bet must match at least the call amount");
|
return ValidationResult.blocked("Bet must match at least the call amount");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isFirstPlayerOfPhase(state, me)) {
|
if (isFirstPreflopPlayer(state, me)) {
|
||||||
if (required > FIRST_PLAYER_MAX_BET) {
|
if (required > FIRST_PLAYER_MAX_BET) {
|
||||||
return ValidationResult.blocked(
|
return ValidationResult.blocked(
|
||||||
"First player cannot bet more than " + FIRST_PLAYER_MAX_BET);
|
"First player cannot bet more than " + FIRST_PLAYER_MAX_BET);
|
||||||
|
|||||||
+37
@@ -0,0 +1,37 @@
|
|||||||
|
package ch.unibas.dmi.dbis.cs108.casono.client.ui.gameui.gameuicomponents;
|
||||||
|
|
||||||
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||||
|
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.GameState;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.Player;
|
||||||
|
import ch.unibas.dmi.dbis.cs108.casono.client.game.PlayerId;
|
||||||
|
import java.util.List;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class TaskbarControllerInputValidationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void updateLogicRunsWithoutCrash() {
|
||||||
|
GameState state = new GameState();
|
||||||
|
|
||||||
|
state.players = List.of(
|
||||||
|
new Player(PlayerId.of("me"), 20000),
|
||||||
|
new Player(PlayerId.of("other"), 20000)
|
||||||
|
);
|
||||||
|
|
||||||
|
state.phase = "PREFLOP";
|
||||||
|
state.currentBet = 200;
|
||||||
|
state.activePlayer = 0;
|
||||||
|
|
||||||
|
DummyController controller = new DummyController();
|
||||||
|
|
||||||
|
controller.update(state, PlayerId.of("me"));
|
||||||
|
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static class DummyController {
|
||||||
|
void update(GameState state, PlayerId id) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user