예제 #1
0
  @Given("startPhase1")
  public UrsuppeGUI testDataPhase1(UrsuppeGUI ursuppe) // Move/Drift and Eat
      {
    Phase1 phase =
        (Phase1)
            this.getObjectPhase(
                this.phaseLogic
                    .getActivePhase()); // Important! Each phase test should have this line!
    Ameba activeAmeba;
    assertFalse(phase.getButtonGoToPhase2IsEnabled());

    assertTrue(this.game.getReadDirection() == GameReadDirection.up);

    // CHECK WINDDIRECTION:
    assertThat(this.game.getActualeDirection(), checkDirection.checkDirection(GameDirection.North));

    //////////
    // YELLOW//
    //////////

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(this.playerYellow));
    assertThat(this.playerYellow.getNrOfFoodsToEat(), checkInteger.checkInteger(3));

    ////////////
    // *AMEBA 1//
    ////////////

    this.moveDriftAndEatTest(
        phase,
        this.playerYellow,
        true,
        false,
        0,
        GameDirection.North,
        2,
        1,
        0,
        1,
        1,
        1,
        2,
        2,
        true,
        false,
        2,
        2,
        2,
        2,
        1,
        0,
        1,
        4);
    this.goHavingANap(); // @for see only

    ////////////
    // *AMEBA 3//
    ////////////
    this.moveDriftAndEatTest(
        phase,
        this.playerYellow,
        true,
        false,
        0,
        GameDirection.North,
        1,
        2,
        0,
        3,
        0,
        0,
        4,
        3,
        true,
        false,
        2,
        2,
        2,
        4,
        2,
        1,
        0,
        4);
    this.goHavingANap(); // @for see only

    assertFalse(phase.getButtonGoToPhase2IsEnabled());

    ////////
    // BLUE//
    ////////

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(this.playerBlue));
    assertThat(this.playerBlue.getNrOfFoodsToEat(), checkInteger.checkInteger(3));

    ////////////
    // *AMEBA 3//
    ////////////
    this.moveDriftAndEatTest(
        phase,
        this.playerBlue,
        true,
        false,
        0,
        GameDirection.North,
        0,
        1,
        2,
        3,
        1,
        1,
        4,
        2,
        false,
        false,
        1,
        0,
        4,
        4,
        1,
        4,
        1,
        0);
    this.goHavingANap(); // @for see only

    ////////////
    // *AMEBA 4//
    ////////////

    this.moveDriftAndEatTest(
        phase,
        this.playerBlue,
        false,
        true,
        5,
        GameDirection.Middle,
        0,
        1,
        2,
        4,
        0,
        0,
        5,
        4,
        false,
        true,
        4,
        1,
        0,
        5,
        4,
        4,
        1,
        0);
    this.goHavingANap(); // @for see only

    assertFalse(phase.getButtonGoToPhase2IsEnabled());
    ////////
    // RED//
    ///////

    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(this.playerRed));
    assertThat(this.playerRed.getNrOfFoodsToEat(), checkInteger.checkInteger(3));

    ////////////
    // *AMEBA 2//
    ////////////
    this.moveDriftAndEatTest(
        phase,
        this.playerRed,
        false,
        true,
        4,
        GameDirection.South,
        1,
        0,
        2,
        2,
        0,
        0,
        3,
        1,
        true,
        false,
        2,
        2,
        2,
        3,
        2,
        1,
        4,
        0);
    this.goHavingANap(); // @for see only

    ////////////
    // *AMEBA 3//
    ////////////
    this.moveDriftAndEatTest(
        phase,
        this.playerRed,
        true,
        false,
        0,
        GameDirection.North,
        2,
        0,
        1,
        3,
        1,
        1,
        2,
        4,
        true,
        false,
        2,
        2,
        2,
        2,
        3,
        0,
        4,
        1);
    this.goHavingANap(); // @for see only

    assertTrue(phase.getButtonGoToPhase2IsEnabled());

    phase.fakeClickbuttonGoToPhase2();
    return ursuppe;
  }
예제 #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));
  }