예제 #1
0
 public void displayTurn(Game game) {
   Player current_player = game.getPlayers()[game.getTurn()];
   int rc[] = current_player.getLastMove();
   if (rc[0] == -1) {
     return;
   }
   String start = "You have ";
   if (current_player.isComputer()) {
     start = "I will";
   }
   System.out.print(
       start
           + " put an "
           + current_player.getIcon()
           + " in the "
           + this.display_position[rc[0]][rc[1]]
           + ".");
 }
예제 #2
0
 /*
  * (non-Javadoc)
  *
  * @see com.games.ttt.view.Viewer#getMove(com.games.ttt.model.Board,
  * com.games.ttt.model.Player)
  */
 @Override
 public int getMove(Game game) {
   // TODO Auto-generated method stub
   this.displayBoard(game.getBoard());
   int number = 0;
   while (number < 1) {
     number = this.readInput();
   }
   return number;
 }
예제 #3
0
 public void displayEnd(Game game) {
   Player players[] = game.getPlayers();
   switch (game.getStatus()) {
     case Game.GAME_TIED:
       System.out.println("Looks like we tied");
       break;
     case Game.PLAYER1_WON:
       if (players[0].isComputer()) {
         System.out.println("Sorry you lost");
       } else {
         System.out.println("You have beaten my poor AI!");
       }
       break;
     case Game.PLAYER2_WON:
       if (players[1].isComputer()) {
         System.out.println("Sorry you lost");
       } else {
         System.out.println("You have beaten my poor AI!");
       }
       break;
   }
   this.displayBoard(game.getBoard());
 }