Esempio n. 1
0
        public void LoginCharacter(string name, string password)
        {
            foreach (PlayerMobile character in Characters)
            {
                if (character.Name == name)
                {
                    // Check if anyone is using this Character
                    if (World.IsPlayerOnline(name))
                    {
                        Console.WriteLine("Login: {0}: Character is already logged in", PlayerSocket);
                        PlayerSocket.Send(new CharacterLoginReplyPacket(ALRReason.CharInUse));
                        return;
                    }

                    if (!character.ValidPassword(password))
                    {
                        Console.WriteLine("Login: {0}: Invalid Password", PlayerSocket);
                        PlayerSocket.Send(new CharacterLoginReplyPacket(ALRReason.CharInvPw));
                        return;
                    }

                    PlayerSocket.Mobile    = character;
                    character.PlayerSocket = PlayerSocket;

                    character.Spawn();

                    PlayerSocket.Send(new CharacterLoginReplyPacket(character));
                    DoLogin();
                    return;
                }
            }
            Console.WriteLine("Login: {0}: Character {1} not assigned to account", PlayerSocket, name);
            PlayerSocket.Send(new CharacterLoginReplyPacket(ALRReason.CharInUse));
            PlayerSocket.Dispose();
        }
Esempio n. 2
0
        public void LoginAccount(PlayerSocket ps, string un, string pw)
        {
            Account acct = GetAccount(un);

            if (acct == null)
            {
                Console.WriteLine("Login: {0}: Invalid username '{1}'", ps, un);
                ps.Send(new AccountCreateLoginReplyPacket(ALRReason.InvalidAccount));
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", ps, un);
                ps.Send(new AccountCreateLoginReplyPacket(ALRReason.InvalidAccount));
            }
            else if (!acct.ValidPassword(pw))
            {
                Console.WriteLine("Login: {0}: Invalid password for '{1}'", ps, un);
                ps.Send(new AccountCreateLoginReplyPacket(ALRReason.BadPass));
            }
            else
            {
                Console.WriteLine("Login: {0}: Valid credentials for '{1}'", ps, un);
                ps.Account        = acct;
                acct.PlayerSocket = ps;
                ps.Send(new AccountCreateLoginReplyPacket(ALRReason.CorrectPassword));
            }
        }
Esempio n. 3
0
 public void GetCharacterList()
 {
     Console.WriteLine("GetCharacterList");
     //Get characters from database
     Characters = PlayerManager.GetPlayerList(Id);
     //send characters to client
     PlayerSocket.Send(new CharacterListPacket(this));
 }
Esempio n. 4
0
        private void DoLogin()
        {
            PlayerMobile m = PlayerSocket.Mobile as PlayerMobile;

            PlayerSocket.Send(new HardCodedMessagePacket(9, m.Name));//Welcome message
            m.LocalMessage(MessageType.System, "Server Programmed by Magistrate.");

            PlayerSocket.Send(new ReligionPacket(m));        //TODO: Fix with correct Values
            PlayerSocket.Send(new PlayerInventoryPacket(m));
            PlayerSocket.Send(new PlayerEquipmentPacket(m)); //TODO: Fix with correct Values

            PlayerSocket.Send(new PlayerSpellListPacket(m));
            PlayerSocket.Send(new PlayerSkillListPacket(m));

            PlayerSocket.Send(new NumberPlayersPacket());

            PlayerSocket.Send(new PlayerNamePacket(m));
            World.Broadcast(MessageSubscriptionType.Login_Logout, new HardCodedMessagePacket(12, m.Name));//Player xxx joined broadcast????

            PlayerSocket.Send(new PlayerIncomingPacket(m));

            m.SendEverything();

            PlayerSocket.Send(new Unk51Packet());
            PlayerSocket.Send(new PlayerHouseingPacket(m));
            PlayerSocket.Send(new PlayerTeleportPacket((byte)m.Map.MapID, m.X, m.Y, (byte)m.Z));
            //playerSocket.Send(new GMobileName(m));
            PlayerSocket.Send(new Unk03Packet(m));
            PlayerSocket.Send(new Unk03_1Packet(m));
            PlayerSocket.Send(new PlayerLocationPacket(m));
            //0x56 Packet
            PlayerSocket.Send(new WeatherPacket(0, 0, 0));

            PlayerSocket.Send(new PlayerHMEPacket(m));
            PlayerSocket.Send(new PlayerStatsPacket(m));
            PlayerSocket.Send(new PlayerLevelPacket(m));
            PlayerSocket.Send(new PlayerMinMaxDamagePacket(m));

            PlayerSocket.Send(new BrightnessPacket(m.Map));

            PlayerSocket.Send(new Unk55Packet());

            int unreadEmail = 0;

            //foreach (MailMessage mm in m.Mail)
            //    if (!mm.Read)
            //        unreadEmail++;

            if (unreadEmail > 0)
            {
                PlayerSocket.Send(new TextMessagePacket(MessageType.System, String.Format("You have {0} unread mail messages.", unreadEmail)));
            }
        }
