private GamePlayer(LobbyPlayer lobbyPlayer, NetTunnel tunnel, GameRoom room)
        {
            this.name = lobbyPlayer.Name;
            this.tunnel = tunnel;
            this.bank = lobbyPlayer.Bank;

            this.lobbyPlayer = lobbyPlayer;
            this.gameRoom = room;

            this.tunnel.OnMessageReceivedEvent += new NetTunnel.OnMessageReceivedCall(tunnel_OnMessageReceivedEvent);
            this.tunnel.OnUnexpectedDisconnectEvent += new NetTunnel.OnUnexpectedDisconnectCall(tunnel_OnUnexpectedDisconnectEvent);
        }
        protected CGamePlayer(LobbyPlayer lobbyPlayer, NetTunnel tunnel, CGameRoom gameRoom)
        {
            this.name = lobbyPlayer.Name;
            this.tunnel = tunnel;
            this.tunnel.Identifier = this.name + " (GamePlayer)";
            this.bank = lobbyPlayer.Bank;

            this.lobbyEntity = lobbyPlayer;
            this.lobbyEntity.GameRoomPlayers.Add(this);

            this.gameRoom = gameRoom;

            this.tunnel.OnUnexpectedDisconnectEvent += new NetTunnel.OnUnexpectedDisconnectCall(OnUnexpectedDisconnectEvent);
        }
예제 #3
0
        public static bool ChangePassword(LobbyPlayer player, string newpassword)
        {
            CloseReader();

            Logger.Log(LogType.Event, player.Name + " wants to change password");

            try
            {
                string username = player.Name;

                string query = String.Format(
                    "SELECT * FROM {0} WHERE (Name='{1}')",
                    playerTableName, username);

                MySqlCommand cmd = new MySqlCommand(query, dbConnection);
                dbReader = cmd.ExecuteReader();

                if (dbReader.HasRows == false)
                {
                    CloseReader();
                    return false;
                }

                CloseReader();

                query = String.Format(
                    "UPDATE {0} SET Password='******', Active='1' WHERE Name='{2}'",
                    playerTableName, newpassword, username);

                cmd = new MySqlCommand(query, dbConnection);
                dbReader = cmd.ExecuteReader();
                CloseReader();

                Logger.Log(LogType.Event, player.Name + " successfully changed password");

                return true;
            }
            catch (Exception ex)
            {
                Logger.Log("During password change for " + player.Name, ex);
                return false;
            }
        }
예제 #4
0
 public THPlayer(LobbyPlayer lobbyPlayer, NetTunnel tunnel, CGameRoom gameRoom)
     : base(lobbyPlayer, tunnel, gameRoom)
 {
     tunnel.OnMessageReceivedEvent += new NetTunnel.OnMessageReceivedCall(OnMessageReceivedEvent);
 }
예제 #5
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;
        }
예제 #6
0
        public string GetTicket(LobbyPlayer lobbyPlayer, List<string> existingGUIDList)
        {
            if (spectators.ContainsKey(lobbyPlayer.Name))
            {
                if (spectators[lobbyPlayer.Name].Tunnel.Ping())
                {
                    Logger.Log(LogType.Error, lobbyPlayer.Name + " tried to get a ticket from " + name + " while already in the room");

                    return null;
                }
            }

            string guid = Guid.NewGuid().ToString();

            while (existingGUIDList.Contains(guid))
                guid = Guid.NewGuid().ToString();

            return guid;
        }
 public static GamePlayer GamePlayerFromLobbyPlayer(LobbyPlayer player, NetTunnel tunnel, GameRoom room)
 {
     return new GamePlayer(player, tunnel, room);
 }
예제 #8
0
 public THPlayer(LobbyPlayer lobbyPlayer, NetTunnel tunnel, CGameRoom gameRoom) : base(lobbyPlayer, tunnel, gameRoom)
 {
     tunnel.OnMessageReceivedEvent += new NetTunnel.OnMessageReceivedCall(OnMessageReceivedEvent);
 }
예제 #9
0
 private void NewTestGame(NetTunnel tunnel)
 {
     TexasHoldem game = new TexasHoldem("Admin Test Game", 500, 1500, this);
     LobbyPlayer lob = new LobbyPlayer("Admin", new NetTunnel(), 9999, this);
     game.JoinGame(lob, tunnel);
 }
예제 #10
0
 public void RemoveLobbyPlayer(LobbyPlayer lobbyPlayer)
 {
     if (lobbyList.ContainsKey(lobbyPlayer.Name))
     {
         lobbyList.Remove(lobbyPlayer.Name);
     }
 }
예제 #11
0
        public void OnRequestGameListEvent(LobbyPlayer lobbyPlayer)
        {
            lobbyPlayer.Tunnel.SendMessage("clrgames");

            for (int i = 0, j = 0; i < roomList.Count; j++)
            {
                if (roomList.ContainsKey(j))
                {
                    CGameRoom room = roomList[j];
                    lobbyPlayer.Tunnel.SendMessage(
                        String.Format(
                            "gameinfo:{0:0},{1},{2}/{3},{4}",
                            j,
                            room.Name,
                            room.PlayerCount,
                            room.MaxSeatNum,
                            room.ChipsInPlay
                        )
                    );

                    i++;
                }
            }
        }
예제 #12
0
        public string OnJoinGameRequestEvent(LobbyPlayer lobbyPlayer, int gameID)
        {
            Logger.Log(LogType.Event, "Player " + lobbyPlayer.Name + " requested to joing gameID " + gameID.ToString("X"));

            if (roomList.ContainsKey(gameID) && lobbyList.ContainsKey(lobbyPlayer.Name))
            {
                string guid = roomList[gameID].GetTicket(lobbyPlayer, ticketPlayerList.Keys.ToList());

                if (guid != null)
                {
                    ticketRoomList.Add(guid, roomList[gameID]);
                    ticketPlayerList.Add(guid, lobbyPlayer);

                    Logger.Log(LogType.Event, "Generated ticket for " + lobbyPlayer.Name);

                    return guid;
                }
                else
                    Logger.Log(LogType.Error, "Player " + lobbyPlayer.Name + " tried to join an room he's already in");
            }
            else
                Logger.Log(LogType.Error, "Player " + lobbyPlayer.Name + " tried to join non-existing game or player does not exist");

            return null;
        }
예제 #13
0
 public static GamePlayer GamePlayerFromLobbyPlayer(LobbyPlayer player, NetTunnel tunnel, GameRoom room)
 {
     return(new GamePlayer(player, tunnel, room));
 }