Пример #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));
  }
Пример #2
0
  @Given("startPhaseSetFirstAmeba")
  public UrsuppeGUI testDataPhaseSetFirstAmeba(UrsuppeGUI ursuppe) {
    PhaseSetFirstAmeba phase =
        (PhaseSetFirstAmeba)
            this.getObjectPhase(
                this.phaseLogic
                    .getActivePhase()); // Important! Each phase test should have this line!

    // System.out.println("ORDER OF PLAYERS IN SCRIPTED GAME: "+
    // this.game.getOrderOfPlayersColor());
    assertTrue(this.game.getOrderOfPlayersColor().equals(this.getControlOrder())); // Check order!

    /////////////////////////
    //// *SET FIRST AMEBA*////
    /////////////////////////

    ///////////
    // YELLOW://
    ///////////

    setAmebaPhaseSetFirstAmebaCheck(
        phase, this.playerYellow, 4, 0, true, true, true, true, 1, 2, 2, 1);
    this.goHavingANap(); // @for see only

    /////////
    // BLUE://
    /////////

    this.setAmebaPhaseSetFirstAmebaCheck(
        phase, this.playerBlue, 4, 0, true, true, true, true, 3, 4, 2, 1);
    this.goHavingANap(); // @for see only

    ////////
    // RED://
    ///////

    this.setAmebaPhaseSetFirstAmebaCheck(
        phase, this.playerRed, 4, 0, true, true, true, true, 3, 2, 4, 1);
    this.goHavingANap(); // @for see only

    /////////////////////////
    //// *SET SECOND AMEBA*////
    /////////////////////////

    ///////////
    // YELLOW://
    ///////////
    this.setAmebaPhaseSetFirstAmebaCheck(
        phase, this.playerYellow, 3, 1, false, true, true, true, 3, 4, 3, 0);
    this.goHavingANap(); // @for see only

    /////////
    // BLUE://
    /////////
    this.setAmebaPhaseSetFirstAmebaCheck(
        phase, this.playerBlue, 3, 1, true, true, false, true, 4, 5, 4, 0);
    this.goHavingANap(); // @for see only

    ////////
    // RED://
    ///////
    this.setAmebaPhaseSetFirstAmebaCheck(
        phase, this.playerRed, 3, 1, true, true, false, true, 2, 3, 1, 0);
    this.goHavingANap(); // @for see only

    ///////// THIS WAS THE LAST AMEBA!
    assertTrue(phase.getButtonGoToPhase1IsEnabled());
    phase.fakeClickButtonGoToPhase1();

    return ursuppe;
  }