Esempio n. 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();
    }
  }
Esempio n. 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);
    }
  }
Esempio n. 3
0
 public String getGameState(char guess, String name) {
   String gameState =
       guess + " " + hangmanRules.getMaskedWord() + " " + hangmanRules.getTriesLeft() + " " + name;
   return gameState;
 }
Esempio n. 4
0
 public String getStatus() {
   return hangmanRules.getStatus();
 }