2,875
edits
(Created page with "local p = {} local Shared = require('Module:Shared') local GameData = require('Module:GameData') local SkillData = GameData.skillData local Common = require('Module:Common') local Modifiers = require('Module:Modifiers') local Attacks = require('Module:Attacks') local Icons = require('Module:Icons') local Items = require('Module:Items') p.spellBooks = { { id = 'standard', dataID = 'attackSpells', name = 'Standard Magic', imgType = 'spell', bookID = 'melvorD:Standard' }...") |
No edit summary |
||
Line 598: | Line 598: | ||
function p._getSpellHeader(includeTypeColumn, includeItems, includeDamage, includeExperience) | function p._getSpellHeader(includeTypeColumn, includeItems, includeDamage, includeExperience) | ||
end | end | ||
function p._getSpellRow(spell, includeTypeColumn, includeItems, includeDamage, includeExperience) | function p._getSpellRow(spell, includeTypeColumn, includeItems, includeDamage, includeExperience) | ||
end | end | ||
Line 683: | Line 627: | ||
local spellListSorted = Shared.shallowClone(spellList) | local spellListSorted = Shared.shallowClone(spellList) | ||
table.sort(spellListSorted, function(a, b) return a.level < b.level end) | table.sort(spellListSorted, function(a, b) return a.level < b.level end) | ||
local | |||
---- Header stuff ---- | |||
local html = mw.html.create('table') | |||
:addClass('wikitable, sortable, stickyHeader') | |||
local header = html.tag('tr') | |||
header.tag('th'):wikitext('Spell') | |||
:attr('colspan', 2) | |||
if includeTypeColumn then | |||
header.tag('th'):wikitext('Spellbook') | |||
end | |||
header.tag('th'):wikitext('Requirements') | |||
header.tag('th'):wikitext('[[DLC]]') | |||
if includeDamage then | |||
header.tag('th'):wikitext('Spell Dmg') | |||
end | |||
header.tag('th'):wikitext('Description') | |||
--table.insert(resultPart, 'style="width:275px"| Description') | |||
if includeExperience then | |||
header.tag('th'):wikitext('XP') | |||
end | |||
header.tag('th'):wikitext('Runes') | |||
:css('min-width', '90px') | |||
if includeItems then | |||
header.tag('th'):wikitext('Item Cost') | |||
end | |||
---- row stuff ---- | |||
for i, spell in ipairs(spellListSorted) do | for i, spell in ipairs(spellListSorted) do | ||
local spellBook = p.getSpellBookFromSpell(spell) | |||
local row = html.tag('tr') | |||
row.tag('td'):wikitext(Icons.Icon({spell.name, type=spellBook.imgType, notext=true})) | |||
:css('text-align', 'center') | |||
:attr('data-sort-value', spell.name) | |||
row.tag('td'):wikitext(Icons.Icon({spell.name, type=spellBook.imgType, noicon=true})) | |||
if includeTypeColumn then | |||
row.tag('td'):wikitext(p.getSpellTypeLink(spellBook.id)) | |||
:attr('data-sort-value', spellBook.id) | |||
end | |||
row.tag('td'):wikitext(Icons.getDLCColumnIcon(spell.id)) | |||
:attr('data-sort-value', Icons.getExpansionID(spell.id)) | |||
:css('text-align', 'center') | |||
row.tag('td'):wikitext(p._getSpellRequirements(spell)) | |||
:attr('data-sort-value', spell.level) | |||
--11/01/22: Added base damage if requested | |||
if includeDamage then | |||
local dmg = p._getSpellStat(spell, 'spellDamage') | |||
if dmg > 0 then | |||
row.tag('td'):wikitext(dmg) | |||
:css('text-align', 'right') | |||
else | |||
row.tag('td'):wikitext('N/A') | |||
:addClass('table-na') | |||
end | |||
end | |||
--8/20/21: Changed to just getting the spell's description outright | |||
row.tag('td'):wikitext(p._getSpellStat(spell, 'description')) | |||
--1/4/22: haha just kidding. Now we're also getting delay between attacks for spells with special attacks | |||
local spAttID = spell.specialAttackID or spell.specialAttack | |||
if spAttID ~= nil then | |||
local spAtt = Attacks.getAttackByID(spAttID) | |||
local interval = spAtt.attackInterval | |||
local hits = spAtt.attackCount ~= nil and spAtt.attackCount or 1 | |||
if interval ~= nil and hits > 1 then | |||
local intervalTable = {} | |||
table.insert(intervalTable, '<br/>(' .. Shared.round(interval / 1000, 2, 2) .. 's delay between attacks.') | |||
if hits > 2 then | |||
table.insert(intervalTable, ' ' .. Shared.round(interval * (hits - 1) / 1000, 2, 2) .. 's total duration.') | |||
end | |||
table.insert(intervalTable, ')') | |||
row.tag('td'):wikitext(table.concat(intervalTable)) | |||
end | |||
end | |||
if includeExperience then | |||
local xp = spell.baseExperience | |||
if xp == nil or xp == 0 then | |||
row.tag('td'):wikitext('N/A') | |||
:addClass('table-na') | |||
else | |||
row.tag('td'):wikitext(xp) | |||
:addClass('text-align', 'right') | |||
end | |||
end | |||
row.tag('td'):wikitext(p._getSpellRunes(spell)) | |||
:css('text-align', 'center') | |||
if includeItems then | |||
row.tag('td'):wikitext(p._getSpellItems(spell)) | |||
:css('text-align', 'center') | |||
end | |||
end | end | ||
return tostring(html) | |||
return | |||
end | end | ||
end | end |
edits