Пример #1
0
        protected override async Task Process(WorldSession session, CharNew packet)
        {
            if (session.Account is null)
            {
                return;
            }

            var slotTaken = await characterRepository.IsSlotTaken(session.Account.Id, packet.Slot);

            if (slotTaken)
            {
                await session.Disconnect();

                return;
            }

            var nameTaken = await characterRepository.IsNameTaken(packet.Name);

            if (nameTaken)
            {
                await session.Disconnect();

                return;
            }

            await characterRepository.Save(new CharacterDTO
            {
                Name           = packet.Name,
                Slot           = packet.Slot,
                AccountId      = session.Account.Id,
                Level          = 1,
                JobLevel       = 1,
                HeroLevel      = 0,
                Job            = Job.Adventurer,
                Gender         = packet.Gender,
                HairColor      = packet.HairColor,
                HairStyle      = packet.HairStyle,
                Dignity        = 0,
                Reputation     = 0,
                Experience     = 0,
                JobExperience  = 0,
                HeroExperience = 0,
                MapId          = 1,
                X         = 75,
                Y         = 115,
                Direction = Direction.South,
                Hp        = 300,
                Mp        = 150,
            });

            await session.SendPacket(new Success());

            var characters = await characterRepository.FindAll(session.Account.Id);

            await session.SendCList(characters);
        }
Пример #2
0
        protected override async Task Process(WorldSession session, CharNew packet)
        {
            if (session.Account is null)
            {
                return;
            }

            var slotTaken = await characterRepository.IsSlotTaken(session.Account.Id, packet.Slot);

            if (slotTaken)
            {
                await session.Disconnect();

                return;
            }

            var nameTaken = await characterRepository.IsNameTaken(packet.Name);

            if (nameTaken)
            {
                await session.Disconnect();

                return;
            }

            await characterRepository.Save(new CharacterDTO
            {
                Name      = packet.Name,
                Slot      = packet.Slot,
                AccountId = session.Account.Id,
                Level     = 1,
                JobLevel  = 1,
                Job       = Job.Adventurer,
                Gender    = packet.Gender,
                HairColor = packet.HairColor,
                HairStyle = packet.HairStyle,
                MapId     = 1,
                X         = 75,
                Y         = 115,
                Hp        = 300,
                Mp        = 150,
            });

            await session.SendPacket(new Success());

            var characters = await characterRepository.FindAll(session.Account.Id);

            await session.SendPacket(new CListStart());

            foreach (var character in characters)
            {
                await session.SendPacket(new CList
                {
                    Name            = character.Name,
                    Slot            = character.Slot,
                    HairColor       = character.HairColor,
                    HairStyle       = character.HairStyle,
                    Level           = character.Level,
                    Gender          = character.Gender,
                    HeroLevel       = 0,
                    JobLevel        = character.JobLevel,
                    Job             = character.Job,
                    Equipments      = Enumerable.Range(0, 10).Select(x => (short?)null),
                    Pets            = Enumerable.Range(0, 24).Select(x => (short?)null),
                    QuestCompletion = 1,
                    QuestPart       = 1,
                    Rename          = false
                });
            }
            await session.SendPacket(new CListEnd());
        }