4,951
edits
Falterfire (talk | contribs) (Formatting tweaks to obstacle course table) |
Falterfire (talk | contribs) (Added a getObstacles function which will be used by the in-progress ModifierTables module) |
||
(10 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
local ItemSourceTables = require('Module:Items/SourceTables') | local ItemSourceTables = require('Module:Items/SourceTables') | ||
local Icons = require('Module:Icons') | local Icons = require('Module:Icons') | ||
function p.getObstacleByID(obstID) | |||
local result = Shared.clone(SkillData.Agility.Obstacles[obstID + 1]) | |||
return result | |||
end | |||
function p.getObstacle(name) | |||
for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do | |||
if obst.name == name then | |||
local result = Shared.clone(obst) | |||
result.id = i - 1 | |||
return result | |||
end | |||
end | |||
return nil | |||
end | |||
function p.getObstacles(checkFunc) | |||
local result = {} | |||
for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do | |||
if checkFunc(obst) then | |||
local newObst = Shared.clone(obst) | |||
newObst.id = i - 1 | |||
table.insert(result, newObst) | |||
end | |||
end | |||
return result | |||
end | |||
function p.getObstacleCourseTable(frame) | function p.getObstacleCourseTable(frame) | ||
Line 15: | Line 43: | ||
result = '{| class="wikitable sortable stickyHeader"' | result = '{| class="wikitable sortable stickyHeader"' | ||
result = result..'\r\n|- class="headerRow-0"' | result = result..'\r\n|- class="headerRow-0"' | ||
result = result..'\r\n! | result = result..'\r\n!Slot!!Name!!XP!!GP!!Time'--!!XP/s!!GP/s | ||
result = result..'!!Bonuses!!Requirements!!Cost' | |||
local catLog = {} | |||
for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do | for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do | ||
result = result..'\r\n|-' | result = result..'\r\n|-' | ||
result = result..'\r\n|'.. | result = result..'\r\n|' | ||
if catLog[obst.category] == nil then | |||
local rowspan = obst.category > 1 and 5 or 3 | |||
result = result..'rowspan="'..rowspan..'" style="border:1px solid black"|'..(obst.category + 1)..'||' | |||
catLog[obst.category] = true | |||
end | |||
result = result..obst.name | |||
--After the name & category, doing XP, GP, Time, and rates | --After the name & category, doing XP, GP, Time, and rates | ||
Line 27: | Line 64: | ||
result = result..'||'..XP..'||data-sort-value="'..GP..'"|'..Icons.GP(GP) | result = result..'||'..XP..'||data-sort-value="'..GP..'"|'..Icons.GP(GP) | ||
result = result..'||data-sort-value="'..Time..'"|'..Shared.timeString(Time, true) | result = result..'||data-sort-value="'..Time..'"|'..Shared.timeString(Time, true) | ||
result = result..'||'..Shared.round(XP / Time, 2, 2) | --result = result..'||'..Shared.round(XP / Time, 2, 2) | ||
result = result..'||data-sort-value="'..GP/Time..'"|'..Icons.GP(Shared.round(GP/Time, 2, 2)) | --result = result..'||data-sort-value="'..GP/Time..'"|'..Icons.GP(Shared.round(GP/Time, 2, 2)) | ||
local bonuses = {} | local bonuses = {} | ||
--After that, adding the bonuses | --After that, adding the bonuses | ||
for bonusName, bonusValue in pairs(obst.modifiers) do | for bonusName, bonusValue in pairs(obst.modifiers) do | ||
table.insert(bonuses, Constants. | table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue)) | ||
end | end | ||
if Shared.tableCount(bonuses) == 0 then | if Shared.tableCount(bonuses) == 0 then | ||
table.insert(bonuses, '<span | table.insert(bonuses, '<span style="color:red">None :(</span>') | ||
end | end | ||
result = result..'||'..table.concat(bonuses, '<br/>') | result = result..'||'..table.concat(bonuses, '<br/>') | ||
Line 57: | Line 94: | ||
for j, itemCost in Shared.skpairs(obst.cost.items) do | for j, itemCost in Shared.skpairs(obst.cost.items) do | ||
local item = Items.getItemByID(itemCost[1]) | local item = Items.getItemByID(itemCost[1]) | ||
table.insert(costs, Icons.Icon({item.name, type='item', qty = itemCost[2]})) | table.insert(costs, Icons.Icon({item.name, type='item', qty = itemCost[2], notext=true})) | ||
end | end | ||
result = result..'|| data-sort-value="'..obst.cost.gp..'"|'..table.concat(costs, '<br/>') | result = result..'|| data-sort-value="'..obst.cost.gp..'"|'..table.concat(costs, '<br/>') | ||
Line 69: | Line 106: | ||
function p.getPassivePillarTable(frame) | function p.getPassivePillarTable(frame) | ||
local result = '' | local result = '' | ||
result = '{| class="wikitable sortable stickyHeader"' | |||
result = result..'\r\n|- class="headerRow-0"' | |||
result = result..'\r\n!Name!!Bonuses!!Cost' | |||
for i, pill in Shared.skpairs(SkillData.Agility.Pillars) do | |||
result = result..'\r\n|-' | |||
result = result..'\r\n|'..pill.name | |||
--After that, adding the bonuses | |||
local bonuses = {} | |||
for bonusName, bonusValue in pairs(pill.modifiers) do | |||
table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue)) | |||
end | |||
if Shared.tableCount(bonuses) == 0 then | |||
table.insert(bonuses, '<span style="color:red">None :(</span>') | |||
end | |||
result = result..'||'..table.concat(bonuses, '<br/>') | |||
--Finally, the cost | |||
local costs = {} | |||
if pill.cost.gp > 0 then table.insert(costs, Icons.GP(pill.cost.gp)) end | |||
if pill.cost.slayerCoins > 0 then table.insert(costs, Icons.SC(pill.cost.slayerCoins)) end | |||
for j, itemCost in Shared.skpairs(pill.cost.items) do | |||
local item = Items.getItemByID(itemCost[1]) | |||
table.insert(costs, Icons.Icon({item.name, type='item', qty = itemCost[2], notext=true})) | |||
end | |||
result = result..'|| data-sort-value="'..pill.cost.gp..'"|'..table.concat(costs, '<br/>') | |||
end | |||
result = result..'\r\n|}' | |||
return result | |||
end | |||
function p.getObstaclesForItem(itemID) | |||
local result = {} | |||
for i, obst in Shared.skpairs(SkillData.Agility.Obstacles) do | |||
for j, costLine in Shared.skpairs(obst.cost.items) do | |||
if costLine[1] == itemID then | |||
table.insert(result, obst) | |||
end | |||
end | |||
end | |||
for i, obst in Shared.skpairs(SkillData.Agility.Pillars) do | |||
for j, costLine in Shared.skpairs(obst.cost.items) do | |||
if costLine[1] == itemID then | |||
table.insert(result, obst) | |||
end | |||
end | |||
end | |||
return result | return result | ||
end | end | ||
return p | return p |