示例#1
0
  public void guess(char guess, String name) {
    hangmanRules.makeGuess(guess);
    isComplete = hangmanRules.gameEnded();

    writeMessage(getGameState(guess, name));

    if (isComplete) {
      /* Start cleaning up */
      stopGame();
    }
  }
示例#2
0
  public void writeMessage(String msg) {
    Socket socket = null;
    TCPHandle handle = null;
    List<HangmanRules<Socket>.Player> players = hangmanRules.getPlayers();

    for (HangmanRules<Socket>.Player player : players) {
      socket = player.playerData;
      handle = new TCPHandle(socket);
      handle.write(msg);
    }
  }
示例#3
0
 public String getGameState(char guess, String name) {
   String gameState =
       guess + " " + hangmanRules.getMaskedWord() + " " + hangmanRules.getTriesLeft() + " " + name;
   return gameState;
 }
示例#4
0
 public String getStatus() {
   return hangmanRules.getStatus();
 }