예제 #1
0
    public override void Handle(GameSession session, PacketReader packet)
    {
        List <TutorialItemMetadata> metadata = JobMetadataStorage.GetTutorialItems((int)session.Player.Job);

        foreach (TutorialItemMetadata tutorialItem in metadata)
        {
            int tutorialItemsCount = session.Player.Inventory.Items.Count(x => x.Value.Id == tutorialItem.ItemId);
            tutorialItemsCount += session.Player.Inventory.Cosmetics.Count(x => x.Value.Id == tutorialItem.ItemId);
            tutorialItemsCount += session.Player.Inventory.Equips.Count(x => x.Value.Id == tutorialItem.ItemId);

            if (tutorialItemsCount >= tutorialItem.Amount)
            {
                continue;
            }

            int amountRemaining = tutorialItem.Amount - tutorialItemsCount;

            Item item = new(tutorialItem.ItemId)
            {
                Rarity = tutorialItem.Rarity,
                Amount = amountRemaining
            };
            session.Player.Inventory.AddItem(session, item, true);
        }
    }
}
예제 #2
0
    public Hotbar(long gameOptionsId, Job job)
    {
        Slots = new QuickSlot[MaxSlots];

        for (int i = 0; i < MaxSlots; i++)
        {
            Slots[i] = new();
        }

        AddDefaultSkills();

        Id = DatabaseManager.Hotbars.Insert(this, gameOptionsId);

        void AddDefaultSkills()
        {
            JobMetadata jobMetadata = JobMetadataStorage.GetJobMetadata(job);

            if (jobMetadata is null)
            {
                return;
            }

            List <int> skillIds = new();

            jobMetadata.LearnedSkills.ForEach(x => skillIds.AddRange(x.SkillIds));

            List <(int skillId, byte slotPriority)> hotbarSkills = new();

            foreach (int skillId in skillIds)
            {
                JobSkillMetadata jobSkillMetadata = jobMetadata.Skills.First(x => x.SkillId == skillId);
                if (jobSkillMetadata.QuickSlotPriority != 99 && jobSkillMetadata.SubJobCode == 0)
                {
                    hotbarSkills.Add((skillId, jobSkillMetadata.QuickSlotPriority));
                }
            }

            foreach ((int skillId, byte _) in hotbarSkills.OrderBy(x => x.slotPriority))
            {
                AddToFirstSlot(QuickSlot.From(skillId));
            }
        }
    }
예제 #3
0
    public override void Handle(GameSession session, PacketReader packet)
    {
        JobMetadata metadata = JobMetadataStorage.GetJobMetadata(session.Player.Job);
        {
            foreach (int taxiMapId in metadata.OpenTaxis)
            {
                if (session.Player.UnlockedTaxis.Contains(taxiMapId))
                {
                    continue;
                }
                session.Player.UnlockedTaxis.Add(taxiMapId);
            }

            foreach (int openMapId in metadata.OpenMaps)
            {
                if (session.Player.UnlockedMaps.Contains(openMapId))
                {
                    continue;
                }
                session.Player.UnlockedMaps.Add(openMapId);
            }
        }
    }
예제 #4
0
    public Hotbar(long gameOptionsId, Job job)
    {
        Slots = new QuickSlot[MAX_SLOTS];

        for (int i = 0; i < MAX_SLOTS; i++)
        {
            Slots[i] = new();
        }

        // Get default job skills
        IOrderedEnumerable <JobSkillMetadata> skills = JobMetadataStorage
                                                       .GetJobskills((int)job).Where(skill => skill.QuickSlotPriority < 4).OrderBy(skill => skill.QuickSlotPriority);

        // Add skills to hotbar
        int index = 4;

        foreach (JobSkillMetadata metadata in skills)
        {
            Slots[index++] = QuickSlot.From(metadata.SkillId);
        }

        Id = DatabaseManager.Hotbars.Insert(this, gameOptionsId);
    }
