コード例 #1
0
        private void OnJoinTableCommandReceived(AbstractBluffinCommand command, IBluffinClient client)
        {
            var c = (JoinTableCommand)command;
            var game = Lobby.GetGame(c.TableId);
            var table = game.GameTable;
            if (!game.IsRunning)
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.WrongTableState, "You can't join a game that isn't running !"));
                return;
            }
            if (table.ContainsPlayer(client.PlayerName))
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.NameAlreadyUsed, "Someone with your name is already in this game !"));
                return;
            }
            var rp = new RemotePlayer(game, new PlayerInfo(client.PlayerName, 0), client, c.TableId);
            if (!rp.JoinGame())
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            LogManager.Log(LogLevel.Message, "BluffinLobbyWorker.OnJoinTableCommandReceived", "> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);
            client.SendCommand(c.ResponseSuccess());

            rp.SendTableInfo();
        }