Exemplo n.º 1
0
 /** Broadcasts only to user specified by id */
 public synchronized void broadcastTo(Object e, int id) {
   if (e instanceof Trade) {
     Trade tr = (Trade) e;
     if (!tr.isBuild() && (tr.isPropose() || tr.isComplete())) _board.notifyAITrade(tr);
   }
   if (id < _clients.size()) _clients.get(id).send(e);
 }
Exemplo n.º 2
0
  /** broadcasts to everyone but the client sender */
  public synchronized void broadcast(Object e, ClientHandler sender) {
    if (e instanceof Trade) {
      Trade tr = (Trade) e;
      if (tr.isPropose()
          && !_tradeIDs.containsKey(tr.getTradeID())
          && !tr.isBuild()
          && tr.getTradeID() != -1) addTrade(tr.getTradeID(), sender.getIndex());
      if (!tr.isBuild() && (tr.isPropose() || tr.isComplete())) _board.notifyAITrade(tr);
    }
    for (ClientHandler client : _clients) {
      if (sender != null && sender == client) {
        continue;
      }

      client.send(e);
    }
  }
Exemplo n.º 3
0
 /** Mark the player as no longer connected */
 public void lostConnection(int i) {
   _board.lostPlayer(i);
 }
Exemplo n.º 4
0
 /**
  * Send the initialization message which includes the number of players, your index, the points
  * needed to win, what hexes make up the board, and where ports are. Then it sends the two free
  * roads and two free settlements
  */
 public synchronized void initMessage(ClientHandler client) {
   client.send(client.getIndex() + "," + _numCon + "," + _board.getPointsToWin());
   client.send(_board.getState());
   client.send(_board.getPorts());
   client.send("7/free");
 }