Module:Sandbox/GauTest/Township: Difference between revisions

Part 1 of p.GetTaskTable
(Tasks)
(Part 1 of p.GetTaskTable)
Line 1: Line 1:
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Items = require('Module:Items')
local Monsters = require('Module:Monsters')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local Constants = require('Module:Constants')
local Constants = require('Module:Constants')
Line 755: Line 757:
end
end
table.insert(ret, '\r\n|}')
table.insert(ret, '\r\n|}')
return table.concat(ret)
end
function p.GetTaskTable(frame)
local category = frame.args ~= nil and frame.args[1] or frame
local ret = {}
table.insert(ret, '\r\n{| class="wikitable" style="text-align:left"')
table.insert(ret, '\r\n!Task')
table.insert(ret, '\r\n!Requirements')
table.insert(ret, '\r\n!Rewards')
for _, task in ipairs(Township.tasks) do
-- Filter out other categories
if task.category == category then
table.insert(ret, '\r\n|-')
table.insert(ret, '\r\n!'..task.name)
-- Requirements
table.insert(ret, '\r\n|<ul>')
for _, item in ipairs(task.goals.items) do
table.insert(ret, '<li>'..Shared.formatnum(item.quantity)..' '..Icons.Icon({Items.getItemByID(item.id), type='item'})..'</li>')
end
for _, monster in ipairs(task.goals.monsters) do
table.insert(ret, '<li>'..Shared.formatnum(monster.quantity)..' '..Icons.Icon({Monsters.getMonsterByID(monster.id), type='monster'})..'</li>')
end
for _, skill in ipairs(task.goals.skillXP) do
local skillname = GameData.getSkillData(skill.id).name
table.insert(ret, '<li>'..Shared.formatnum(skill.quantity)..' '..Icons.Icon({skillname, type='skill'})..'XP </li>')
end
for _, building in ipairs(task.goals.buildings) do
local buildingname = p._GetBuildingByID(building.id).name
table.insert(ret, '<li>'..Shared.formatnum(building.quantity)..' '..Icons.Icon({buildingname, type='building'})..'</li>')
end
table.insert(ret, '</ul>')
end
end
return table.concat(ret)
return table.concat(ret)
end
end


return p
return p
572

edits