Пример #1
0
        public bool JoinGame(LobbyPlayer lobbyPlayer, NetTunnel tunnel)
        {
            string pname = lobbyPlayer.Name;

            if (spectators.ContainsKey(pname))
            {
                // should trigger unexpected disconnect and remove itself from list if disconnected
                if (spectators[pname].Tunnel.Ping())
                {
                    Logger.Log(LogType.Error, pname + " is already a spectator when he suppied the correct ticket to join " + name);

                    tunnel.SendMessage("fail");
                    return(false);
                }
            }

            CGamePlayer newPlayer = null;

            if (GAME_TYPE == typeof(TexasHoldem))
            {
                newPlayer = new THPlayer(lobbyPlayer, tunnel, this);
            }
            else
            {
                Logger.Log(LogType.Error, "unknown game type");
                tunnel.SendMessage("fail");
                return(false);
            }

            spectators.Add(pname, newPlayer);

            Logger.Log(LogType.Debug, pname + " joined game " + name);

            newPlayer.Tunnel.SendMessage(newPlayer.Name);
            newPlayer.Tunnel.SendMessage(this.name);
            newPlayer.Tunnel.SendMessage(BUY_IN.ToString("0"));
            newPlayer.Tunnel.SendMessage(MAX_BUY_IN.ToString("0"));

            newPlayer.Status = PlayerStatus.Standing;

            SendAllSeatInfo(newPlayer);

            return(true);
        }
Пример #2
0
        public bool JoinGame(LobbyPlayer lobbyPlayer, NetTunnel tunnel)
        {
            string pname = lobbyPlayer.Name;
            if (spectators.ContainsKey(pname))
            {
                // should trigger unexpected disconnect and remove itself from list if disconnected
                if (spectators[pname].Tunnel.Ping())
                {
                    Logger.Log(LogType.Error, pname + " is already a spectator when he suppied the correct ticket to join " + name);

                    tunnel.SendMessage("fail");
                    return false;
                }
            }

            CGamePlayer newPlayer = null;

            if (GAME_TYPE == typeof(TexasHoldem))
                newPlayer = new THPlayer(lobbyPlayer, tunnel, this);
            else
            {
                Logger.Log(LogType.Error, "unknown game type");
                tunnel.SendMessage("fail");
                return false;
            }

            spectators.Add(pname, newPlayer);

            Logger.Log(LogType.Debug, pname + " joined game " + name);

            newPlayer.Tunnel.SendMessage(newPlayer.Name);
            newPlayer.Tunnel.SendMessage(this.name);
            newPlayer.Tunnel.SendMessage(BUY_IN.ToString("0"));
            newPlayer.Tunnel.SendMessage(MAX_BUY_IN.ToString("0"));

            newPlayer.Status = PlayerStatus.Standing;

            SendAllSeatInfo(newPlayer);

            return true;
        }