Esempio n. 1
0
        private bool MeetsPrerequisites(QuestInfo info)
        {
            if (info.Entry.QuestPlayerFactionEnum == 0u && player.Faction1 != Faction.Exile)
            {
                return(false);
            }
            if (info.Entry.QuestPlayerFactionEnum == 1u && player.Faction1 != Faction.Dominion)
            {
                return(false);
            }
            if (info.Entry.PrerequisiteRace != 0u && player.Race != (Race)info.Entry.PrerequisiteRace)
            {
                return(false);
            }
            if (info.Entry.PrerequisiteClass != 0u && player.Class != (Class)info.Entry.PrerequisiteClass)
            {
                return(false);
            }
            if (player.Level < info.Entry.PrerequisiteLevel)
            {
                return(false);
            }

            // ReSharper disable once PossibleInvalidCastExceptionInForeachLoop
            foreach (ushort questId in info.Entry.PrerequisiteQuests.Where(q => q != 0u))
            {
                if (GetQuestState(questId) != QuestState.Completed)
                {
                    return(false);
                }
            }

            if (info.Entry.PrerequisiteId != 0u && !PrerequisiteManager.Instance.Meets(player, info.Entry.PrerequisiteId))
            {
                return(false);
            }

            if (!info.IsContract())
            {
                GameFormulaEntry entry = GameTableManager.Instance.GameFormula.GetEntry(655);
                // client also hard codes 40 if entry doesn't exist
                if (completedQuests.Count > (entry?.Dataint0 ?? 40u))
                {
                    return(false);
                }
            }
            else
            {
                // TODO: contracts use reward property for max slots, RewardProperty.ActiveContractSlots
            }

            return(true);
        }