Module:Skills/Agility: Difference between revisions

Update for v1.3
No edit summary
(Update for v1.3)
Line 4: Line 4:
local Num = require('Module:Number')
local Num = require('Module:Number')
local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Common = require('Module:Common')
local GameData = require('Module:GameData')
local GameData = require('Module:GameData')
local SkillData = GameData.skillData
local SkillData = GameData.skillData
local Modifiers = require('Module:Modifiers')
local Skills = require('Module:Skills')
local Skills = require('Module:Skills')
local Items = require('Module:Items')
local Items = require('Module:Items')
Line 33: Line 35:


function p.getPillars(checkFunc)
function p.getPillars(checkFunc)
local result = nil
return GameData.getEntities(SkillData.Agility.pillars, checkFunc)
local keys = { 'pillars', 'elitePillars' }
for i, key in ipairs(keys) do
local pillars = GameData.getEntities(SkillData.Agility[key], checkFunc)
if result == nil then
result = pillars
else
for k, pillar in ipairs(pillars) do
table.insert(result, pillar)
end
end
end
if result == nil then
result = {}
end
return result
end
end


Line 104: Line 91:
local items = {}
local items = {}


if obstacle.gpCost > 0 then
for j, currCost in ipairs(obstacle.currencyCosts) do
costs['GP'] = obstacle.gpCost
local shortID = nil
end
if currCost.id == 'melvorD:GP' then
if obstacle.scCost > 0 then
shortID = 'GP'
costs['SC'] = obstacle.scCost
elseif currCost.id == 'melvorD:SlayerCoins' then
shortID = 'SC'
end
if shortID ~= nil then
costs[shortID] = currCost.quantity
end
end
end


Line 131: Line 123:
end
end


function p._getObstacleCosts(obstacle)
function p.getObstacleCourseTable(frame)
local costs = {}
local args = frame.args ~= nil and frame.args or frame
local obstacleCosts = p.getObstacleCosts(obstacle)
local realmName = args.realm
 
local realmID = nil
-- Make sure SC and GP appear at the top.
if realmName ~= nil and realmName ~= '' then
if obstacleCosts['GP'] then table.insert(costs, Icons.GP(obstacleCosts['GP'])) end
local realm = GameData.getEntityByName('realms', realmName)
if obstacleCosts['SC'] then table.insert(costs, Icons.SC(obstacleCosts['SC'])) end
if realm == nil then
for item, amount in pairs(obstacleCosts['Items']) do
return Shared.printError('No such realm: ' .. realmName)
table.insert(costs, Icons.Icon({item, type='item', qty = amount, notext=true}))
end
realmID = realm.id
end
end
 
return table.concat(costs, '<br/>')
end
 
function p.getObstacleCourseTable(frame)
local result = ''
local result = ''


Line 153: Line 142:


local catLog = {}
local catLog = {}
local obstacles = p.getObstacles(function(obst) return true end)
local obstacles = p.getObstacles(
function(obst)
return realmID == nil or Skills.getRecipeRealm(obst) == realmID
end
)
table.sort(obstacles, function(a, b) return a.category < b.category end)
table.sort(obstacles, function(a, b) return a.category < b.category end)


Line 179: Line 172:
local GP = obst.gpReward
local GP = obst.gpReward
local Time = obst.baseInterval / 1000
local Time = obst.baseInterval / 1000
result = result..'||'..XP..'||data-sort-value="'..GP..'"|'..Icons.GP(GP)
local costString = Common.getCostString({
items = obst.itemCosts,
currencies = obst.currencyCosts
})
local rewardString = Common.getCostString({
items = obst.itemRewards,
currencies = obst.currencyRewards
})
local costVal = (obst.currencyCosts ~= nil and obst.currencyCosts[1].quantity or 0)
local rewardVal = (obst.currencyRewards ~= nil and obst.currencyRewards[1].quantity or 0)
 
 
result = result..'||'..XP..'||data-sort-value="'..rewardVal..'"|'..rewardString
result = result..'||data-sort-value="'..Time..'"|'..Shared.timeString(Time, true)
result = result..'||data-sort-value="'..Time..'"|'..Shared.timeString(Time, true)
-- Readded XP/Time and GP/Time (previously commented out)
-- Readded XP/Time and GP/Time (previously commented out)
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="'..rewardVal/Time..'"|'..Icons.GP(Shared.round(rewardVal/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
local modText = Modifiers.getModifiersText(obst.modifiers, true, false, 10)
table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue))
if modText == '' then
modText = '<span style="text-negative">None :(</span>'
end
end
if Shared.tableIsEmpty(bonuses) then
result = result..'||'..modText
table.insert(bonuses, '<span style="color:red">None :(</span>')
end
result = result..'||'..table.concat(bonuses, '<br/>')


--Grabbing requirements to create
--Grabbing requirements to create
Line 199: Line 202:


--Finally, the cost
--Finally, the cost
result = result..'|| data-sort-value="'..obst.gpCost..'"|'..p._getObstacleCosts(obst)
result = result..'|| data-sort-value="'..costVal..'"|'..costString
end
end


Line 208: Line 211:


function p.getPassivePillarTable(frame)
function p.getPassivePillarTable(frame)
local args = frame.args ~= nil and frame.args or frame
local realmName = args.realm
local realmID = nil
if realmName ~= nil and realmName ~= '' then
local realm = GameData.getEntityByName('realms', realmName)
if realm == nil then
return Shared.printError('No such realm: ' .. realmName)
end
realmID = realm.id
end
local result = ''
local result = ''


Line 214: Line 228:
result = result..'\r\n!Name!!Bonuses!!Cost'
result = result..'\r\n!Name!!Bonuses!!Cost'


local pillars = p.getPillars(function(pillar) return true end)
local pillars = p.getPillars(
function(pill)
return realmID == nil or Skills.getRecipeRealm(pill) == realmID
end
)
for i, pill in ipairs(pillars) do
for i, pill in ipairs(pillars) do
result = result..'\r\n|-'
result = result..'\r\n|-'
Line 220: Line 238:


--After that, adding the bonuses
--After that, adding the bonuses
local bonuses = {}
local modText = Modifiers.getModifiersText(pill.modifiers, true, false, 10)
for bonusName, bonusValue in pairs(pill.modifiers) do
if modText == '' then
table.insert(bonuses, Constants._getModifierText(bonusName, bonusValue))
modText = '<span style="text-negative">None :(</span>'
end
if Shared.tableIsEmpty(bonuses) then
table.insert(bonuses, '<span style="color:red">None :(</span>')
end
end
result = result..'||'..table.concat(bonuses, '<br/>')
result = result..'||'..modText


--Finally, the cost
--Finally, the cost
result = result..'|| data-sort-value="'..pill.gpCost..'"|'.. p._getObstacleCosts(pill)
local costString = Common.getCostString({
items = pill.itemCosts,
currencies = pill.currencyCosts
})
local costVal = (pill.currencyCosts ~= nil and pill.currencyCosts[1].quantity or 0)
result = result..'|| data-sort-value="'..costVal..'"|'.. costString
end
end