예제 #5
0
    public void LearnDefaultSkills(Job job, JobCode jobCode)
    {
        JobMetadata jobMetadata = JobMetadataStorage.GetJobMetadata(job);

        if (jobMetadata is null)
        {
            return;
        }

        List <int> skillIds = new();

        jobMetadata.LearnedSkills.ForEach(x => skillIds.AddRange(x.SkillIds));

        foreach (int skillId in skillIds)
        {
            JobSkillMetadata jobSkillMetadata = jobMetadata.Skills.First(x => x.SkillId == skillId);
            if (jobSkillMetadata.SubJobCode != (int)jobCode && jobSkillMetadata.SubJobCode != 0)
            {
                continue;
            }

            AddOrUpdate(skillId, 1, true);
        }
    }
예제 #6
0
 // Initializes all values to be saved into the database
 public Player(Account account, string name, byte gender, Job job, SkinColor skinColor)
 {
     AccountId   = account.Id;
     Account     = account;
     Name        = name;
     Gender      = gender;
     Job         = job;
     GameOptions = new GameOptions();
     Wallet      = new Wallet(meso: 0, valorToken: 0, treva: 0, rue: 0, haviFruit: 0);
     Levels      = new Levels(playerLevel: 1, exp: 0, restExp: 0, prestigeLevel: 1, prestigeExp: 0, new List <MasteryExp>()
     {
         new MasteryExp(MasteryType.Fishing),
         new MasteryExp(MasteryType.Performance),
         new MasteryExp(MasteryType.Mining),
         new MasteryExp(MasteryType.Foraging),
         new MasteryExp(MasteryType.Ranching),
         new MasteryExp(MasteryType.Farming),
         new MasteryExp(MasteryType.Smithing),
         new MasteryExp(MasteryType.Handicraft),
         new MasteryExp(MasteryType.Alchemy),
         new MasteryExp(MasteryType.Cooking),
         new MasteryExp(MasteryType.PetTaming)
     });
     Timestamps             = new TimeInfo(DateTimeOffset.UtcNow.ToUnixTimeSeconds());
     MapId                  = JobMetadataStorage.GetStartMapId((int)job);
     Coord                  = MapEntityStorage.GetRandomPlayerSpawn(MapId).Coord.ToFloat();
     Stats                  = new PlayerStats(strBase: 10, dexBase: 10, intBase: 10, lukBase: 10, hpBase: 500, critRateBase: 10);
     Motto                  = "Motto";
     ProfileUrl             = "";
     CreationTime           = DateTimeOffset.Now.ToUnixTimeSeconds();
     TitleId                = 0;
     InsigniaId             = 0;
     Titles                 = new List <int>();
     PrestigeRewardsClaimed = new List <int>();
     ChatSticker            = new List <ChatSticker>();
     FavoriteStickers       = new List <int>();
     Emotes                 = new List <int>()
     {
         90200011, 90200004, 90200024, 90200041, 90200042, 90200057, 90200043, 90200022, 90200031, 90200005, 90200006, 90200003, 90200092, 90200077, 90200073, 90200023, 90200001, 90200019, 90200020, 90200021
     };
     StatPointDistribution = new StatDistribution(20);
     Inventory             = new Inventory();
     Mailbox        = new List <Mail>();
     BuddyList      = new List <Buddy>();
     QuestList      = new List <QuestStatus>();
     GatheringCount = new List <GatheringCount>();
     TrophyCount    = new int[3] {
         0, 0, 0
     };
     ReturnMapId      = (int)Map.Tria;
     ReturnCoord      = MapEntityStorage.GetRandomPlayerSpawn(ReturnMapId).Coord.ToFloat();
     GroupChatId      = new int[3];
     SkinColor        = skinColor;
     UnlockedTaxis    = new List <int>();
     UnlockedMaps     = new List <int>();
     ActiveSkillTabId = 1;
     CharacterId      = DatabaseManager.Characters.Insert(this);
     SkillTabs        = new List <SkillTab> {
         new SkillTab(CharacterId, job, 1, $"Build {(SkillTabs == null ? "1" : SkillTabs.Count + 1)}")
     };
 }