private void PlayerJoinRoom(IHanabiPlayer player, RequestJoinRoom request) { RoomInfo roomInfo = new RoomInfo(); JoinRoomResult result = JoinRoomResult.Fail; if (player.RoomStatus == PlayerRoomStatus.Idle) { RoomIndexType roomIndex = new RoomIndexType(request.RoomIndex); if (Rooms.ContainsKey(roomIndex)) { Room room = Rooms[roomIndex]; if (room.Players.Count < room.Setting.MaxPlayers) { room.Players.Add(player); roomInfo = room.Info; player.OnJoinRoom(room); result = JoinRoomResult.Success; } } } ResponseJoinRoom response = new ResponseJoinRoom(); response.Result = result; response.Room = roomInfo; SendCommand(player, ActionType.JoinRoom, response); }
private bool VerifyJoinRoom(Command c, JoinRoomResult result, int userCount) { if (c.action != ActionType.JoinRoom.ToString()) { return(false); } ResponseJoinRoom response = JsonConvert.DeserializeObject <ResponseJoinRoom>(c.payload); if (response.result != result) { return(false); } return((response.result == JoinRoomResult.Fail) ? true : (response.room.players.Count == userCount)); }