Exemple #1
0
  @Test
  public void testIsFinishedPlayerReachedFinalCell() {
    assertFalse(this.mGame.isFinished());

    // Put a player in the final cell.
    final Board board = this.mGame.getBoard();
    final Player player = this.mGame.nextPlayer();
    final ICell finalCell = board.getCell(board.getSize() - 1);

    finalCell.welcome(player);
    player.setCell(finalCell);

    // Game must be finished.
    assertTrue(this.mGame.isFinished());
    finalCell.empty();
  }
Exemple #2
0
  @Test
  public void testIsFinishedAllPlayersAreTrapped() {
    final Board board = this.mGame.getBoard();

    // Browse through the board to get trap cells and put Players in them
    int nbPlayersTrapped = 0;
    for (int i = 0; i < board.getSize() && nbPlayersTrapped < 5; i++) {
      ICell c = board.getCell(i);

      if (c instanceof TrapCell && !c.isBusy()) {
        final Player player = this.mGame.nextPlayer();
        c.welcome(player);
        player.setCell(c);
        nbPlayersTrapped++;
      }
    }

    assertTrue(this.mGame.isFinished());
  }