17,105
edits
mNo edit summary |
(Use tabs instead of spaces for indentation) |
||
Line 9: | Line 9: | ||
function p.getFullStormsnapTable(frame) | function p.getFullStormsnapTable(frame) | ||
local monsterIDs = {} | |||
for i = 0, Shared.tableCount(MonsterData.Monsters) - 1, 1 do | |||
table.insert(monsterIDs, i) | |||
end | |||
return p._getStormsnapTable(monsterIDs) | |||
end | end | ||
function p._getStormsnapTable(monsterIDs | function p._getStormsnapTable(monsterIDs) | ||
--Making a single function for getting a table of monsters given a list of IDs. | |||
local tableParts = {} | |||
table.insert(tableParts, '{| class="wikitable sortable stickyHeader" style="width: 100%;"') | |||
table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n!Monster !!Name ') | |||
table.insert(tableParts, '!!style="padding:1 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true}) .. ' Magic Level') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true}) .. ' Ranged Attack Bonus') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Strength', type='skill', notext=true}) .. ' Ranged Strength Bonus') | |||
-- Generate row per monster | |||
for i, monsterID in Shared.skpairs(monsterIDs) do | |||
local monster = Monsters.getMonsterByID(monsterID) | |||
local magicLevel = Monsters._getMonsterLevel(monster, 'Magic') | |||
local rangedStrBonus = 111 + math.floor((6 * magicLevel)/33) | |||
local rangedAttBonus = math.floor(102 * (1 + ((6 * magicLevel)/5500))) | |||
if magicLevel > 1 then | |||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left" |' .. Icons.Icon({monster.name, type='monster', noicon=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. magicLevel .. '" |' .. Shared.formatnum(magicLevel)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. rangedAttBonus .. '" |' .. Shared.formatnum(rangedAttBonus)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. rangedStrBonus .. '" |' .. Shared.formatnum(rangedStrBonus)) | |||
end | |||
end | end | ||
table.insert(tableParts, '\r\n|}') | |||
return table.concat(tableParts) | |||
end | end | ||
function p.getFullMonsterTable(frame) | function p.getFullMonsterTable(frame) | ||
local monsterIDs = {} | |||
for i = 0, Shared.tableCount(MonsterData.Monsters) - 1, 1 do | |||
table.insert(monsterIDs, i) | |||
end | |||
return p._getMonsterTable(monsterIDs, false) | |||
end | end | ||
function p._getMonsterTable(monsterIDs, excludeDungeons) | function p._getMonsterTable(monsterIDs, excludeDungeons) | ||
--Making a single function for getting a table of monsters given a list of IDs. | |||
local hideDungeons = excludeDungeons ~= nil and excludeDungeons or false | |||
local tableParts = {} | |||
--wikitable sortable align-center-1 align-left-2 align-left-3 align-center-4 align-center-5 align-center-6 align-center-7 align-center-8 align-center-9 jquery-tablesorter | |||
table.insert(tableParts, '{| class="wikitable sortable stickyHeader jquery-tablesorter" style="width: 100%;"') | |||
-- First header row | |||
table.insert(tableParts, '\r\n|- class="headerRow-0"\r\n! colspan="5" | !! colspan="4" |Offensive Stats !! colspan="3" |Evasion Rating !! colspan="4" |') | |||
-- Second header row | |||
table.insert(tableParts, '\r\n|- class="headerRow-1"\r\n! colspan="2"|Monster !!ID !!style="width: 5%;"|Combat Level ') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Hitpoints', type='skill', notext=true})) | |||
table.insert(tableParts, '!!Attack Type !!style="width: 5%;"|Attack Speed (s) !!Max Hit !!Accuracy ') | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Defence', type='skill', notext=true})) | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Ranged', type='skill', notext=true})) | |||
table.insert(tableParts, '!!style="padding:0 1em 0 0"|' .. Icons.Icon({'Magic', type='skill', notext=true})) | |||
table.insert(tableParts, '!!Bones !!Locations') | |||
-- Generate row per monster | |||
for i, monsterID in Shared.skpairs(monsterIDs) do | |||
local monster = Monsters.getMonsterByID(monsterID) | |||
local cmbLevel = Monsters._getMonsterCombatLevel(monster) | |||
local atkSpeed = Monsters._getMonsterAttackSpeed(monster) | |||
local maxHit = Monsters._getMonsterMaxHit(monster) | |||
local accR = Monsters._getMonsterAR(monster) | |||
local evaR = {Monsters._getMonsterER(monster, "Melee"), Monsters._getMonsterER(monster, "Ranged"), Monsters._getMonsterER(monster, "Magic")} | |||
local lootChance = monster.lootChance ~= nil and monster.lootChance or 100 | |||
local gpRange = {0, 0} | |||
if monster.dropCoins ~= nil and monster.dropCoins[2] > 1 then | |||
gpRange = {monster.dropCoins[1], monster.dropCoins[2]} | |||
end | |||
local gpTxt = nil | |||
if gpRange[1] >= gpRange[2] then | |||
gpTxt = Icons.GP(gpRange[1]) | |||
else | |||
gpTxt = Icons.GP(gpRange[1], gpRange[2]) | |||
end | |||
local boneTxt = 'None' | |||
if monster.bones ~= nil and monster.bones >= 0 then | |||
local bones = Items.getItemByID(monster.bones) | |||
boneTxt = Icons.Icon({bones.name, type='item', notext=true}) | |||
end | |||
table.insert(tableParts, '\r\n|-\r\n|style="text-align: center; border-right-width: 0px;" |' .. Icons.Icon({monster.name, type='monster', size=50, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:left; border-left-width: 0px; width: 15%;" |' .. Icons.Icon({monster.name, type='monster', noicon=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" |' .. monsterID) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. cmbLevel .. '" |' .. Shared.formatnum(cmbLevel)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. Monsters._getMonsterHP(monster) .. '" |' .. Shared.formatnum(Monsters._getMonsterHP(monster))) | |||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. Monsters._getMonsterStyleIcon({monster, notext=true})) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. atkSpeed .. '" |' .. Shared.round(atkSpeed, 1, 1)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. maxHit .. '" |' .. Shared.formatnum(maxHit)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. accR .. '" |' .. Shared.formatnum(accR)) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[1] .. '" |' .. Shared.formatnum(evaR[1])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[2] .. '" |' .. Shared.formatnum(evaR[2])) | |||
table.insert(tableParts, '\r\n|style="text-align:right" data-sort-value="' .. evaR[3] .. '" |' .. Shared.formatnum(evaR[3])) | |||
table.insert(tableParts, '\r\n|style="text-align:center" |' .. boneTxt) | |||
table.insert(tableParts, '\r\n|style="text-align:right;white-space:pre-line;" |' .. Monsters._getMonsterAreas(monster, hideDungeons)) | |||
end | |||
table.insert(tableParts, '\r\n|}') | |||
return table.concat(tableParts) | |||
end | end | ||
return p | return p |