4,951
edits
Falterfire (talk | contribs) (Created shell of Agility page, doesn't actually have any useful functions yet) |
Falterfire (talk | contribs) (Initial pass at creating the agility obstacle table) |
||
Line 3: | Line 3: | ||
local ItemData = mw.loadData('Module:Items/data') | local ItemData = mw.loadData('Module:Items/data') | ||
local SkillData = mw.loadData('Module:Skills/data') | local SkillData = mw.loadData('Module:Skills/data') | ||
local Constants = require('Module:Constants') | |||
local Shared = require('Module:Shared') | local Shared = require('Module:Shared') | ||
local Items = require('Module:Items') | local Items = require('Module:Items') | ||
Line 12: | Line 12: | ||
function p.getObstacleCourseTable(frame) | function p.getObstacleCourseTable(frame) | ||
local result = '' | local result = '' | ||
result = '{| class="wikitable sortable stickyHeader"' | |||
result = result..'\r\n|- class="headerRow-0"' | |||
result = result..'!Name!!Slot!!XP!!GP!!Time!!XP/s!!GP/s!!Bonuses!!Requirements!!Cost' | |||
for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do | |||
result = result..'\r\n|-' | |||
result = result..'\r\n|'..obst.name..'||'..(obst.category + 1) | |||
--After the name & category, doing XP, GP, Time, and rates | |||
local XP = obst.completionBonuses.xp | |||
local GP = obst.completionBonuses.gp | |||
local Time = obst.interval / 1000 | |||
result = result..'||'..XP..'||data-sort-value="'..GP..'"|'..Icons.GP(GP) | |||
result = result..'||data-sort-value="'..Time..'"|'..Shared.timeString(Time) | |||
result = result..'||'..Shared.round(XP / Time, 2, 2) | |||
result = result..'||data-sort-value="'..GP/Time..'"|'..Icons.GP(Shared.round(GP/Time, 2, 2)) | |||
local bonuses = {} | |||
--After that, adding the bonuses | |||
for bonusName, bonusValue in pairs(obst.modifiers) do | |||
table.insert(bonuses, Constants.getModifierText(bonusName, bonusValue)) | |||
end | |||
if Shared.tableCount(bonuses) == 0 then | |||
table.insert(bonuses, '<span color="red">None :(</span>') | |||
end | |||
result = result..'||'..table.concat(bonuses, '<br/>') | |||
--Grabbing requirements to create | |||
result = result..'||' | |||
if obst.category > 0 then | |||
result = result..Icons._SkillReq('Agility', obst.category * 10) | |||
end | |||
if obst.requirements ~= nil and obst.requirements.skillLevel ~= nil then | |||
for j, skillReq in Shared.skpairs(obst.requirements.skillLevel) do | |||
result = result..'<br/>'..Icons._SkillReq(Constants.getSkillName(skillReq[1]), skillReq[2]) | |||
end | |||
end | |||
--Finally, the cost | |||
local costs = {} | |||
if obst.cost.gp > 0 then table.insert(costs, Icons.GP(obst.cost.gp)) end | |||
if obst.cost.slayerCoins > 0 then table.insert(costs, Icons.SC(obst.cost.slayerCoins)) end | |||
for j, itemCost in Shared.skpairs(obst.cost.items) do | |||
local item = Items.getItemByID(itemCost[1]) | |||
table.insert(costs, Icons.Icon({item.name, type='item', qty = itemCost[2]})) | |||
end | |||
result = result..'|| data-sort-value="'..obst.cost.gp..'"|'..table.concat(costs, '<br/>') | |||
end | |||
result = result..'\r\n|}' | |||
return result | return result | ||
end | end |