Ejemplo n.º 1
0
        public GameRoom CreateRoom(string name, byte[] gameInfo, PlayerAccount host)
        {
            var room = new GameRoom(name, nextRoomID, LobbyID, gameInfo, host);

            Rooms.Add(nextRoomID, room);
            nextRoomID--;
            return(room);
        }
Ejemplo n.º 2
0
 public GameRoom(string name, int id, int lobbyId, byte[] gameInfo, PlayerAccount host)
 {
     Name            = name;
     ID              = id;
     lobbyID         = lobbyId;
     GameInformation = gameInfo;
     Host            = host;
     // Players.Add(host);
 }
Ejemplo n.º 3
0
        protected void LadderLogin(Message msg)
        {
            var username = msg.Data[0].AsString;
            var game     = msg.Data[1].AsString;

            account = PlayerAccount.Get(username);
            if (account != null)
            {
                Connection.Send(msg.SuccessResponse(new DNodeList()));
            }
        }
Ejemplo n.º 4
0
        void GetPlayerInfo(Message msg)
        {
            var username = msg.Data[0].AsString;

            var acc = PlayerAccount.Get(username);

            if (acc == null)
            {
                Connection.Send(msg.FailResponse(new DNodeList {
                    new DNodeBinary(1)
                }));
            }
            else
            {
                Connection.Send(msg.SuccessResponse(new DNodeList {
                    acc.IrcAlias, acc.Username, acc.FirstName, acc.LastName, acc.Language, acc.Email, acc.PublicIP
                }));
            }
        }
Ejemplo n.º 5
0
        protected void LoginWaitModuleCmd(Message msg)
        {
            var username = msg.Data[0].AsString;

            account = PlayerAccount.Get(username);

            if (account != null)
            {
                Connection.Send(msg.SuccessResponse());
            }
            else
            {
                Connection.Send(msg.FailResponse(new DNodeList {
                    new DNodeBinary(2)
                }));
            }

            account.PublicIP = Connection.IP;
        }
Ejemplo n.º 6
0
        protected void LoginCmd(Message msg)
        {
            var username = msg.Data[0].AsString;
            var password = msg.Data[1].AsString;
            var game     = msg.Data[2].AsString; // "SHOKPC1.05"

            var acc = PlayerAccount.Get(username);

            if (acc != null)
            {
                if (acc.CheckPassword(password))
                {
                    if (!PlayerAccount.LoggedInAccounts.Contains(acc))
                    {
                        PlayerAccount.LoggedInAccounts.Add(acc);
                        Connection.Send(msg.SuccessResponse());
                    }
                    else
                    {
                        Connection.Send(msg.FailResponse(new DNodeList {
                            new DNodeBinary((int)LoginResponses.AlreadyLoggedIn)
                        }));
                    }
                }
                else
                {
                    Connection.Send(msg.FailResponse(new DNodeList {
                        new DNodeBinary((int)LoginResponses.WrongPassword)
                    }));
                }
            }
            else
            {
                Connection.Send(msg.FailResponse(new DNodeList {
                    new DNodeBinary((int)LoginResponses.InvalidUsername)
                }));
            }
        }
Ejemplo n.º 7
0
        protected void NewUserCmd(Message msg)
        {
            var game      = msg.Data[0].AsString; //SHOKPC1.05
            var username  = msg.Data[1].AsString;
            var password  = msg.Data[2].AsString;
            var firstName = msg.Data[3].AsString;
            var lastName  = msg.Data[4].AsString;
            var email     = msg.Data[5].AsString;
            var language  = msg.Data[6].AsString;

            if (!PlayerAccount.IsNameAvailable(username))
            {
                Connection.Send(msg.FailResponse(new DNodeList {
                    new DNodeBinary(1)
                }));
            }
            else
            {
                var pa = new PlayerAccount
                {
                    Username  = username,
                    FirstName = firstName,
                    LastName  = lastName,
                    Email     = email,
                    Language  = language
                };
                pa.SetPassword(password);
                pa.UpdateStore();

                Connection.Send(msg.SuccessResponse());
            }

            /* 1    username taken
             * 2    username not according to rules
             * 3    username contains illegal words
             * */
        }
Ejemplo n.º 8
0
        protected void LobbyServerLogin(Message msg)
        {
            var username    = msg.Data[0].AsString;
            var unknownNum  = msg.Data[1].AsInt;
            var localIP     = msg.Data[2].AsString;
            var localSubnet = msg.Data[3].AsString;
            var unknownNum2 = msg.Data[4].AsInt;

            Connection.WriteDebug("lobby server login ({0} | {1})", unknownNum, unknownNum2);

            account = PlayerAccount.Get(username);
            if (account != null)
            {
                account.LocalIP     = localIP;
                account.LocalSubnet = localSubnet;
                account.PublicIP    = Connection.IP;

                Connection.Send(new Message(MessageCode.GSSUCCESS, new DNodeList {
                    (int)MessageCode.LOBBYSERVERLOGIN, new DNodeList {
                        Constants.LOBBY_SERVER_ID
                    }
                }));
            }
        }