16,254
edits
(Fix monster lookup) |
(_getTaskRow: Support new AoD requirements, add exception reporting for unrecognized requirements) |
||
Line 764: | Line 764: | ||
-- Requirements | -- Requirements | ||
table.insert(ret, '\n|') | table.insert(ret, '\n|') | ||
local | -- Determines order of requirements output | ||
local reqOrder = { | |||
local | ["items"] = 10, | ||
["monsters"] = 20, | |||
["monsterWithItems"] = 30, | |||
["skillXP"] = 40, | |||
["buildings"] = 50, | |||
["numPOIs"] = 60, | |||
["numRefinements"] = 70 | |||
} | |||
local reqTextPart = {} | |||
local function getItemText(itemID) | |||
local item = Items.getItemByID(itemID) | |||
if item == nil then | |||
return Shared.printError('Unknown item: ' .. (itemID or 'nil')) | |||
else | |||
return Icons.Icon({item.name, type='item'}) | |||
end | |||
end | end | ||
local function getMonsterText(monsterID) | |||
local | local monster = Monsters.getMonsterByID(monsterID) | ||
if monster == nil then | |||
return Shared.printError('Unknown monster: ' .. (monsterID or 'nil')) | |||
else | |||
return Icons.Icon({Monsters.getMonsterName(monster), type='monster'}) | |||
end | |||
end | end | ||
for goalType, goalData in pairs(task.goals) do | |||
local typeOrder = reqOrder[goalType] or 0 | |||
local goalText = nil | |||
if type(goalData) == 'table' then | |||
local | -- Goal data is a table | ||
table.insert( | for goalIdx, goalObj in ipairs(goalData) do | ||
if goalType == 'items' then | |||
goalText = Shared.formatnum(goalObj.quantity) .. ' ' .. getItemText(goalObj.id) | |||
elseif goalType == 'monsters' then | |||
goalText = Shared.formatnum(goalObj.quantity) .. ' ' .. getMonsterText(goalObj.id) | |||
elseif goalType == 'monsterWithItems' then | |||
local itemsText = {} | |||
for i, itemID in ipairs(goalObj.itemIDs) do | |||
table.insert(itemsText, getItemText(itemID)) | |||
end | |||
goalText = Shared.formatnum(goalObj.quantity) .. ' ' .. getMonsterText(goalObj.monsterID) .. ' with ' .. table.concat(itemsText, ', ') .. ' equipped' | |||
elseif goalType == 'skillXP' then | |||
local skillName = GameData.getSkillData(goalObj.id).name | |||
goalText = Shared.formatnum(goalObj.quantity) .. ' ' .. Icons.Icon({skillName, type='skill'}) .. ' XP' | |||
elseif goalType == 'buildings' then | |||
local buildingName = p._GetBuildingByID(goalObj.id).name | |||
goalText = Shared.formatnum(goalObj.quantity) .. ' ' .. Icons.Icon({buildingName, type='building'}) | |||
elseif goalType == 'numPOIs' then | |||
local mapName = GameData.getEntityByID(GameData.skillData.Cartography.worldMaps, goalObj.worldMapID).name | |||
goalText = 'Discover ' .. Shared.formatnum(goalObj.quantity) .. ' Points of Interest in ' .. Icons.Icon({'Cartography', type='skill'}) .. ' world map of ' .. mapName | |||
else | |||
goalText = Shared.printError('Unknown goal type: ' .. (goalType or 'nil')) | |||
end | |||
table.insert(reqTextPart, { | |||
["goalOrder"] = typeOrder, | |||
["subOrder"] = goalIdx, | |||
["text"] = goalText | |||
}) | |||
end | |||
else | |||
-- Goal data is another value of some type | |||
if goalType == 'numRefinements' then | |||
goalText = 'Refine dig site maps in ' .. Icons.Icon({'Cartography', type='skill'}) .. ' ' .. Shared.formatnum(goalData) .. ' times' | |||
else | |||
goalText = Shared.printError('Unknown goal type: ' .. (goalType or 'nil')) | |||
end | end | ||
table.insert( | table.insert(reqTextPart, { | ||
["goalOrder"] = typeOrder, | |||
["subOrder"] = 0, | |||
["text"] = goalText | |||
}) | |||
end | end | ||
end | end | ||
table.sort(reqTextPart, | |||
function(a, b) | |||
if a.goalOrder == b.goalOrder then | |||
for | return a.subOrder < b.subOrder | ||
else | |||
table.insert(requirements, | return a.goalOrder < b.goalOrder | ||
end | |||
end | |||
) | |||
local requirements = {} | |||
for i, req in ipairs(reqTextPart) do | |||
table.insert(requirements, req.text) | |||
end | end | ||
-- We don't check tasks.requirements (so far it's only used to enumerate the Tutorial tasks so you only see 1 at a time) | -- We don't check tasks.requirements (so far it's only used to enumerate the Tutorial tasks so you only see 1 at a time) | ||
Line 853: | Line 917: | ||
local taskcount = 0 | local taskcount = 0 | ||
local ret = {} | local ret = {} | ||
table.insert(ret, '{| class="wikitable lighttable" style="text-align:left"') | table.insert(ret, '{| class="wikitable lighttable stickyHeader" style="text-align:left"') | ||
table.insert(ret, '\n|- class="headerRow-0"') | |||
table.insert(ret, '\n!Task') | table.insert(ret, '\n!Task') | ||
table.insert(ret, '\n!Requirements') | table.insert(ret, '\n!Requirements') |