public Player(RealmManager manager, Client psr)
            : base(manager, (ushort)psr.Character.ObjectType, psr.Random)
        {
            try
            {
                control       = false;
                Client        = psr;
                Manager       = psr.Manager;
                StatsManager  = new StatsManager(this, psr.Random.CurrentSeed);
                Name          = psr.Account.Name;
                AccountId     = psr.Account.AccountId;
                FameCounter   = new FameCounter(this, Client.Account);
                Tokens        = psr.Account.FortuneTokens;
                HpPotionPrice = 5;
                MpPotionPrice = 5;

                Level                  = psr.Character.Level == 0 ? 1 : psr.Character.Level;
                Experience             = psr.Character.Exp;
                ExperienceGoal         = GetExpGoal(Level);
                Stars                  = GetStars();
                Texture1               = psr.Character.Tex1;
                Texture2               = psr.Character.Tex2;
                Credits                = psr.Account.Credits;
                NameChosen             = psr.Account.NameChosen;
                CurrentFame            = psr.Account.Stats.Fame;
                Fame                   = psr.Character.CurrentFame;
                XpBoosted              = psr.Character.XpBoosted;
                XpBoostTimeLeft        = psr.Character.XpTimer;
                xpFreeTimer            = XpBoostTimeLeft != -1.0;
                LootDropBoostTimeLeft  = psr.Character.LDTimer;
                lootDropBoostFreeTimer = LootDropBoost;
                LootTierBoostTimeLeft  = psr.Character.LTTimer;
                lootTierBoostFreeTimer = LootTierBoost;
                var state =
                    psr.Account.Stats.ClassStates.SingleOrDefault(_ => Utils.FromString(_.ObjectType) == ObjectType);
                FameGoal         = GetFameGoal(state?.BestFame ?? 0);
                Glowing          = IsUserInLegends();
                Guild            = GuildManager.Add(this, psr.Account.Guild);
                HP               = psr.Character.HitPoints <= 0 ? psr.Character.MaxHitPoints : psr.Character.HitPoints;
                Mp               = psr.Character.MagicPoints;
                ConditionEffects = 0;
                OxygenBar        = 100;
                HasBackpack      = psr.Character.HasBackpack == 1;
                PlayerSkin       = Client.Account.OwnedSkins.Contains(Client.Character.Skin) ? Client.Character.Skin : 0;
                HealthPotions    = psr.Character.HealthStackCount < 0 ? 0 : psr.Character.HealthStackCount;
                MagicPotions     = psr.Character.MagicStackCount < 0 ? 0 : psr.Character.MagicStackCount;

                Locked  = psr.Account.Locked ?? new List <string>();
                Ignored = psr.Account.Ignored ?? new List <string>();

                playerQuestManager = new QuestManager(this);
                try
                {
                    Manager.Database.DoActionAsync(db =>
                    {
                        Locked     = db.GetLockeds(AccountId);
                        Ignored    = db.GetIgnoreds(AccountId);
                        Muted      = db.IsMuted(AccountId);
                        DailyQuest = psr.Account.DailyQuest;

                        var playerQuests = db.CharacterQuestGet(Client.Character.CharacterId);
                        foreach (var j in playerQuests)
                        {
                            playerQuestManager.AddPlayerQuest(j.Item1, j.Item2, j.Item3, j.Item4);
                        }
                    });
                }
                catch (Exception ex)
                {
                    log.Error(ex);
                }

                if (HasBackpack)
                {
                    var inv =
                        psr.Character.Equipment.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    var backpack =
                        psr.Character.Backpack.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();

                    Inventory = inv.Concat(backpack).ToArray();
                    var xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        var slotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                        Array.Resize(ref slotTypes, 20);
                        SlotTypes = slotTypes;
                    }
                }
                else
                {
                    Inventory =
                        psr.Character.Equipment.Select(
                            _ =>
                            _ == -1
                                    ? null
                                    : (Manager.GameData.Items.ContainsKey((ushort)_) ? Manager.GameData.Items[(ushort)_] : null))
                        .ToArray();
                    var xElement = Manager.GameData.ObjectTypeToElement[ObjectType].Element("SlotTypes");
                    if (xElement != null)
                    {
                        SlotTypes =
                            Utils.FromCommaSepString32(
                                xElement.Value);
                    }
                }
                Stats = new[]
                {
                    psr.Character.MaxHitPoints,
                    psr.Character.MaxMagicPoints,
                    psr.Character.Attack,
                    psr.Character.Defense,
                    psr.Character.Speed,
                    psr.Character.HpRegen,
                    psr.Character.MpRegen,
                    psr.Character.Dexterity
                };

                Pet = null;

                for (var i = 0; i < SlotTypes.Length; i++)
                {
                    if (SlotTypes[i] == 0)
                    {
                        SlotTypes[i] = 10;
                    }
                }

                if (Client.Account.Rank >= 3)
                {
                    return;
                }
                for (var i = 0; i < 4; i++)
                {
                    if (Inventory[i]?.SlotType != SlotTypes[i])
                    {
                        Inventory[i] = null;
                    }
                }
            }
            catch (Exception e)
            {
                log.Error(e);
            }
        }