Anonymous

Module:Magic: Difference between revisions

From Melvor Idle
Added a spell damage column to Archaic & Standard spell books
(Added spell item cost to the spellbook table)
(Added a spell damage column to Archaic & Standard spell books)
Line 294: Line 294:
elseif stat == 'type' then
elseif stat == 'type' then
return p.getTypeString(spell.spellBook)
return p.getTypeString(spell.spellBook)
elseif stat == 'spellDamage' then
if spell.maxHit ~= undefined then
return spell.maxHit * 10
else
return 0
end
end
end
return spell[stat]
return spell[stat]
Line 535: Line 541:
end
end


function p._getSpellRow(spell, includeTypeColumn, includeItems)
function p._getSpellRow(spell, includeTypeColumn, includeItems, includeDamage)
     local spellBookIdx = p.spellBookIndex[spell.spellBook]
     local spellBookIdx = p.spellBookIndex[spell.spellBook]
     local spellBook = p.spellBooks[spellBookIdx]
     local spellBook = p.spellBooks[spellBookIdx]
Line 546: Line 552:
table.insert(rowPart, '||data-sort-value="' .. spellBookIdx .. '"| ' .. p.getSpellTypeLink(spell.spellBook))
table.insert(rowPart, '||data-sort-value="' .. spellBookIdx .. '"| ' .. p.getSpellTypeLink(spell.spellBook))
end
end
--11/01/22: Added base damage if requested
if includeDamage then
table.insert(rowPart, '||'..p._getSpellStat(spell, 'spellDamage'))
end
--8/20/21: Changed to just getting the spell's description outright
--8/20/21: Changed to just getting the spell's description outright
table.insert(rowPart, '|| ' .. p._getSpellStat(spell, 'description'))
table.insert(rowPart, '|| ' .. p._getSpellStat(spell, 'description'))
Line 584: Line 595:
end
end
end
end
-- Check to see if we want to show damage
local showDamage = spellBookID == 'archaic' or spellBookID == 'standard'
    
    
         local resultPart = {}
         local resultPart = {}
         table.insert(resultPart, '{|class="wikitable sortable"\r\n!colspan="2"| Spell')
         table.insert(resultPart, '{|class="wikitable sortable"\r\n!colspan="2"| Spell')
         table.insert(resultPart, '\r\n! Requirements')
         table.insert(resultPart, '\r\n! Requirements')
        if showDamage then
        table.insert(resultPart, '\r\n!Spell Dmg')
        end
         table.insert(resultPart, '\r\n!style="width:275px"| Description')
         table.insert(resultPart, '\r\n!style="width:275px"| Description')
         if spellBookID == 'altMagic' then
         if spellBookID == 'altMagic' then
Line 598: Line 615:


         for i, spell in ipairs(spells) do
         for i, spell in ipairs(spells) do
             table.insert(resultPart, p._getSpellRow(spell, false, hasItems))
             table.insert(resultPart, p._getSpellRow(spell, false, hasItems, showDamage))
         end
         end