Esempio n. 5
0
        public void CreateAccount(PlayerSocket ps, string un, string pw, string em)
        {
            if (!AccountExisits(un))
            {
                if (string.IsNullOrEmpty(un) || string.IsNullOrEmpty(pw) || string.IsNullOrEmpty(em))
                {
                    return;
                }

                bool isSafe = true;

                for (int i = 0; isSafe && i < un.Length; ++i)
                {
                    isSafe = (un[i] >= 0x20 && un[i] < 0x80);
                }

                for (int i = 0; isSafe && i < pw.Length; ++i)
                {
                    isSafe = (pw[i] >= 0x20 && pw[i] < 0x80);
                }

                for (int i = 0; isSafe && i < em.Length; ++i)
                {
                    isSafe = (em[i] >= 0x20 && em[i] < 0x80);
                }

                bool acctAdded = false;
                if (isSafe)
                {
                    Console.WriteLine("Login: {0}: Creating new account '{1}'", ps, un);
                    acctAdded = AddAccount(un, pw, em);
                }

                Console.WriteLine("Login: {0}: Created new account {1}", ps, acctAdded);
                if (acctAdded)
                {
                    ps.Send(new AccountCreateLoginReplyPacket(ALRReason.AccountCreated));
                }
                else
                {
                    ps.Send(new AccountCreateLoginReplyPacket(ALRReason.InvalidAccount));
                }
            }
            else
            {
                ps.Send(new AccountCreateLoginReplyPacket(ALRReason.AccountExists));
            }
        }
Esempio n. 6
0
        public void CreateCharacter(string name, string name2, string password, byte gender, byte hair)
        {
            if (PlayerManager.PlayerExists(name))
            {
                Console.WriteLine("Login: {0}: Character name {1} already exists.", PlayerSocket, name);
                PlayerSocket.Send(new CharacterCreateReplyPacket(ALRReason.CharExist));
                return;
            }

            PlayerManager.CreatePlayer(Id, name, password, gender, hair);

            Console.WriteLine("Login: {0}: New character being created (account={1})", PlayerSocket, UserName);
            Console.WriteLine(" - Character: {0}", name);

            PlayerSocket.Send(new CharacterCreateReplyPacket(ALRReason.CharCreated));
        }
 /// <summary>
 /// 判断本地SnakeBody是否吃到食物
 /// </summary>
 /// <returns></returns>
 public bool IsEatFood()
 {
     if (m_snake.HeadItem().ItemPositon == m_food.FoodPosition)
     {
         this.m_snake.TotalScore += DeltaScore;
         if (this.PlayerGameMode == GameMode.ONLINE)
         {
             PlayerSocket.Send(MessageCode.EAT_FOOD.ToString() + ","
                               + this.Snake.SnakeBodyID);
         }
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// 判断游戏是否结束 吃到自己或者撞到墙
        /// </summary>
        /// <returns></returns>
        public bool IsGameOver()
        {
            if (this.Snake.IsAlive == false)
            {
                return(false);
            }

            m_snake.HitSelfTest();  // 是否吃到自己
            this.HitBorderTest();   // 是否撞到墙
            if (m_snake.IsAlive == false)
            {
                Console.WriteLine("i have dead a!a!a!");
                if (this.PlayerGameMode == GameMode.ONLINE)
                {
                    PlayerSocket.Send(MessageCode.DEAD.ToString() + ","
                                      + this.Snake.SnakeBodyID);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 9
0
 public override void WarpToLocation(IMap targetMap, Point3D targetLocation)
 {
     base.WarpToLocation(targetMap, targetLocation);
     PlayerSocket.Send(new PlayerTeleportPacket(Map.MapID, X, Y, Z));
 }
Esempio n. 10
0
 public override void ProcessMovement(Point3D location, byte direction)
 {
     base.ProcessMovement(location, direction);
     PlayerSocket.Send(new PlayerMovementPacket(this));
 }
Esempio n. 11
0
 public void LostPassword(PlayerSocket ps, string accountName)
 {
     Console.WriteLine("Login: {0}: Lost Password for account {1}", ps, accountName);
 }
Esempio n. 12
0
 public void DownloadScript(PlayerSocket playerSocket, string filename)
 {
 }
Esempio n. 13
0
 public void AddSpawn(PlayerSocket socket, MobileSpawn ms)
 {
 }
Esempio n. 14
0
 public void GetSpawnInfo(PlayerSocket playerSocket, byte mapID, int mobileID)
 {
 }
Esempio n. 15
0
 public override void SendMessage(MessageSubscriptionType messageType, Packet p)
 {
     base.SendMessage(messageType, p);
     PlayerSocket.Send(p);
 }
Esempio n. 16
0
 public override void OpenBank()
 {
     PlayerSocket.Send(new PlayerBankPacket(this));
 }
Esempio n. 17
0
 public void UploadScript(PlayerSocket playerSocket, NPCSpawnInfo spawnInfo)
 {
 }