示例#1
0
        public static Game InitNewGame(RemotePlayer BlueSide, RemotePlayer RedSide)
        {
            var game = new Game(BlueSide, RedSide, new StandardGameRuleSet());

            game.OnGameEnded += EndGame;
            BlueSide.JoinGame(game);
            RedSide.JoinGame(game);
            lock (Games)
            {
                Games.Add(game);
            }
            return(game);
        }
        private void OnJoinTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c    = (JoinTableCommand)command;
            var game = (PokerGame)Lobby.GetGame(c.TableId);

            if (game == null || !game.IsRunning)
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.WrongTableState, "You can't join a game that isn't running !"));
                return;
            }
            var table = game.Table;

            if (table.Seats.Players().ContainsPlayerNamed(client.PlayerName))
            {
                client.SendCommand(c.ResponseFailure(TaluvaMessageId.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(TaluvaMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            Logger.LogInformation("> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);


            var r = c.ResponseSuccess();

            r.GameHasStarted = rp.Game.IsPlaying;
            //r.BoardCards = rp.Game.Table.Cards.Select(x => x.ToString()).ToArray();
            r.Seats  = rp.AllSeats().ToList();
            r.Params = rp.Game.Table.Params;
            //r.TotalPotAmount = rp.Game.Table.Bank.MoneyAmount;
            //r.PotsAmount = rp.Game.Table.Bank.PotAmountsPadded(rp.Game.Table.Params.MaxPlayers).ToList();

            client.SendCommand(r);
        }
        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();
        }
        private void OnJoinTableCommandReceived(AbstractCommand command, IBluffinClient client)
        {
            var c = (JoinTableCommand)command;
            var game = (PokerGame)Lobby.GetGame(c.TableId);
            var table = game.Table;
            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, Server, c.TableId);
            if (!rp.JoinGame())
            {
                client.SendCommand(c.ResponseFailure(BluffinMessageId.SpecificServerMessage, "Unknown failure"));
                return;
            }

            client.AddPlayer(rp);

            Logger.LogInformation("> Client '{0}' joined {2}:{1}", client.PlayerName, table.Params.TableName, c.TableId, rp.Player.NoSeat);


            var r = c.ResponseSuccess();

            r.GameHasStarted = rp.Game.IsPlaying;
            r.BoardCards = rp.Game.Table.Cards.Select(x => x.ToString()).ToArray();
            r.Seats = rp.AllSeats().ToList();
            r.Params = rp.Game.Table.Params;
            r.TotalPotAmount = rp.Game.Table.TotalPotAmnt;
            r.PotsAmount = rp.Game.Table.PotAmountsPadded.ToList();

            client.SendCommand(r);
        }