Exemplo n.º 1
0
  /**
   * * OnClick for the gameBoard's cells
   *
   * @param v : View from the cell where the player want to add a piece
   */
  @Override
  public void onClick(View v) {
    // Get move from cell
    ImageView cell = (ImageView) v;
    Move nextMove = getMoveFromCase(cell);

    // Play the move in the game
    game.playMove(nextMove);

    // Update graphics
    updateGraphic();
    switch (game.getState()) {
      case Game.NO_MOVE:
        Tools.Toast(
            getApplicationContext(),
            "No possible move for player "
                + game.getActualPlayer().getName()
                + ",\nit's "
                + game.getEnemyPlayer().getName()
                + " turn");
        break;
      case Game.IMPOSSIBLE_MOVE:
        Tools.Toast(
            getApplicationContext(), "Move : " + nextMove.toString() + " is not possible !");
        break;
      case Game.END_GAME:
        Tools.Toast(
            getApplicationContext(), "Move : " + nextMove.toString() + " is not possible !");
        endGame();
        break;
    }
  }
Exemplo n.º 2
0
 public Player getNameWinner() {
   return game.getActualPlayer().getScore() > game.getEnemyPlayer().getScore()
       ? game.getActualPlayer()
       : game.getEnemyPlayer();
 }