Anonymous

Module:Monsters: Difference between revisions

From Melvor Idle
Added getMonsterResistance and getMonsterBoxResistenceText
(Fixed lua error and added functions to get the name of the monster's damage type)
(Added getMonsterResistance and getMonsterBoxResistenceText)
Line 358: Line 358:
end
end
end
end
end
function p._getMonsterResistance(monster)
local amount, text = nil, nil
if monster.damageType == 'melvorItA:Abyssal' then
amount = p._getMonsterStat(monster, 'resistance')
text = 'Abyssal Resistance'
else
amount = p._getMonsterStat(monster, 'damageReduction')
text = 'Damage Reduction'
end
return amount, text
end
end


Line 916: Line 928:


return result
return result
end
function p.getMonsterBoxResistenceText(frame)
local MonsterName = frame.args ~= nil and frame.args[1] or frame
local monster = p.getMonster(MonsterName)
if monster == nil then
return Shared.printError('No monster with that name found')
end
local resistance, text = p._getMonsterResistance(monster)
if resistance <= 0 then
return ''
end
local result = {}
table.insert(result, '|-\r\n| style="font-weight: bold;" | ' .. Icons.Icon({text, size=16, nolink="true"}) ..':')
table.insert(result, '\r\n| colspan=15 style="text-align: right" |')
table.insert(result, ' '..resistance..'%')
return table.concat(result, '')
end
end


Line 1,743: Line 1,775:
local atkSpeed = p._getMonsterAttackSpeed(monster)
local atkSpeed = p._getMonsterAttackSpeed(monster)
local maxHit = p._getMonsterMaxHit(monster)
local maxHit = p._getMonsterMaxHit(monster)
local dr = nil
local resistance = p._getMonsterResistance(monster)
if monster.damageType == 'melvorItA:Abyssal' then
dr = p._getMonsterStat(monster, 'resistance')
else
dr = p._getMonsterStat(monster, 'damageReduction')
end
local drReduce = p._getMonsterDrReduction(monster)
local drReduce = p._getMonsterDrReduction(monster)
local currVal = 0
local currVal = 0
Line 1,772: Line 1,799:
table.insert(tableParts, '\r\n|style="text-align:right"|' .. Num.formatnum(maxHit))
table.insert(tableParts, '\r\n|style="text-align:right"|' .. Num.formatnum(maxHit))
end
end
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. dr .. '" |' .. dr..'%')
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. resistance .. '" |' .. resistance..'%')
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. currVal .. '" |' .. currText)
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. currVal .. '" |' .. currText)
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt)
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt)