Exemple #1
0
        private void NewGamePlayer(NetTunnel tunnel, string ticket)
        {
            if (string.IsNullOrEmpty(ticket))
            {
                Logger.Log(LogType.Error, "Received an empty ticket");
                tunnel.Destroy();
                return;
            }

            if (ticketRoomList.ContainsKey(ticket) && ticketPlayerList.ContainsKey(ticket))
            {
                LobbyPlayer lobbyPlayer = ticketPlayerList[ticket];
                CGameRoom   room        = ticketRoomList[ticket];

                room.JoinGame(lobbyPlayer, tunnel);

                ticketPlayerList.Remove(ticket);
                ticketRoomList.Remove(ticket);

                Logger.Log(LogType.Event, "Player " + lobbyPlayer.Name + " joined " + room.Name);
            }
            else
            {
                Logger.Log(LogType.Error, "Received an invalid ticket");
                tunnel.Destroy();
                return;
            }
        }
 public void Quit()
 {
     DepositBank(wallet);
     gameRoom.LeaveGame(this);
     lobbyEntity.GameRoomPlayers.Remove(this);
     tunnel.Destroy();
 }
Exemple #3
0
        private void NewLobbyPlayer(NetTunnel tunnel)
        {
            string username   = tunnel.WaitMessage();
            string hashedPass = tunnel.WaitMessage();

            if (string.IsNullOrEmpty(username))
            {
                Logger.Log(LogType.Error, "Blank username");
                tunnel.Destroy();
                return;
            }

            if (string.IsNullOrEmpty(hashedPass))
            {
                Logger.Log(LogType.Error, "Blank password");
                tunnel.Destroy();
                return;
            }

            LobbyPlayer lobbyPlayer = Database.Login(username, hashedPass, tunnel, this);

            if (lobbyPlayer == null)
            {
                tunnel.SendMessage("fail");
                tunnel.Destroy();
                Logger.Log(LogType.Event, "Bad login attempt (bad credentials) from " + username);
                return;
            }
            else if (lobbyList.ContainsKey(lobbyPlayer.Name))
            {
                if (lobbyList[lobbyPlayer.Name].Tunnel.SendMessage("alreadyin"))
                {
                    tunnel.SendMessage("fail");
                    tunnel.Destroy();
                    Logger.Log(LogType.Event, "Bad login attempt (existing player) from " + username);
                    return;
                }
                else
                {
                    tunnel.SendMessage("ok");
                }
            }
            else
            {
                tunnel.SendMessage("ok");
            }

            lobbyList.Add(lobbyPlayer.Name, lobbyPlayer);

            Logger.Log(LogType.Event, "Added player to lobby " + lobbyPlayer.Name);
        }
        public void QuitRoom()
        {
            this.bank += this.wallet;
            this.lobbyPlayer.SetBank(this.bank);

            gameRoom.OnQuitEvent(this);

            //lobbyPlayer.GameRoomPlayers.Remove(this);

            tunnel.Destroy();
        }
Exemple #5
0
        public void Destroy()
        {
            Logger.Log(LogType.Event, this.name + " has left");

            List <CGamePlayer> tmpList = new List <CGamePlayer>(gamePlayers);

            foreach (CGamePlayer i in tmpList)
            {
                i.Quit();
            }

            Database.SaveBank(this.Name, this.bank);

            tunnel.Destroy();
        }
        private void NewLobbyPlayer(NetTunnel tunnel)
        {
            string username = tunnel.WaitMessage();
            string hashedPass = tunnel.WaitMessage();

            if (string.IsNullOrEmpty(username))
            {
                Logger.Log(LogType.Error, "Blank username");
                tunnel.Destroy();
                return;
            }

            if (string.IsNullOrEmpty(hashedPass))
            {
                Logger.Log(LogType.Error, "Blank password");
                tunnel.Destroy();
                return;
            }

            LobbyPlayer lobbyPlayer = Database.Login(username, hashedPass, tunnel, this);

            if (lobbyPlayer == null)
            {
                tunnel.SendMessage("fail");
                tunnel.Destroy();
                Logger.Log(LogType.Event, "Bad login attempt (bad credentials) from " + username);
                return;
            }
            else if (lobbyList.ContainsKey(lobbyPlayer.Name))
            {
                if (lobbyList[lobbyPlayer.Name].Tunnel.SendMessage("alreadyin"))
                {
                    tunnel.SendMessage("fail");
                    tunnel.Destroy();
                    Logger.Log(LogType.Event, "Bad login attempt (existing player) from " + username);
                    return;
                }
                else
                {
                    tunnel.SendMessage("ok");
                }
            }
            else
            {
                tunnel.SendMessage("ok");
            }

            lobbyList.Add(lobbyPlayer.Name, lobbyPlayer);

            Logger.Log(LogType.Event, "Added player to lobby " + lobbyPlayer.Name);
        }
        private void NewGamePlayer(NetTunnel tunnel, string ticket)
        {
            if (string.IsNullOrEmpty(ticket))
            {
                Logger.Log(LogType.Error, "Received an empty ticket");
                tunnel.Destroy();
                return;
            }

            if (ticketRoomList.ContainsKey(ticket) && ticketPlayerList.ContainsKey(ticket))
            {
                LobbyPlayer lobbyPlayer = ticketPlayerList[ticket];
                CGameRoom room = ticketRoomList[ticket];

                room.JoinGame(lobbyPlayer, tunnel);

                ticketPlayerList.Remove(ticket);
                ticketRoomList.Remove(ticket);

                Logger.Log(LogType.Event, "Player " + lobbyPlayer.Name + " joined " + room.Name);
            }
            else
            {
                Logger.Log(LogType.Error, "Received an invalid ticket");
                tunnel.Destroy();
                return;
            }
        }