|
|
Line 10: |
Line 10: |
|
| |
|
| function p.getPrayerByID(id) | | function p.getPrayerByID(id) |
| local result = Shared.clone(SkillData.Prayer[id + 1])
| | local result = Shared.clone(SkillData.Prayer[id + 1]) |
| if result ~= nil and result.id == nil then result.id = id end
| | if result ~= nil and result.id == nil then result.id = id end |
| return result
| | return result |
| end | | end |
|
| |
|
| function p.getPrayer(name) | | function p.getPrayer(name) |
| local result = nil
| | local result = nil |
| for i, prayer in pairs(SkillData.Prayer) do
| | for i, prayer in pairs(SkillData.Prayer) do |
| local prayName = prayer.name
| | local prayName = prayer.name |
| if prayName == name then
| | if prayName == name then |
| result = Shared.clone(prayer)
| | result = Shared.clone(prayer) |
| result.id = i - 1
| | result.id = i - 1 |
| break
| | break |
| end
| | end |
| end
| | end |
| return result
| | return result |
| end | | end |
|
| |
|
Line 39: |
Line 39: |
|
| |
|
| function p.getPrayerCost(prayer) | | function p.getPrayerCost(prayer) |
| local costLines = {}
| | local costLines = {} |
| if prayer.pointsPerPlayer > 0 then
| | if prayer.pointsPerPlayer > 0 then |
| local pluralString = prayer.pointsPerPlayer > 1 and 's' or ''
| | local pluralString = prayer.pointsPerPlayer > 1 and 's' or '' |
| table.insert(costLines, prayer.pointsPerPlayer..' Prayer Point'..pluralString..' per player attack')
| | table.insert(costLines, prayer.pointsPerPlayer..' Prayer Point'..pluralString..' per player attack') |
| end
| | end |
| if prayer.pointsPerEnemy > 0 then
| | if prayer.pointsPerEnemy > 0 then |
| local pluralString = prayer.pointsPerEnemy > 1 and 's' or ''
| | local pluralString = prayer.pointsPerEnemy > 1 and 's' or '' |
| table.insert(costLines, prayer.pointsPerEnemy..' Prayer Point'..pluralString..' per enemy attack')
| | table.insert(costLines, prayer.pointsPerEnemy..' Prayer Point'..pluralString..' per enemy attack') |
| end
| | end |
| if prayer.pointsPerRegen > 0 then
| | if prayer.pointsPerRegen > 0 then |
| local pluralString = prayer.pointsPerRegen > 1 and 's' or ''
| | local pluralString = prayer.pointsPerRegen > 1 and 's' or '' |
| table.insert(costLines, prayer.pointsPerRegen..' Prayer Point'..pluralString..' when health regenerates')
| | table.insert(costLines, prayer.pointsPerRegen..' Prayer Point'..pluralString..' when health regenerates') |
| end
| | end |
| return table.concat(costLines, '<br/>')
| | return table.concat(costLines, '<br/>') |
| end | | end |
|
| |
|
| function p.formatEffectLine(var, val) | | function p._getPrayerEffect(prayer, asList) |
| if var == 'prayerBonusDefence' then
| | if asList == nil then asList = false end |
| return '+'..val..'% [[Combat#Melee Evasion Rating|Melee Evasion Rating]]'
| | local chr = asList and '* ' or '' |
| elseif var == 'prayerBonusStrength' then
| | local bonusLines = {} |
| return '+'..val..'% [[Combat#Melee Max Hit|Melee Strength]]'
| |
| elseif var == 'prayerBonusAttack' then
| |
| return '+'..val..'% [[Combat#Melee Accuracy Rating|Melee Accuracy Rating]]'
| |
| elseif var == 'prayerBonusDefenceRanged' then
| |
| return '+'..val..'% [[Combat#Ranged Evasion Rating|Ranged Evasion Rating]]'
| |
| elseif var == 'prayerBonusAttackRanged' then
| |
| return '+'..val..'% [[Combat#Ranged Accuracy Rating|Ranged Accuracy Rating]]'
| |
| elseif var == 'prayerBonusStrengthRanged' then
| |
| return '+'..val..'% [[Combat#Ranged Max Hit|Ranged Strength]]'
| |
| elseif var == 'prayerBonusDefenceMagic' then
| |
| return '+'..val..'% [[Combat#Magic Evasion Rating|Ranged Evasion Rating]]'
| |
| elseif var == 'prayerBonusAttackMagic' then
| |
| return '+'..val..'% [[Combat#Magic Accuracy Rating|Magic Accuracy Rating]]'
| |
| elseif var == 'prayerBonusDamageMagic' then
| |
| return '+'..val..'% [[Combat#Magic Max Hit|Magic Damage]]'
| |
| elseif var == 'prayerBonusHitpoints' then
| |
| return val..'x Restore Rate for [[Hitpoints]]'
| |
| elseif var == 'prayerBonusProtectItem' then
| |
| return 'Prevents losing an item upon [[Death]]'
| |
| elseif var == 'prayerBonusProtectFromMelee' then
| |
| return '85% chance to dodge Melee attacks'
| |
| elseif var == 'prayerBonusProtectFromRanged' then
| |
| return '85% chance to dodge Ranged attacks'
| |
| elseif var == 'prayerBonusProtectFromMagic' then
| |
| return '85% chance to dodge Magic attacks'
| |
| elseif var == 'prayerBonusHitpointHeal' then
| |
| return 'Heal +'..val..'% HP when HP falls below 10%'
| |
| elseif var == 'prayerBonusDamageReduction' then
| |
| return '+'..val..'% [[Damage Reduction]]'
| |
| else
| |
| return '+'..val..' of unknown bonus '..var..'[[Category:Unknown Prayer Bonus]]'
| |
| end
| |
| end
| |
|
| |
|
| function p._getPrayerEffect(prayer, asList)
| | if type(prayer.modifiers) == 'table' then |
| if asList == nil then asList = false end
| | for bonusKey, bonusVal in Shared.skpairs(prayer.modifiers) do |
| local chr = asList and '* ' or ''
| | table.insert(bonusLines, chr .. Constants._getModifierText(bonusKey, bonusVal, false)) |
| local bonusLines = {}
| | end |
| | end |
|
| |
|
| if type(prayer.modifiers) == 'table' then
| | if type(prayer.enemyModifiers) == 'table' then |
| for bonusKey, bonusVal in Shared.skpairs(prayer.modifiers) do
| | for bonusKey, bonusVal in Shared.skpairs(prayer.enemyModifiers) do |
| table.insert(bonusLines, chr .. Constants._getModifierText(bonusKey, bonusVal, false))
| | table.insert(bonusLines, chr .. 'Gives the enemy: ' .. Constants._getModifierText(bonusKey, bonusVal, false)) |
| end
| | end |
| end
| | end |
|
| |
| if type(prayer.enemyModifiers) == 'table' then
| |
| for bonusKey, bonusVal in Shared.skpairs(prayer.enemyModifiers) do
| |
| table.insert(bonusLines, chr .. 'Gives the enemy: ' .. Constants._getModifierText(bonusKey, bonusVal, false))
| |
| end
| |
| end
| |
|
| |
|
| --If there are no actual effects, just use the prayer's description
| | --If there are no actual effects, just use the prayer's description |
| if Shared.tableCount(prayer.modifiers) == 0 then
| | if Shared.tableCount(prayer.modifiers) == 0 then |
| table.insert(bonusLines, chr..prayer.description)
| | table.insert(bonusLines, chr..prayer.description) |
| end
| | end |
|
| |
|
| if prayer.pointsPerPlayer > 0 then
| | if prayer.pointsPerPlayer > 0 then |
| -- Prayer XP ratio is 1/3 in game but is divided by 10 here as HP/damage values
| | -- Prayer XP ratio is 1/3 in game but is divided by 10 here as HP/damage values |
| -- displayed to the player are multiplied by 10 in the standard game mode
| | -- displayed to the player are multiplied by 10 in the standard game mode |
| 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 |
| return table.concat(bonusLines, '\r\n')
| | return table.concat(bonusLines, '\r\n') |
| else
| | else |
| return table.concat(bonusLines, '<br/>')
| | return table.concat(bonusLines, '<br/>') |
| end
| | end |
| end | | end |
|
| |
|
| function p.getPrayerEffect(frame) | | function p.getPrayerEffect(frame) |
| local prayerName = frame.args ~= nil and frame.args[1] or frame[1]
| | local prayerName = frame.args ~= nil and frame.args[1] or frame[1] |
| local asListTxt = frame.args ~= nil and frame.args[2] or frame[2]
| | local asListTxt = frame.args ~= nil and frame.args[2] or frame[2] |
| local asList = asListTxt ~= nil and asListTxt ~= 'false' and asListTxt ~= 'no'
| | local asList = asListTxt ~= nil and asListTxt ~= 'false' and asListTxt ~= 'no' |
| local prayer = p.getPrayer(prayerName)
| | local prayer = p.getPrayer(prayerName) |
| if prayer == nil then
| | if prayer == nil then |
| return "ERROR: Could not find a prayer named "..prayerName
| | return "ERROR: Could not find a prayer named "..prayerName |
| end
| | end |
|
| |
|
| return p._getPrayerEffect(prayer, asList)
| | return p._getPrayerEffect(prayer, asList) |
| end | | end |
|
| |
|
| function p._getPrayerStat(prayer, statName) | | function p._getPrayerStat(prayer, statName) |
| if statName == "prayerCost" then
| | if statName == "prayerCost" then |
| return p.getPrayerCost(prayer)
| | return p.getPrayerCost(prayer) |
| elseif statName == "prayerEffect" then
| | elseif statName == "prayerEffect" then |
| 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, true) |
| elseif statName == 'prayerLevel' then
| | elseif statName == 'prayerLevel' then |
| return Icons._SkillReq('Prayer', prayer['prayerLevel'])
| | return Icons._SkillReq('Prayer', prayer['prayerLevel']) |
| else
| | else |
| return prayer[statName]
| | return prayer[statName] |
| end
| | end |
| end | | end |
|
| |
|
| function p.getPrayerStat(frame) | | function p.getPrayerStat(frame) |
| local prayerName = frame.args ~= nil and frame.args[1] or frame[1]
| | local prayerName = frame.args ~= nil and frame.args[1] or frame[1] |
| local statName = frame.args ~= nil and frame.args[2] or frame[2]
| | local statName = frame.args ~= nil and frame.args[2] or frame[2] |
| local prayer = p.getPrayer(prayerName)
| | local prayer = p.getPrayer(prayerName) |
| if prayer == nil then
| | if prayer == nil then |
| return "ERROR: Could not find a prayer named "..prayerName
| | return "ERROR: Could not find a prayer named "..prayerName |
| end
| | end |
|
| |
|
| return p._getPrayerStat(prayer, statName)
| | return p._getPrayerStat(prayer, statName) |
| end | | end |
|
| |
|
| function p._getPrayerCategories(prayer) | | function p._getPrayerCategories(prayer) |
| return '[[Category:Prayers]]'
| | return '[[Category:Prayers]]' |
| end | | end |
|
| |
|
| function p.getPrayerCategories(frame) | | function p.getPrayerCategories(frame) |
| local prayerName = frame.args ~= nil and frame.args[1] or frame[1]
| | local prayerName = frame.args ~= nil and frame.args[1] or frame[1] |
| local prayer = p.getPrayer(prayerName)
| | local prayer = p.getPrayer(prayerName) |
| if prayer == nil then
| | if prayer == nil then |
| return "ERROR: Could not find a prayer named "..prayerName
| | return "ERROR: Could not find a prayer named "..prayerName |
| end
| | end |
|
| |
|
| return p._getPrayerCategories(prayer)
| | return p._getPrayerCategories(prayer) |
| end | | end |
|
| |
|
| function p.getPrayerTable(frame) | | function p.getPrayerTable(frame) |
| local result = '{| class="wikitable sortable stickyHeader"'
| | local result = '{| class="wikitable sortable stickyHeader"' |
| result = result..'\r\n|-class=headerRow-0'
| | result = result..'\r\n|-class=headerRow-0' |
| result = result..'\r\n!colspan="2"|Prayer!!'..Icons.Icon({"Prayer", type="skill", notext=true})..' Lvl'
| | result = result..'\r\n!colspan="2"|Prayer!!'..Icons.Icon({"Prayer", type="skill", notext=true})..' Lvl' |
| result = result..'!!Effects!!Point Cost'
| | result = result..'!!Effects!!Point Cost' |
|
| | |
| local prayerList = Shared.clone(SkillData.Prayer)
| | local prayerList = Shared.clone(SkillData.Prayer) |
| table.sort(prayerList, function(a, b)
| | table.sort(prayerList, function(a, b) |
| if a.prayerLevel == b.prayerLevel then
| | if a.prayerLevel == b.prayerLevel then |
| return a.name < b.name
| | return a.name < b.name |
| else
| | else |
| return a.prayerLevel < b.prayerLevel
| | return a.prayerLevel < b.prayerLevel |
| end
| | end |
| end)
| | end) |
|
| |
|
| for i, prayer in ipairs(prayerList) do
| | for i, prayer in ipairs(prayerList) do |
| result = result..'\r\n|-'
| | result = result..'\r\n|-' |
| result = result..'\r\n|'..Icons.Icon({prayer.name, type='prayer', notext=true, size='50'})
| | result = result..'\r\n|'..Icons.Icon({prayer.name, type='prayer', notext=true, size='50'}) |
| result = result..'||'..Icons.Icon({prayer.name, type='prayer', noicon=true})..'||'..prayer.prayerLevel
| | result = result..'||'..Icons.Icon({prayer.name, type='prayer', noicon=true})..'||'..prayer.prayerLevel |
| result = result..'||'..p._getPrayerEffect(prayer)
| | result = result..'||'..p._getPrayerEffect(prayer) |
| result = result..'||'..p.getPrayerCost(prayer)
| | result = result..'||'..p.getPrayerCost(prayer) |
| end
| | end |
|
| |
|
| result = result..'\r\n|}'
| | result = result..'\r\n|}' |
| return result
| | return result |
| end | | end |
|
| |
|
| function p.getBonesTable(frame) | | function p.getBonesTable(frame) |
| local result = '{| class="wikitable sortable stickyHeader"'
| | local result = '{| class="wikitable sortable stickyHeader"' |
| result = result..'\r\n|- class="headerRow-0"'
| | result = result..'\r\n|- class="headerRow-0"' |
| result = result..'\r\n!colspan="2"|Bone!!Prayer Points!!Sources'
| | result = result..'\r\n!colspan="2"|Bone!!Prayer Points!!Sources' |
|
| |
| local itemArray = Items.getItems(function(item) return item.prayerPoints ~= nil and item.prayerPoints > 0 end)
| |
|
| |
|
| table.sort(itemArray, function(a, b) return a.prayerPoints < b.prayerPoints end)
| | local itemArray = Items.getItems(function(item) return item.prayerPoints ~= nil and item.prayerPoints > 0 end) |
|
| |
|
| for i, item in Shared.skpairs(itemArray) do
| | table.sort(itemArray, function(a, b) return a.prayerPoints < b.prayerPoints end) |
| result = result..'\r\n|-'
| |
| 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..'||style="text-align:right;"|'..item.prayerPoints
| |
| result = result..'||'..ItemSources._getItemSources(item, false, false)
| |
| end
| |
|
| |
|
| result = result..'\r\n|}'
| | for i, item in Shared.skpairs(itemArray) do |
| | result = result..'\r\n|-' |
| | 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..'||style="text-align:right;"|'..item.prayerPoints |
| | result = result..'||'..ItemSources._getItemSources(item, false, false) |
| | end |
|
| |
|
| return result
| | result = result..'\r\n|}' |
| | |
| | return result |
| end | | end |
|
| |
|
| return p | | return p |