Ejemplo n.º 1
0
  /**
   * @param phase
   * @param currentPlayer
   * @param nrOfAmebasOffBoardBefore
   * @param nrOfAmebasOnBoardBefore
   * @param radioButton1IsEnabled
   * @param radioButton2IsEnabled
   * @param radioButton3IsEnabled
   * @param radioButton4IsEnabled
   * @param choseAmebaNr
   * @param xCoordinate
   * @param yCoordinate
   * @param damagePointsOfAmeba
   */
  public void setAmebaPhaseSetFirstAmebaCheck(
      PhaseSetFirstAmeba phase,
      Player currentPlayer,
      int nrOfAmebasOffBoardBefore,
      int nrOfAmebasOnBoardBefore,
      boolean radioButton1IsEnabled,
      boolean radioButton2IsEnabled,
      boolean radioButton3IsEnabled,
      boolean radioButton4IsEnabled,
      int choseAmebaNr,
      int xCoordinate,
      int yCoordinate,
      int damagePointsOfAmeba) {
    assertThat(this.game.getActualPlayer(), checkPlayer.checkPlayer(currentPlayer));
    assertThat(
        currentPlayer.getNumbersOfAmebasOffBoard(),
        checkInteger.checkInteger(nrOfAmebasOffBoardBefore));
    assertThat(
        currentPlayer.getNumbersOfAmebasOnBoard(),
        checkInteger.checkInteger(nrOfAmebasOnBoardBefore));

    assertThat(
        phase.getRadioButtonAmeba1IsEnabled(), checkBoolean.checkBoolean(radioButton1IsEnabled));
    assertThat(
        phase.getRadioButtonAmeba2IsEnabled(), checkBoolean.checkBoolean(radioButton2IsEnabled));
    assertThat(
        phase.getRadioButtonAmeba3IsEnabled(), checkBoolean.checkBoolean(radioButton3IsEnabled));
    assertThat(
        phase.getRadioButtonAmeba4IsEnabled(), checkBoolean.checkBoolean(radioButton4IsEnabled));

    assertFalse(phase.getButtonGoToPhase1IsEnabled());
    assertFalse(phase.getButtonSetAmebaIsEnabled());
    assertTrue(phase.getButtonCheckPossibleSquareIsEnabled());

    // Chose ameba nr #:
    switch (choseAmebaNr) {
      case 1:
        {
          phase.fakeClickRadioButton1();
          break;
        }
      case 2:
        {
          phase.fakeClickRadioButton2();
          break;
        }
      case 3:
        {
          phase.fakeClickRadioButton3();
          break;
        }
      case 4:
        {
          phase.fakeClickRadioButton4();
          break;
        }
      default:
        {
          System.out.println(
              "Error in ScriptedGame1.class: unkown case in setAmebaPhaseSetFirstAmebaCheck()!");
          // TODO
          assertTrue(false);
          break;
        }
    }

    assertFalse(phase.getButtonGoToPhase1IsEnabled());
    assertFalse(phase.getButtonSetAmebaIsEnabled());
    assertTrue(phase.getButtonCheckPossibleSquareIsEnabled());

    // Set coordinate:

    phase.setTextTextFieldX(Integer.toString(xCoordinate));
    phase.setTextTextFieldY(Integer.toString(yCoordinate));

    phase.fakeClickCheckPossibleSquare();

    assertFalse(phase.getButtonGoToPhase1IsEnabled());
    assertTrue(phase.getButtonSetAmebaIsEnabled());
    assertTrue(phase.getButtonCheckPossibleSquareIsEnabled());

    // Set ameba:
    phase.fakeClickButtonSetAmeba();

    // Check square:
    assertFalse(this.game.getBoard().getSquare(xCoordinate, yCoordinate).isEmpy());

    // Check ameba
    Ameba newSetAmeba = this.game.getActiveAmeba();

    assertThat(newSetAmeba.getColor(), checkColor.checkColor(currentPlayer.getColor()));
    assertThat(newSetAmeba.getNumber(), checkInteger.checkInteger(choseAmebaNr));
    assertThat(newSetAmeba.getDamagePoints(), checkInteger.checkInteger(damagePointsOfAmeba));

    assertThat(
        this.playerYellow.getNumbersOfAmebasOffBoard(),
        checkInteger.checkInteger(nrOfAmebasOffBoardBefore - 1));
    assertThat(
        this.playerYellow.getNumbersOfAmebasOnBoard(),
        checkInteger.checkInteger(nrOfAmebasOnBoardBefore + 1));
  }
Ejemplo 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));
  }