Esempio n. 1
0
  @Given("startPhase0")
  public UrsuppeGUI testDataPhase0(UrsuppeGUI ursuppe) {

    Phase0 phase =
        (Phase0)
            this.getObjectPhase(
                this.phaseLogic
                    .getActivePhase()); // Important! Each phase test should have this line!

    assertFalse(phase.buttonLetsPlayPart2IsEnabled());
    assertTrue(phase.buttonRollDiePart1IsEnabled());

    assertFalse(phase.radioButtonStartPos1IsEnabled());
    assertFalse(phase.radioButtonStartPos2IsEnabled());
    assertFalse(phase.radioButtonStartPos3IsEnabled());

    // ROLL DIE:

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(playerBlue));

    die.setExpectedValue(6);
    this.goHavingANap(); // @for see only
    phase.fakeClickButtonRollDiePart1();

    assertThat(this.playerBlue.getRolledFaceValue(), checkInteger.checkInteger(6));
    assertThat(this.playerRed.getRolledFaceValue(), checkInteger.checkInteger(0));
    assertThat(this.playerYellow.getRolledFaceValue(), checkInteger.checkInteger(0));

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(playerRed));

    die.setExpectedValue(1);
    this.goHavingANap(); // @for see only
    phase.fakeClickButtonRollDiePart1();

    assertThat(this.playerBlue.getRolledFaceValue(), checkInteger.checkInteger(6));
    assertThat(this.playerRed.getRolledFaceValue(), checkInteger.checkInteger(1));
    assertThat(this.playerYellow.getRolledFaceValue(), checkInteger.checkInteger(0));

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(playerYellow));

    die.setExpectedValue(4);
    this.goHavingANap(); // @for see only
    phase.fakeClickButtonRollDiePart1();

    assertThat(this.playerBlue.getRolledFaceValue(), checkInteger.checkInteger(6));
    assertThat(this.playerRed.getRolledFaceValue(), checkInteger.checkInteger(1));
    assertThat(this.playerYellow.getRolledFaceValue(), checkInteger.checkInteger(4));

    this.goHavingANap(); // @for see only
    phase.fakeClickButtonLetsSetPlayers(); // Show dialogue part 2
    this.goHavingANap(); // @for see only

    // SET POSITION:

    assertTrue(phase.radioButtonStartPos1IsEnabled());
    assertTrue(phase.radioButtonStartPos2IsEnabled());
    assertTrue(phase.radioButtonStartPos3IsEnabled());

    assertFalse(phase.buttonLetsPlayPart2IsEnabled());

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(playerBlue));

    phase.fakeClickradioButtonStartPos2();
    this.goHavingANap(); // @for see only

    assertThat(this.playerBlue.getScore(), checkInteger.checkInteger(2));
    assertThat(this.playerRed.getScore(), checkInteger.checkInteger(0));
    assertThat(this.playerYellow.getScore(), checkInteger.checkInteger(0));

    assertTrue(phase.radioButtonStartPos1IsEnabled());
    assertFalse(phase.radioButtonStartPos2IsEnabled());
    assertTrue(phase.radioButtonStartPos3IsEnabled());

    assertFalse(phase.buttonLetsPlayPart2IsEnabled());

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(playerYellow));

    phase.fakeClickradioButtonStartPos1();
    this.goHavingANap(); // @for see only

    assertThat(this.playerBlue.getScore(), checkInteger.checkInteger(2));
    assertThat(this.playerRed.getScore(), checkInteger.checkInteger(0));
    assertThat(this.playerYellow.getScore(), checkInteger.checkInteger(1));

    assertFalse(phase.radioButtonStartPos1IsEnabled());
    assertFalse(phase.radioButtonStartPos2IsEnabled());
    assertTrue(phase.radioButtonStartPos3IsEnabled());

    assertFalse(phase.buttonLetsPlayPart2IsEnabled());

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(playerRed));

    phase.fakeClickradioButtonStartPos3();
    this.goHavingANap(); // @for see only

    assertThat(this.playerBlue.getScore(), checkInteger.checkInteger(2));
    assertThat(this.playerRed.getScore(), checkInteger.checkInteger(3));
    assertThat(this.playerYellow.getScore(), checkInteger.checkInteger(1));

    assertFalse(phase.radioButtonStartPos1IsEnabled());
    assertFalse(phase.radioButtonStartPos2IsEnabled());
    assertFalse(phase.radioButtonStartPos3IsEnabled());

    assertTrue(phase.buttonLetsPlayPart2IsEnabled());

    assertThat(this.playerBlue.getScore(), checkInteger.checkInteger(2));
    assertThat(this.playerRed.getScore(), checkInteger.checkInteger(3));
    assertThat(this.playerYellow.getScore(), checkInteger.checkInteger(1));

    // System.out.println("ORDER 1:  " +this.game.getOrderOfPlayersColor());
    phase.fakeClickButtonLetsPlayPart2();
    this.goHavingANap(); // @for see only

    ////////////
    // *YELLOW*//
    ////////////
    ISquare ladderSquare1 = this.game.getBoard().getLadderSquare(1);
    assertTrue(ladderSquare1.getPlayer().equals(this.playerYellow));

    //////////
    // *BLUE*//
    //////////
    ISquare ladderSquare2 = this.game.getBoard().getLadderSquare(2);
    assertTrue(ladderSquare2.getPlayer().equals(this.playerBlue));

    /////////
    // *RED*//
    /////////
    ISquare ladderSquare3 = this.game.getBoard().getLadderSquare(3);
    assertTrue(ladderSquare3.getPlayer().equals(this.playerRed));

    return ursuppe;
  }
