/** * * 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; } }
private void saveGame(boolean show) { File file = new File(getFilesDir(), "game_" + game.getMode()); Tools.writeSerializableInFile(this, game, file); if (show) Tools.Toast(this, "Game saved"); }