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