Anonymous

Module:Sandbox/GauTest/Township: Difference between revisions

From Melvor Idle
no edit summary
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.name)
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|')
if task.description ~= nil then
local requirements = {}
table.insert(ret, task.description..'<br>')
end
table.insert(ret, '<ul>')
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(ret, '<li>'..Shared.formatnum(item.quantity)..' '..Icons.Icon({itemname, type='item'})..'</li>')
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(ret, '<li>'..Shared.formatnum(monster.quantity)..' '..Icons.Icon({monstername, type='monster'})..'</li>')
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(ret, '<li>'..Shared.formatnum(skill.quantity)..' '..Icons.Icon({skillname, type='skill'})..' XP</li>')
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(ret, '<li>'..Shared.formatnum(building.quantity)..' '..Icons.Icon({buildingname, type='building'})..'</li>')
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, '</ul>')
table.insert(ret, table.concat(requirements, '<br>'))
-- Rewards
-- Rewards
table.insert(ret, '\r\n|<ul>')
table.insert(ret, '\r\n|')
local rewards = {}
if task.rewards.gp ~= 0 then
if task.rewards.gp ~= 0 then
table.insert(ret, '<li>'..Icons.GP(task.rewards.gp)..'</li>')
table.insert(rewards, Icons.GP(task.rewards.gp))
end
end
if task.rewards.slayerCoins ~= 0 then
if task.rewards.slayerCoins ~= 0 then
table.insert(ret, '<li>'..Icons.SC(task.rewards.slayerCoins)..'</li>')
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(ret, '<li>'..Shared.formatnum(item.quantity)..' '..Icons.Icon({itemname, type='item'})..'</li>')
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(ret, '<li>'..Shared.formatnum(skill.quantity)..' '..Icons.Icon({skillname, type='skill'})..' XP</li>')
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(ret, '<li>'..Shared.formatnum(townshipResource.quantity)..' '..Icons.Icon({resourcename, type='resource'})..'</li>')
table.insert(rewards, Shared.formatnum(townshipResource.quantity)..' '..Icons.Icon({resourcename, type='resource'}))
end
end
table.insert(ret, '</ul>')
table.insert(ret, table.concat(rewards, '<br>'))
end
end
end
end
572

edits