diff --git a/Core.lua b/Core.lua index c9e6850..acc553b 100644 --- a/Core.lua +++ b/Core.lua @@ -13,3 +13,4 @@ WQA.missionList = {} WQA.itemList = {} WQA.links = {} WQA.Criterias = {} +WQA.Rewards = {} diff --git a/Criterias/AreaPoi.lua b/Criterias/AreaPoi.lua index 0b622b9..00aa919 100644 --- a/Criterias/AreaPoi.lua +++ b/Criterias/AreaPoi.lua @@ -1,12 +1,16 @@ +---@class WQAchievements local WQA = WQAchievements -WQA.Criterias.AreaPoi = {} - -local criteria = WQA.Criterias.AreaPoi +---@alias AreaPoiCriteria +---| { AreaPoiId: integer, MapId: integer} +local criteria = {} criteria.list = {} criteria.watched = {} +---@param poi AreaPoiCriteria +---@param rewardType RewardType +---@param emissary boolean? function criteria:AddReward(poi, rewardType, reward, emissary) local poiId = poi.AreaPoiId local mapId = poi.MapId @@ -86,3 +90,5 @@ function criteria:Check() retry = retry } end + +WQA.Criterias.AreaPoi = criteria diff --git a/Criterias/CriteriaType.lua b/Criterias/CriteriaType.lua new file mode 100644 index 0000000..3cf1f88 --- /dev/null +++ b/Criterias/CriteriaType.lua @@ -0,0 +1,11 @@ +---@class WQAchievements +local WQA = WQAchievements + +---@enum CriteriaType +local CriteriaType = { + AreaPoi = "AREA_POI" +} + +WQA.Criterias = { + CriteriaType = CriteriaType +} diff --git a/DB/Data/WarWithin.lua b/DB/Data/WarWithin.lua index b4894d5..c66b778 100644 --- a/DB/Data/WarWithin.lua +++ b/DB/Data/WarWithin.lua @@ -120,3 +120,14 @@ data.achievements = { } } } + +-- Miscellaneous +data.miscellaneous = { + { + name = "Special Assignment", + criteriaType = "AREA_POI", + criteria = { + { AreaPoiId = 7828, MapId = 2215 } -- Special Assignment: Rise of the Colossals + } + }, +} diff --git a/Items/Miscellaneous.lua b/Items/Miscellaneous.lua new file mode 100644 index 0000000..69c6715 --- /dev/null +++ b/Items/Miscellaneous.lua @@ -0,0 +1,18 @@ +---@class WQAchievements +local WQA = WQAchievements +local CriteriaType = WQA.Criterias.CriteriaType +local RewardType = WQA.Rewards.RewardType + +---@param items { name: string, criteriaType: CriteriaType, criteria: AreaPoiCriteria[] }[] +function WQA:AddMiscellaneous(items) + for _, item in pairs(items) do + if item.criteriaType == CriteriaType.AreaPoi then + for _, criteria in pairs(item.criteria) do + WQA.Criterias.AreaPoi:AddReward( + criteria --[[@as AreaPoiCriteria]], + RewardType.Miscellaneous, + item.name) + end + end + end +end diff --git a/Rewards/Reward.lua b/Rewards/Reward.lua new file mode 100644 index 0000000..a242eab --- /dev/null +++ b/Rewards/Reward.lua @@ -0,0 +1,94 @@ +---@class WQAchievements +local WQA = WQAchievements +local RewardType = WQA.Rewards.RewardType + + +---@param rewardType RewardType +function WQA:AddReward(list, rewardType, reward, emissary) + local l = list + if emissary == true then + l.isEmissary = true + end + if not l.reward then + l.reward = {} + end + + + ---@type table + l = l.reward + if rewardType == RewardType.Achievement then + if not l.achievement then + l.achievement = {} + end + + for _, achievement in ipairs(l.achievement) do + if achievement.id == reward then + return + end + end + + l.achievement[#l.achievement + 1] = { id = reward } + elseif rewardType == RewardType.Chance then + if not l.chance then + l.chance = {} + end + + for _, v in pairs(l.chance) do + if v.id == reward then + return + end + end + + l.chance[#l.chance + 1] = { id = reward } + elseif rewardType == RewardType.Custom then + if not l.custom then + l.custom = true + end + elseif rewardType == RewardType.Item then + if not l.item then + l.item = {} + end + for k, v in pairs(reward) do + l.item[k] = v + end + elseif rewardType == RewardType.Reputation then + if not l.reputation then + l.reputation = {} + end + for k, v in pairs(reward) do + l.reputation[k] = v + end + elseif rewardType == RewardType.Recipe then + l.recipe = reward + elseif rewardType == RewardType.CustomItem then + l.customItem = reward + elseif rewardType == RewardType.Currency then + if not l.currency then + l.currency = {} + end + for k, v in pairs(reward) do + l.currency[k] = v + end + elseif rewardType == RewardType.ProfessionSkillup then + l.professionSkillup = reward + elseif rewardType == RewardType.Gold then + l.gold = reward + elseif rewardType == RewardType.AzeriteTrait then + if not l.azeriteTraits then + l.azeriteTraits = {} + end + for k, v in pairs(l.azeriteTraits) do + if v.spellID == reward then + return + end + end + l.azeriteTraits[#l.azeriteTraits + 1] = { spellID = reward } + elseif rewardType == RewardType.Miscellaneous then + if not l[RewardType.Miscellaneous] then + ---@type { [string]: boolean } + l[RewardType.Miscellaneous] = {} + end + + table.insert(l[RewardType.Miscellaneous], reward) + end +end diff --git a/Rewards/RewardType.lua b/Rewards/RewardType.lua new file mode 100644 index 0000000..394812e --- /dev/null +++ b/Rewards/RewardType.lua @@ -0,0 +1,22 @@ +---@class WQAchievements +local WQA = WQAchievements + +---@enum RewardType +local RewardType = { + Achievement = "ACHIEVEMENT", + AzeriteTrait = "AZERITE_TRAIT", + Chance = "CHANCE", + Currency = "CURRENCY", + Custom = "CUSTOM", + CustomItem = "CUSTOM_ITEM", + Gold = "GOLD", + Item = "ITEM", + Miscellaneous = "MISCELLANEOUS", + ProfessionSkillup = "PROFESSION_SKILLUP", + Recipe = "RECIPE", + Reputation = "REPUTATION" +} + +WQA.Rewards = { + RewardType = RewardType +} diff --git a/WQAchievements.lua b/WQAchievements.lua index b2a092d..d4629f2 100644 --- a/WQAchievements.lua +++ b/WQAchievements.lua @@ -277,6 +277,10 @@ function WQA:CreateQuestList() if (data.toys) then self:AddToys(data.toys) end + + if (data.miscellaneous) then + self:AddMiscellaneous(data.miscellaneous) + end end @@ -436,85 +440,6 @@ function WQA:AddRewardToQuest(questID, rewardType, reward, emissary) self:AddReward(l, rewardType, reward, emissary) end -function WQA:AddReward(list, rewardType, reward, emissary) - local l = list - if emissary == true then - l.isEmissary = true - end - if not l.reward then - l.reward = {} - end - l = l.reward - if rewardType == "ACHIEVEMENT" then - if not l.achievement then - l.achievement = {} - end - - for _, achievement in ipairs(l.achievement) do - if achievement.id == reward then - return - end - end - - l.achievement[#l.achievement + 1] = { id = reward } - elseif rewardType == "CHANCE" then - if not l.chance then - l.chance = {} - end - - for _, v in pairs(l.chance) do - if v.id == reward then - return - end - end - - l.chance[#l.chance + 1] = { id = reward } - elseif rewardType == "CUSTOM" then - if not l.custom then - l.custom = true - end - elseif rewardType == "ITEM" then - if not l.item then - l.item = {} - end - for k, v in pairs(reward) do - l.item[k] = v - end - elseif rewardType == "REPUTATION" then - if not l.reputation then - l.reputation = {} - end - for k, v in pairs(reward) do - l.reputation[k] = v - end - elseif rewardType == "RECIPE" then - l.recipe = reward - elseif rewardType == "CUSTOM_ITEM" then - l.customItem = reward - elseif rewardType == "CURRENCY" then - if not l.currency then - l.currency = {} - end - for k, v in pairs(reward) do - l.currency[k] = v - end - elseif rewardType == "PROFESSION_SKILLUP" then - l.professionSkillup = reward - elseif rewardType == "GOLD" then - l.gold = reward - elseif rewardType == "AZERITE_TRAIT" then - if not l.azeriteTraits then - l.azeriteTraits = {} - end - for k, v in pairs(l.azeriteTraits) do - if v.spellID == reward then - return - end - end - l.azeriteTraits[#l.azeriteTraits + 1] = { spellID = reward } - end -end - function WQA:AddEmissaryReward(questID, rewardType, reward) self:AddRewardToQuest(questID, rewardType, reward, true) end @@ -1683,6 +1608,8 @@ function WQA:GetRewardLinkByID(questId, key, value, i) return nil end link = GetSpellLink(v[i].spellID) + elseif k == WQA.Rewards.RewardType.Miscellaneous then + link = table.concat(v, ", ") end return link end diff --git a/WQAchievements.toc b/WQAchievements.toc index 3798ec3..06d34dc 100644 --- a/WQAchievements.toc +++ b/WQAchievements.toc @@ -22,8 +22,14 @@ DB\Data\WarWithin.lua DB\Expansions.lua DB\Zones.lua +Criterias\CriteriaType.lua Criterias\AreaPoi.lua +Rewards\RewardType.lua +Rewards\Reward.lua + +Items\Miscellaneous.lua + Achievements.lua Locales.lua