Beispiel #1
0
 private void handleInGameCommands(TBGToken msg, ProtocolCallback<TBGToken> callback) {
   if (msg.getCommandType().equals("MSG") && msg.getArgs() != null && !msg.getArgs().equals("")) {
     myRoom.sendMessage(this, msg.getArgs());
   } else if (msg.getCommandType().equals("START")
       && msg.getArgs() != null
       && !msg.getArgs().equals("")
       && myRoom.startGame(msg.getArgs())) {
   } else if (msg.getCommandType().equals("TXTRESP")
       && msg.getArgs() != null
       && !msg.getArgs().equals("")) {
     myRoom.play(this, msg);
   } else if (msg.getCommandType().equals("SELECTRESP")
       && msg.getArgs() != null
       && !msg.getArgs().equals("")) {
     myRoom.play(this, msg);
   }
 }
Beispiel #2
0
 private TBGToken joinToRoom(TBGToken msg) {
   GameRoom room = gameRooms.get(msg.getArgs());
   if (room == null) {
     room = new GameRoom(msg.getArgs());
     gameRooms.put(msg.getArgs(), room);
     room.join(this);
     myRoom = room;
     return new TBGToken("SYSMSG", msg.getCommandType() + " ACCEPTED");
   } else {
     if (room.join(this)) {
       myRoom = room;
       return new TBGToken("SYSMSG", msg.getCommandType() + " ACCEPTED");
     } else
       return new TBGToken(
           "SYSMSG", msg.getCommandType() + " REJECTED ; room is closed for new players");
   }
 }