Module:Prayer: Difference between revisions

473 bytes removed ,  22 October 2022
Update for v1.1
m (getBonesTable: skpairs -> ipairs where table is already sorted)
(Update for v1.1)
Line 4: Line 4:


local Shared = require('Module:Shared')
local Shared = require('Module:Shared')
local Constants = require('Module:Constants')
local GameData = require('Module:GameData')
local Icons = require('Module:Icons')
local Icons = require('Module:Icons')
local Constants = require('Module:Constants')
local Items = require('Module:Items')
local Items = require('Module:Items')
local ItemSources = require('Module:Items/SourceTables')
local ItemSources = require('Module:Items/SourceTables')


function p.getPrayerByID(id)
function p.getPrayerByID(id)
local result = Shared.clone(SkillData.Prayer[id + 1])
return GameData.getEntityByID('prayers', id)
if result ~= nil and result.id == nil then result.id = id end
return result
end
end


function p.getPrayer(name)
function p.getPrayer(name)
local result = nil
return GameData.getEntityByName('prayers', name)
for i, prayer in pairs(SkillData.Prayer) do
local prayName = prayer.name
if prayName == name then
result = Shared.clone(prayer)
result.id = i - 1
break
end
end
return result
end
end


function p.getPrayers(checkFunc)
function p.getPrayers(checkFunc)
local result = {}
return GameData.getEntities('prayer', checkFunc)
for i, prayer in ipairs(SkillData.Prayer) do
if checkFunc(prayer) then
table.insert(result, prayer)
end
end
return result
end
end


Line 70: Line 54:
table.insert(bonusLines, chr .. 'Gives the enemy: ' .. Constants._getModifierText(bonusKey, bonusVal, false))
table.insert(bonusLines, chr .. 'Gives the enemy: ' .. Constants._getModifierText(bonusKey, bonusVal, false))
end
end
end
--If there are no actual effects, just use the prayer's description
if Shared.tableCount(prayer.modifiers) == 0 then
table.insert(bonusLines, chr..prayer.description)
end
end


Line 82: Line 61:
local xpRatio = 1 / 30
local xpRatio = 1 / 30
local val = xpRatio * prayer.pointsPerPlayer
local val = xpRatio * prayer.pointsPerPlayer
table.insert(bonusLines, chr.."+"..Shared.round(val, 3, 3).." Prayer XP per damage done")
table.insert(bonusLines, chr .. "+" .. Shared.round(val, 3, 3) .. " Prayer XP per damage done")
end
end
if asList then
if asList then
Line 109: Line 88:
return p._getPrayerEffect(prayer)
return p._getPrayerEffect(prayer)
elseif statName == "prayerEffectList" then
elseif statName == "prayerEffectList" then
return p.getPrayerEffect(prayer, true)
return p.getPrayerEffect(prayer)
elseif statName == 'prayerLevel' then
elseif statName == 'prayerLevel' then
return Icons._SkillReq('Prayer', prayer['prayerLevel'])
return Icons._SkillReq('Prayer', prayer['prayerLevel'])
Line 148: Line 127:
result = result..'!!Effects!!Point Cost'
result = result..'!!Effects!!Point Cost'


local prayerList = Shared.clone(SkillData.Prayer)
local prayerList = p.getPrayers(function(prayer) return true end)
table.sort(prayerList, function(a, b)
table.sort(prayerList, function(a, b)
if a.prayerLevel == b.prayerLevel then
if a.level == b.level then
return a.name < b.name
return a.name < b.name
else
else
return a.prayerLevel < b.prayerLevel
return a.level < b.level
end
end
end)
end)
Line 180: Line 159:
result = result..'\r\n|'..Icons.Icon({item.name, type='item', notext=true, size='50'})
result = result..'\r\n|'..Icons.Icon({item.name, type='item', notext=true, size='50'})
result = result..'||'..Icons.Icon({item.name, type='item', noicon=true})
result = result..'||'..Icons.Icon({item.name, type='item', noicon=true})
result = result..'||style="text-align:right;"|'..item.prayerPoints
result = result..'||style="text-align:right;"|'..Shared.formatnum(item.prayerPoints)
result = result..'||'..ItemSources._getItemSources(item, false, false)
result = result..'||'..ItemSources._getItemSources(item, false, false)
end
end