FANDOM


local p = {}
 
local formatNum = require( 'Module:FormatNum' ).formatNum
 
-- Add a record here in the order you wish the spells to appear
p.spells = {
   'lightning',
   'santassurprise',
   'healing',
   'rage',
   'jump',
   'freeze',
   'clone',
   'poison',
   'earthquake',
   'haste',
   'skeleton',
   'bat'
}
 
p.spellData = {
   ['lightning'] = {
      ['name']          = 'Lightning Spell',
      ['resource']      = 'Elixir',
      ['housing space'] = 2,
      ['total damage']  = {   300,    360,    420,     480,     540,     600,     660 },
      ['creation cost'] = { 15000,  16500,  18000,   20000,   22000,   24000,   26000 },
      ['research cost'] = {     0, 200000, 500000, 1000000, 2000000, 6000000, 8000000 },
   },
   ['santassurprise'] = {
      ['name']          = 'Santa\'s Surprise',
      ['resource']      = 'Elixir',
      ['housing space'] = 2,
      ['total damage']  = {   900 },
      ['creation cost'] = { 19000 },
      ['research cost'] = {     0 },
   },
   ['healing'] = {
      ['name']          = 'Healing Spell',
      ['resource']      = 'Elixir',
      ['housing space'] = 2,
      ['total healing'] = {   600,    800,   1000,    1200,    1400,    1600,   1800,   2000 },
      ['creation cost'] = { 15000,  16500,  18000,  19000,   21000,   23000,   25000,  27000 },
      ['research cost'] = {     0, 300000, 600000, 1200000, 2000000, 4000000,   6000000,    14000000 },
   },
   ['rage'] = {
      ['name']          = 'Rage Spell',
      ['resource']      = 'Elixir',
      ['housing space'] = 2,
      ['damage boost']  = {   1.3,    1.4,    1.5,     1.6,     1.7,    1.8 },
      ['speed boost']   = {    20,     22,     24,      26,      28,    30 },
      ['creation cost'] = { 20000,  22000,  24000,   26000,   28000,    30000 },
      ['research cost'] = {     0, 450000, 900000, 1800000, 3000000,    11000000 },
   },
   ['jump'] = {
      ['name']          = 'Jump Spell',
      ['resource']      = 'Elixir',
      ['housing space'] = 2,
      ['duration']      = {    20,      40,      60,    80 },
      ['creation cost'] = { 23000,   27000,   31000,    32000 },
      ['research cost'] = {     0, 3000000, 6000000,    13000000 },
   },
   ['freeze'] = {
      ['name']          = 'Freeze Spell',
      ['resource']      = 'Elixir',
      ['housing space'] = 1,
      ['duration']      = {     2.5,    3,     3.5,    4,       4.5,  5,    5.5 },
      ['creation cost'] = { 6000,  7000,    8000,   9000,   10000,   11000, 12000 },
      ['research cost'] = {     0, 3000000, 4000000, 5000000, 7000000, 9500000, 11000000 },
   },
   ['clone'] = {
      ['name']          = 'Clone Spell',
      ['resource']      = 'Elixir',
      ['housing space'] = 3,
      ['cloned capacity']= {   18,      21,      24,      27,   30 },
      ['creation cost'] = { 28000,   29500,     31000,   32500,   34000 },
      ['research cost'] = {     0, 4000000,     6000000, 8000000, 10000000 },
   },
   ['poison'] = {
      ['name']                 = 'Poison Spell',
      ['resource']             = 'Dark Elixir',
      ['housing space']        = 1,
      ['speed decrease']       = { 0.26,   0.3,  0.34,  0.38,    0.4,   0.42 },
      ['attack rate decrease'] = { 0.35,   0.4,  0.45,   0.5,   0.55,   0.6 },
      ['max dps']              = {   90,   115,   145,   180,    220,   260 },
      ['creation cost']        = {   95,   110,   125,   140,    155,   170 },
      ['research cost']        = {    0, 25000, 50000, 75000, 150000,   200000 },
   },
   ['earthquake'] = {
      ['name']          = 'Earthquake Spell',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 1,
      ['damage']        = {  0.145,  0.17,  0.21,  0.25, 0.29 },
      ['creation cost'] = {   125,   140,   160,   180, 200 },
      ['research cost'] = {     0, 30000, 60000, 90000, 120000 },
   },
   ['haste'] = {
      ['name']           = 'Haste Spell',
      ['resource']       = 'Dark Elixir',
      ['housing space']  = 1,
      ['duration']       = { 10,    15,    20,     25,  30 },
      ['speed increase'] = { 28,    34,    40,     46,  50 },
      ['creation cost']  = { 80,    100,    120,     140,   160 },
      ['research cost']  = {  0, 40000, 80000, 100000,  120000 },
   },
   ['skeleton'] = {
      ['name']           = 'Skeleton Spell',
      ['resource']       = 'Dark Elixir',
      ['housing space']  = 1,
      ['skeletons generated'] = { 10,    11,    12,     13, 14, 15, 16  },
      ['creation cost']  = { 110,    120,   130,     140,   150,    160,    170 },
      ['research cost']  = {  0, 50000, 75000, 100000,  125000, 150000, 250000 },
   },
    ['bat'] = {
      ['name']           = 'Bat Spell',
      ['resource']       = 'Dark Elixir',
      ['housing space']  = 1,
      ['bats generated'] = { 7,    9,    11,     16, 21  },
      ['creation cost']  = { 110,    120,   130,     140,   150 },
      ['research cost']  = {  0, 60000, 80000, 120000,  160000 },
   },
}
function p.spellStatistics( spellName, statistic, level, format )
   local retVal
 
   spellName = string.lower( spellName or '' )
   statistic = string.lower( statistic or '' )
   level     = level or 0
   format    = not ( not format )
 
   -- Remove spaces and punctuation from spell name
   spellName = string.gsub( string.gsub( spellName, '%s+', '' ), '%p+', '' )
 
   -- If the spell name has 'spell' at the end, remove that
   if string.sub( spellName, -5 ) == 'spell' then
      spellName = string.sub( spellName, 0, -6 )
   end
 
   if not p.spellData[ spellName ] then
      retVal = ''
   elseif not p.spellData[ spellName ][ statistic ] then
      retVal = ''
   else
      retVal = p.spellData[ spellName ][ statistic ]
 
      if type( retVal ) == 'table' and level ~= 0 then
         if not retVal[ level ] then
            retVal = 0
         else
            retVal = retVal[ level ]
         end
      end
   end
 
   if type( retVal ) == 'number' then
      if format then
         retVal = formatNum( retVal )
      end
   elseif type ( retVal ) == 'table' then
      retVal = '{' .. table.concat( retVal, ',' ) .. '}'
   end
 
   return retVal
end
 
function p.main( frame )
   local spellName = frame.args[ 'spell' ] or frame.args[ 1 ]
   local statistic = frame.args[ 'stat' ] or frame.args[ 2 ]
   local level     = tonumber( frame.args[ 'level' ] ) or tonumber( frame.args[ 3 ] )
   local format    = frame.args[ 'format' ] or frame.args[ 4 ]
 
   return p.spellStatistics( spellName, statistic, level, format )
end
 
return p
Community content is available under CC-BY-SA unless otherwise noted.