Пример #1
0
 private static void GetPrefixCodes()
 {
     if (Root.IsLeaf())
     {
         CharacterTable.Add("1", Root.Fact);
     }
     else
     {
         PrefixCodes(Root, "");
     }
 }
Пример #2
0
            public virtual void ReadChildData(BinaryReader reader)
            {
                int x = 0;

                for (x = 0; (x < _characterTable.Count); x = (x + 1))
                {
                    CharacterTable.Add(new FontCharacterTableBlock());
                    CharacterTable[x].Read(reader);
                }
                for (x = 0; (x < _characterTable.Count); x = (x + 1))
                {
                    CharacterTable[x].ReadChildData(reader);
                }
            }
Пример #3
0
 private static void PrefixCodes(HuffmanNode Node, string traversal)
 {
     if (Node.IsLeaf())
     {
         CharacterTable.Add(traversal, Node.Fact); return;
     }
     else
     {
         if (Node.LeftNode != null)
         {
             PrefixCodes(Node.LeftNode, traversal + "0");
         }
         if (Node.RightNode != null)
         {
             PrefixCodes(Node.RightNode, traversal + "1");
         }
     }
 }
Пример #4
0
 private static void PrefixCodes(Nodo Node, string Route)
 {
     if (Node.IsLeaf())
     {
         CharacterTable.Add(Node.Fact, Route);
     }
     else
     {
         if (Node.LeftNode != null)
         {
             PrefixCodes(Node.LeftNode, Route + "0");
         }
         if (Node.RightNode != null)
         {
             PrefixCodes(Node.RightNode, Route + "1");
         }
     }
 }
Пример #5
0
        public void InitLocalMySQL()
        {
            if (this.Database.CreateIfNotExists())
            {
                EntityGenerator <Items> generatorItems = new EntityGenerator <Items>();
                for (int i = 0; i < 60; i++)
                {
                    ItemsTable.Add(generatorItems.GenerateItem());
                }

                EntityGenerator <Party> generatorParty = new EntityGenerator <Party>();
                for (int i = 0; i < 3; i++)
                {
                    PartyTable.Add(generatorParty.GenerateItem());
                }

                EntityGenerator <Character> generatorPersonnage = new EntityGenerator <Character>();
                for (int i = 0; i < 15; i++)
                {
                    CharacterTable.Add(generatorPersonnage.GenerateItem());
                }

                EntityGenerator <Boss> generatorBoss = new EntityGenerator <Boss>();
                for (int i = 0; i < 20; i++)
                {
                    BossTable.Add(generatorBoss.GenerateItem());
                }

                EntityGenerator <Donjon> generatorDonjon = new EntityGenerator <Donjon>();
                for (int i = 0; i < 5; i++)
                {
                    DonjonTable.Add(generatorDonjon.GenerateItem());
                }

                this.SaveChangesAsync();
            }
        }
        private static void ProcessCharacterCreationRequest(WorldClient Client, string Packet)
        {
            var characterInfos = Packet.Substring(2);

            // fake Packet
            if (!characterInfos.Contains('|'))
            {
                Client.Disconnect();
                return;
            }

            var infos = characterInfos.Split('|');

            // fake Packet
            if (infos.Length != 6)
            {
                Client.Disconnect();
                return;
            }

            String first = (infos[0][0].ToString()).ToUpper();
            var    Name  = first + infos[0].Substring(1).ToLower();

            var Class  = int.Parse(infos[1]);
            var Sex    = int.Parse(infos[2]);
            var Color1 = int.Parse(infos[3]);
            var Color2 = int.Parse(infos[4]);
            var Color3 = int.Parse(infos[5]);

            // trop de personnage
            if (Client.Account.Characters.Count > (Settings.AppSettings.GetIntElement("Account.MaxPlayer") - 1))
            {
                Client.Send(new CharacterSlotFullMessage());
                return;
            }

            // fake class
            if (!StringHelper.isValidName(Name) || Class < (int)ClassEnum.CLASS_FECA || Class > (int)ClassEnum.CLASS_PANDAWA)
            {
                Client.Send(new CharacterCreationFailMessage());
                return;
            }

            // fake sex
            if (Sex > 1 || Sex < 0)
            {
                Client.Send(new CharacterCreationFailMessage());
                return;
            }

            // fake color
            if (Color1 < -1 || Color2 < -1 || Color3 < -1)
            {
                Client.Send(new CharacterCreationFailMessage());
                return;
            }

            // pseudo deja pris ?
            if (CharacterTable.Contains(Name) || 4 > Name.Length)
            {
                Client.Send(new CharacterNameAlreadyExistMessage());
                return;
            }

            var character = new Database.Models.Player()
            {
                ID              = DatabaseCache.nextPlayerGuid++,
                Owner           = Client.Account.ID,
                Name            = Name,
                Level           = Settings.AppSettings.GetIntElement("World.StartLevel"),
                Color1          = Color1,
                Color2          = Color2,
                Color3          = Color3,
                Look            = Class * 10,
                Sexe            = Sex,
                Classe          = Class,
                EnabledChannels = "i*#$p%!?:@",
                Map             = Settings.AppSettings.GetShortElement("World.StartMap"),
                CellId          = Settings.AppSettings.GetIntElement("World.StartCell"),
                Restriction     = 0,
                Experience      = ExpFloorTable.GetFloorByLevel(Settings.AppSettings.GetIntElement("World.StartLevel")).Character,
                Kamas           = Settings.AppSettings.GetIntElement("World.KamasStart"),
                CaractPoint     = (Settings.AppSettings.GetIntElement("World.StartLevel") - 1) * 5,
                SpellPoint      = Settings.AppSettings.GetIntElement("World.StartLevel") - 1,
                LifePer         = 100,
                Energy          = 10000,
                AP              = (Settings.AppSettings.GetIntElement("World.StartLevel") >= 100 ? 7 : 6),
                MP              = 3,
                Vitality        = 0,
                Wisdom          = 0,
                Strength        = 0,
                Intell          = 0,
                Agility         = 0,
                Chance          = 0,
                Alignement      = 0,
                Honor           = 0,
                Deshonor        = 0,
                Stuff           = "",
                MountID         = -1,
                MountXPGive     = 0,
                Title           = 0,
                SavePos         = Settings.AppSettings.GetShortElement("World.StartMap") + "," + Settings.AppSettings.GetIntElement("World.StartCell"),
                Account         = Client.Account,
            };

            if (!CharacterTable.Add(character))
            {
                Client.Send(new CharacterCreationFailMessage());
                return;
            }

            Client.Account.Characters.Add(character.ID, character);

            using (CachedBuffer Buffer = new CachedBuffer(Client))
            {
                Buffer.Append(new CharacterCreationSuccessMessage());
                Buffer.Append(new CharactersListMessage(Client.Account.Characters));
            }
        }