Esempio n. 2
0
  public void moveDriftAndEatTest(
      Phase1 phase,
      Player currentPlayer,
      boolean doClickDrift,
      boolean doClickMove,
      int expectedValueOfDie,
      GameDirection currentDirection,
      int nrOfEatFoodBlue,
      int nrOfEatFoodRed,
      int nrOfEatFoodYellow,
      int nrOfCurrentAmeba,
      int nrOfDamagePointsBefore,
      int nrOfDamagePointsAfter,
      int xCoordinateLeft,
      int yCoordinateLeft,
      boolean isLeftSquareEmtpy,
      boolean isLeftSquareContainsCurrentAmeba,
      int nrBlueFoodOnLeftSquare,
      int nrRedFoodOnLeftSquare,
      int nrYellowFoodOnLeftSquare,
      int xCoordinateTarget,
      int yCoordinateTarget,
      int nrBlueFoodOnTargetSquare,
      int nrRedFoodOnTargetSquare,
      int nrYellowFoodOnTargetSquare) {

    // CHECK AMEBA:
    Ameba activeAmeba = phase.getActiveAmeba();
    assertThat(activeAmeba.getColor(), checkColor.checkColor(currentPlayer.getColor()));
    assertThat(activeAmeba.getNumber(), checkInteger.checkInteger(nrOfCurrentAmeba));
    assertThat(activeAmeba.getDamagePoints(), checkInteger.checkInteger(nrOfDamagePointsBefore));

    // decide what to do:
    if (doClickDrift) {
      phase.fakeClickbuttonDrift();
    } else if (doClickMove) {
      phase.fakeClickbuttonMove();
      this.die.setExpectedValue(expectedValueOfDie);
      phase.fakeClickbuttonRollDie();
      assertThat(
          currentPlayer.getBioPoints(),
          checkInteger.checkInteger(this.game.getBioPointsAtStart() - 1));
    }

    // CHECK TEXTFIELDS
    switch (activeAmeba.getColor()) {
      case blue:
        {
          assertFalse(phase.getTextFieldNrOfBlueFoodToEatIsEnabled());
          assertTrue(phase.getTextFieldNrOfRedFoodToEatIsEnabled());
          assertTrue(phase.getTextFieldNrOfYellowFoodToEatIsEnabled());
          break;
        }
      case red:
        {
          assertTrue(phase.getTextFieldNrOfBlueFoodToEatIsEnabled());
          assertFalse(phase.getTextFieldNrOfRedFoodToEatIsEnabled());
          assertTrue(phase.getTextFieldNrOfYellowFoodToEatIsEnabled());
          break;
        }
      case yellow:
        {
          assertTrue(phase.getTextFieldNrOfBlueFoodToEatIsEnabled());
          assertTrue(phase.getTextFieldNrOfRedFoodToEatIsEnabled());
          assertFalse(phase.getTextFieldNrOfYellowFoodToEatIsEnabled());
          break;
        }
      default:
        {
          System.out.println(
              "Error in ScriptedGame1.class: unknown error in moveDriftAndEatTest()!");
          // TODO
          assertTrue(false);
          break;
        }
    }

    // SET NUMBER OF FOOD TO EAT
    phase.setTexttextFieldNrOfBlueFoodToEat(Integer.toString(nrOfEatFoodBlue));
    phase.setTexttextFieldNrOfRedFoodToEat(Integer.toString(nrOfEatFoodRed));
    phase.setTexttextFieldNrOfYellowFoodToEat(Integer.toString(nrOfEatFoodYellow));

    // DO MOVE/DRIFT AND EAT

    phase.fakeClickbuttonSetFoodToEat();

    // CHECK SQUARES:

    // *LEFT SQUARE*//
    ISquare leftSquare = this.game.getBoard().getSquare(xCoordinateLeft, yCoordinateLeft);

    assertTrue(leftSquare.isEmpy() == isLeftSquareEmtpy);
    assertTrue(
        leftSquare.getAmebasOfColor(activeAmeba.getColor()).contains(activeAmeba)
            == isLeftSquareContainsCurrentAmeba);

    assertThat(
        leftSquare.getNrOfFood(GameColor.blue), checkInteger.checkInteger(nrBlueFoodOnLeftSquare));
    assertThat(
        leftSquare.getNrOfFood(GameColor.red), checkInteger.checkInteger(nrRedFoodOnLeftSquare));
    assertThat(
        leftSquare.getNrOfFood(GameColor.yellow),
        checkInteger.checkInteger(nrYellowFoodOnLeftSquare));

    // *TARGET SQUARE*//
    ISquare targetSquare = this.game.getBoard().getSquare(xCoordinateTarget, yCoordinateTarget);

    assertFalse(targetSquare.isEmpy());
    assertTrue(targetSquare.getAmebasOfColor(activeAmeba.getColor()).contains(activeAmeba));

    assertThat(
        targetSquare.getNrOfFood(GameColor.blue),
        checkInteger.checkInteger(nrBlueFoodOnTargetSquare));
    assertThat(
        targetSquare.getNrOfFood(GameColor.red),
        checkInteger.checkInteger(nrRedFoodOnTargetSquare));
    assertThat(
        targetSquare.getNrOfFood(GameColor.yellow),
        checkInteger.checkInteger(nrYellowFoodOnTargetSquare));

    // CHECK AMEBA:
    assertThat(activeAmeba.getDamagePoints(), checkInteger.checkInteger(nrOfDamagePointsAfter));
    assertThat(activeAmeba.getDirection(), checkDirection.checkDirection(currentDirection));
  }