Exemplo n.º 1
0
        public static async Task LoginAsync(GameSession session)
        {
            var plr = session.Player;

            plr.LoggedIn = true;

            try
            {
                plr?.SendAsync(new MoneyRefreshCashInfoAckMessage(plr.PEN, plr.AP));
                plr?.SendAsync(new CharacterCurrentSlotInfoAckMessage
                {
                    ActiveCharacter = plr.CharacterManager.CurrentSlot,
                    CharacterCount  = (byte)plr.CharacterManager.Count,
                    MaxSlots        = 3
                });

                plr?.SendAsync(new MoenyRefreshCoinInfoAckMessage(plr.Coins1, plr.Coins2));
                plr?.SendAsync(new ShoppingBasketListInfoAckMessage());

                foreach (var data in ArraySplitter.Split(
                             plr.Inventory.Select(i => i.Map <PlayerItem, ItemDto>()).ToArray(),
                             300))
                {
                    plr?.SendAsync(new ItemInventoryInfoAckMessage(data));
                }

                plr?.SendAsync(new PlayeArcadeMapInfoAckMessage());
                plr?.SendAsync(new PlayerArcadeStageInfoAckMessage());
                plr?.SendAsync(new ClubMyInfoAckMessage(plr.Map <Player, ClubMyInfoDto>()));

                foreach (var @char in plr.CharacterManager)
                {
                    plr?.SendAsync(new CharacterCurrentInfoAckMessage
                    {
                        Slot  = @char.Slot,
                        Style = new CharacterStyle(@char.Gender, @char.Slot)
                    });

                    plr?.SendAsync(new CharacterCurrentItemInfoAckMessage
                    {
                        Slot    = @char.Slot,
                        Weapons = @char.Weapons.GetItems().Select(i => i?.Id ?? 0).ToArray(),
                        Skills  = new[] { @char.Skills.GetItem(SkillSlot.Skill)?.Id ?? 0 },
                        Clothes = @char.Costumes.GetItems().Select(i => i?.Id ?? 0).ToArray()
                    });
                }
            }
            finally
            {
                plr?.SendAsync(new ItemEquipBoostItemInfoAckMessage());
                plr?.SendAsync(new EspherChipLv5Message());
                plr?.SendAsync(new ItemClearInvalidEquipItemAckMessage());
                plr?.SendAsync(new ItemClearEsperChipAckMessage());
                plr?.SendAsync(new MapOpenInfosMessage());
                await plr.SendAsync(new PlayerAccountInfoAckMessage(plr.Map <Player, PlayerAccountInfoDto>()));

                await plr.SendAsync(new ServerResultAckMessage(ServerResult.WelcomeToS4World));
            }
        }
Exemplo n.º 2
0
        public static async Task LoginAsync(GameSession session)
        {
            var plr = session.Player;

            plr.LoggedIn = true;

            try
            {
                using (var db = AuthDatabase.Open())
                {
                    var account = db.Find <AccountDto>(statement => statement
                                                       .Where($"{nameof(AccountDto.Id):C} = @{nameof(session.Player.Account.Id)}")
                                                       .WithParameters(new { session.Player.Account.Id })).FirstOrDefault();

                    if (account != null && account.IsServer)
                    {
                        account.IsServer = false;
                        DbUtil.Update(db, account);
                    }
                }

                plr?.SendAsync(new MoneyRefreshCashInfoAckMessage(plr.PEN, plr.AP));
                plr?.SendAsync(new CharacterCurrentSlotInfoAckMessage
                {
                    ActiveCharacter = plr.CharacterManager.CurrentSlot,
                    CharacterCount  = (byte)plr.CharacterManager.Count,
                    MaxSlots        = 3
                });

                plr?.SendAsync(new MoenyRefreshCoinInfoAckMessage(plr.Coins1, plr.Coins2));
                plr?.SendAsync(new ShoppingBasketListInfoAckMessage());

                foreach (var data in ArraySplitter.Split(
                             plr.Inventory.Select(i => i.Map <PlayerItem, ItemDto>()).ToArray(),
                             300))
                {
                    plr?.SendAsync(new ItemInventoryInfoAckMessage(data));
                }

                plr?.SendAsync(new PlayeArcadeMapInfoAckMessage());
                plr?.SendAsync(new PlayerArcadeStageInfoAckMessage());
                plr?.SendAsync(new ClubMyInfoAckMessage(plr.Map <Player, ClubMyInfoDto>()));

                foreach (var @char in plr.CharacterManager)
                {
                    plr?.SendAsync(new CharacterCurrentInfoAckMessage
                    {
                        Slot  = @char.Slot,
                        Style = new CharacterStyle(@char.Gender, @char.Slot)
                    });

                    plr?.SendAsync(new CharacterCurrentItemInfoAckMessage
                    {
                        Slot    = @char.Slot,
                        Weapons = @char.Weapons.GetItems().Select(i => i?.Id ?? 0).ToArray(),
                        Skills  = new[] { @char.Skills.GetItem(SkillSlot.Skill)?.Id ?? 0 },
                        Clothes = @char.Costumes.GetItems().Select(i => i?.Id ?? 0).ToArray()
                    });
                }
            }
            finally
            {
                plr?.SendAsync(new ItemEquipBoostItemInfoAckMessage());
                plr?.SendAsync(new EspherChipLv5Message());
                plr?.SendAsync(new ItemClearInvalidEquipItemAckMessage());
                plr?.SendAsync(new ItemClearEsperChipAckMessage());
                plr?.SendAsync(new MapOpenInfosMessage());
                await plr.SendAsync(new PlayerAccountInfoAckMessage(plr.Map <Player, PlayerAccountInfoDto>()));

                await plr.SendAsync(new ServerResultAckMessage(ServerResult.WelcomeToS4World));
            }
        }