572
edits
No edit summary |
No edit summary |
||
Line 720: | Line 720: | ||
-- Setup the table | -- Setup the table | ||
local ret = {} | local ret = {} | ||
table.insert(ret, '\r\n{| class="wikitable sortable" style="text-align:center"') | table.insert(ret, '\r\n{| class="wikitable sortable lighttable" style="text-align:center"') | ||
table.insert(ret, '\r\n!Map') | table.insert(ret, '\r\n!Map') | ||
Line 762: | Line 762: | ||
function p.GetTaskTable(frame) | function p.GetTaskTable(frame) | ||
local category = frame.args ~= nil and frame.args[1] or frame | local category = frame.args ~= nil and frame.args[1] or frame | ||
local categoryname = GameData.getEntityByID(Township.taskCategories, category).name | |||
local taskcount = 0 | |||
local ret = {} | local ret = {} | ||
Line 772: | Line 774: | ||
-- Filter out other categories | -- Filter out other categories | ||
if task.category == category then | if task.category == category then | ||
-- If has description, we will need to rowspan the title by 2, and insert a description with colspan 2 | |||
local hasDescription = false | |||
if task.description ~= nil then | |||
hasDescription = true | |||
end | |||
local titlespan = hasDescription == true and 'rowspan="2"|' or '' | |||
-- Title | |||
table.insert(ret, '\r\n|-') | table.insert(ret, '\r\n|-') | ||
table.insert(ret, '\r\n!'..task. | taskcount = taskcount + 1 | ||
table.insert(ret, '\r\n!'..titlespan..categoryname..' '..taskcount) | |||
-- Description | |||
if hasDescription then | |||
table.insert(ret, '\r\n|colspan="2"|'..task.description) | |||
table.insert(ret, '\r\n|-') | |||
end | |||
-- Requirements | -- Requirements | ||
table.insert(ret, '\r\n|') | table.insert(ret, '\r\n|') | ||
local requirements = {} | |||
for _, item in ipairs(task.goals.items) do | for _, item in ipairs(task.goals.items) do | ||
local itemname = Items.getItemByID(item.id).name | local itemname = Items.getItemByID(item.id).name | ||
table.insert( | table.insert(requirements, Shared.formatnum(item.quantity)..' '..Icons.Icon({itemname, type='item'})) | ||
end | end | ||
for _, monster in ipairs(task.goals.monsters) do | for _, monster in ipairs(task.goals.monsters) do | ||
local monstername = Monsters.getMonsterByID(monster.id).name | local monstername = Monsters.getMonsterByID(monster.id).name | ||
table.insert( | table.insert(requirements, Shared.formatnum(monster.quantity)..' '..Icons.Icon({monstername, type='monster'})) | ||
end | end | ||
for _, skill in ipairs(task.goals.skillXP) do | for _, skill in ipairs(task.goals.skillXP) do | ||
local skillname = GameData.getSkillData(skill.id).name | local skillname = GameData.getSkillData(skill.id).name | ||
table.insert( | table.insert(requirements, Shared.formatnum(skill.quantity)..' '..Icons.Icon({skillname, type='skill'})..' XP') | ||
end | end | ||
for _, building in ipairs(task.goals.buildings) do | for _, building in ipairs(task.goals.buildings) do | ||
local buildingname = p._GetBuildingByID(building.id).name | local buildingname = p._GetBuildingByID(building.id).name | ||
table.insert( | table.insert(requirements, Shared.formatnum(building.quantity)..' '..Icons.Icon({buildingname, type='building'})) | ||
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) | ||
table.insert(ret, '< | table.insert(ret, table.concat(requirements, '<br>')) | ||
-- Rewards | -- Rewards | ||
table.insert(ret, '\r\n| | table.insert(ret, '\r\n|') | ||
local rewards = {} | |||
if task.rewards.gp ~= 0 then | if task.rewards.gp ~= 0 then | ||
table.insert( | table.insert(rewards, Icons.GP(task.rewards.gp)) | ||
end | end | ||
if task.rewards.slayerCoins ~= 0 then | if task.rewards.slayerCoins ~= 0 then | ||
table.insert( | table.insert(rewards, Icons.SC(task.rewards.slayerCoins)) | ||
end | end | ||
for _, item in ipairs(task.rewards.items) do | for _, item in ipairs(task.rewards.items) do | ||
local itemname = Items.getItemByID(item.id).name | local itemname = Items.getItemByID(item.id).name | ||
table.insert( | table.insert(rewards, Shared.formatnum(item.quantity)..' '..Icons.Icon({itemname, type='item'})) | ||
end | end | ||
for _, skill in ipairs(task.rewards.skillXP) do | for _, skill in ipairs(task.rewards.skillXP) do | ||
local skillname = GameData.getSkillData(skill.id).name | local skillname = GameData.getSkillData(skill.id).name | ||
table.insert( | table.insert(rewards, Shared.formatnum(skill.quantity)..' '..Icons.Icon({skillname, type='skill'})..' XP') | ||
end | end | ||
for _, townshipResource in ipairs(task.rewards.townshipResources) do | for _, townshipResource in ipairs(task.rewards.townshipResources) do | ||
local resourcename = p._GetResourceByID(townshipResource.id).name | local resourcename = p._GetResourceByID(townshipResource.id).name | ||
table.insert( | table.insert(rewards, Shared.formatnum(townshipResource.quantity)..' '..Icons.Icon({resourcename, type='resource'})) | ||
end | end | ||
table.insert(ret, '< | table.insert(ret, table.concat(rewards, '<br>')) | ||
end | end | ||
end | end |
edits