コード例 #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();
 }