FANDOM


local p = {}
 
local formatNum = require( 'Module:FormatNum' ).formatNum
 
-- Add a record here in the order you wish the troops to appear
p.troops = {
   'barbarian',
   'pumpkinbarbarian',
   'archer',
   'giant',
   'battleram',
   'giantskeleton',
   'goblin',
   'wallbreaker',
   'balloon',
   'wizard',
   'icewizard',
   'healer',
   'dragon',
   'pekka',
   'babydragon',
   'miner',
   'minion',
   'hogrider',
   'valkyrie',
   'golem',
   'witch',
   'lavahound',
   'bowler'
}
 
p.troopData = {
   ['barbarian'] = {
      ['name']          = 'Barbarian',
      ['resource']      = 'Elixir',
      ['housing space'] = 1,
      ['imagenum']      = {  1,     1,      3,      3,       5,       6,       7 },
      ['hitpoints']     = { 45,    54,     65,     78,      95,     110,     125 },
      ['dps']           = {  8,    11,     14,     18,      23,      26,      30 },
      ['training cost'] = { 25,    40,     60,    100,     150,     200,     250 },
      ['research cost'] = {  0, 50000, 150000, 500000, 1500000, 4500000, 6000000 },
      },
    ['pumpkinbarbarian'] = {
      ['name']          = 'Pumpkin Barbarian',
      ['resource']      = 'Elixir',
      ['housing space'] = 1,
      ['imagenum']      = {  1,     1,      1,      1,       1,       1,       1 },
      ['hitpoints']     = { 60,    72,     87,     104,      127,     146,     167 },
      ['dps']           = {  8,    11,     14,     18,      23,      26,      30 },
      ['training cost'] = { 25,    40,     60,    100,     150,     200,     250 },
      ['research cost'] = {  0,     0,  0,  0,  0,  0,  0 },
      },
   ['archer'] = {
      ['name']          = 'Archer',
      ['resource']      = 'Elixir',
      ['housing space'] = 1,
      ['imagenum']      = {  1,     1,      3,      3,       5,       6,       7 },
      ['hitpoints']     = { 20,    23,     28,     33,      40,      44,      48 },
      ['dps']           = {  7,     9,     12,     16,      20,      22,      25 },
      ['training cost'] = { 50,    80,    120,    200,     300,     400,     500 },
      ['research cost'] = {  0, 50000, 250000, 750000, 2250000, 6000000, 7500000 },
   },
   ['giant'] = {
      ['name']          = 'Giant',
      ['resource']      = 'Elixir',
      ['housing space'] = 5,
      ['imagenum']      = {   1,      1,      3,      3,       5,       6,       7,       8 },
      ['hitpoints']     = { 300,    360,    430,    520,     670,     940,    1100,    1260 },
      ['dps']           = {  11,     14,     19,     24,      31,      43,      50,      57 },
      ['training cost'] = { 250,    750,   1250,   1750,    2250,    3000,    3500,    4000 },
      ['research cost'] = {   0, 100000, 250000, 750000, 2250000, 5000000, 6000000, 9500000 },
      },
    ['battleram'] = {
      ['name']          = 'Battle Ram',
      ['resource']      = 'Elixir',
      ['housing space'] = 4,
      ['imagenum']      = {1,1,1,1,1,1,1,1,1,1,1},
      ['hitpoints']     = {90,111,132,153,174,195,216,237,258,279,300},
      ['dps']           = {115,142,168,195,222,249,276,303,330,357,384},
      ['training cost'] = {250,250,250,250,250,250,250,250,250,250,250},
      ['research cost'] = {0,0,0,0,0,0,0,0,0,0,0},
   },
   ['giantskeleton'] = {
      ['name']          = 'Giant Skeleton',
      ['resource']      = 'Elixir',
      ['housing space'] = 25,
      ['imagenum']      = {   1,      1,      1,      1,       1,       1,       1,       1 },
      ['hitpoints']     = { 750,    900,    1075,    1300,     1675,     2350,    2750,    3150 },
      ['dps']           = {  11,     14,     19,     24,      31,      43,      50,      57 },
      ['training cost'] = { 250,    750,   1250,   1750,    2250,    3000,    3500,    4000 },
      ['research cost'] = {   0, 0, 0,  0,  0,  0,  0,  0},
      },
   ['goblin'] = {
      ['name']          = 'Goblin',
      ['resource']      = 'Elixir',
      ['housing space'] = 1,
      ['imagenum']      = {  1,     1,      3,      3,       5,       6,        7 },
      ['hitpoints']     = { 25,    30,     36,     43,      52,      68,       74 },
      ['dps']           = { 11,    14,     19,     24,      32,      42,       52 },
      ['training cost'] = { 25,    40,     60,     80,     100,     150,      200 },
      ['research cost'] = {  0, 50000, 250000, 750000, 2250000, 4500000,  6750000 },
   },
   ['wallbreaker'] = {
      ['name']          = 'Wall Breaker',
      ['resource']      = 'Elixir',
      ['housing space'] = 2,
      ['imagenum']      = {    1,      1,      3,      3,       5,       6,     7 },
      ['hitpoints']     = {   20,     24,     29,     35,      42,      54,     62 },
      ['dps']           = {   12,     16,     24,     32,      46,      60,     78 },
      ['training cost'] = { 1000,   1500,   2000,   2500,    3000,    3500,     4000 },
      ['research cost'] = {    0, 100000, 250000, 750000, 2000000, 6000000,     9000000 },
   },
   ['balloon'] = {
      ['name']          = 'Balloon',
      ['resource']      = 'Elixir',
      ['housing space'] = 5,
      ['imagenum']      = {    1,      1,      3,       3,       5,       6,       7 },
      ['hitpoints']     = {  150,    180,    216,     280,     390,     545,     690 },
      ['dps']           = {   25,     32,     48,      72,     108,     162,     198 },
      ['training cost'] = { 2000,   2500,   3000,    3500,    4000,    4500,    5000 },
      ['research cost'] = {    0, 150000, 450000, 1350000, 2500000, 6000000, 9500000 },
   },
   ['wizard'] = {
      ['name']          = 'Wizard',
      ['resource']      = 'Elixir',
      ['housing space'] = 4,
      ['imagenum']      = {    1,      1,      3,       3,       5,       6,       7,       8 },
      ['hitpoints']     = {   75,     90,    108,     130,     156,     175,     190,        210 },
      ['dps']           = {   50,     70,     90,     125,     170,     185,     200,        215 },
      ['training cost'] = { 1500,   2000,   2500,    3000,    3500,    4000,    4500,        5000 },
      ['research cost'] = {    0, 150000, 450000, 1350000, 2500000, 5000000, 7000000,        9000000 },
   },
   ['icewizard'] = {
      ['name']          = 'Ice Wizard',
      ['resource']      = 'Elixir',
      ['housing space'] = 4,
      ['imagenum']      = {    1,       1,      1,      1,      1,      1,      1 },
      ['hitpoints']     = {  116,   130,    144,    158,    172,    186,    200 },
      ['dps']           = {  116,   130,    144,    158,    172,    186,    200 },
      ['training cost'] = { 1500,   1500,   1500,   1500,   1500,   1500,   1500 },
      ['research cost'] = {    0,   0,  0,  0,  0,  0,  0 },
   },
   ['healer'] = {
      ['name']          = 'Healer',
      ['resource']      = 'Elixir',
      ['housing space'] = 14,
      ['imagenum']      = {    1,      1,       3,       3,     5 },
      ['hitpoints']     = {  500,    600,     840,    1200,     1500 },
      ['dps']           = {    0,      0,       0,       0,     0 },
      ['training cost'] = { 5000,   6000,    8000,   10000,     15000 },
      ['research cost'] = {    0, 750000, 1500000, 3000000,     9500000 },
   },
   ['dragon'] = {
      ['name']          = 'Dragon',
      ['resource']      = 'Elixir',
      ['housing space'] = 20,
      ['imagenum']      = {     1,       2,       3,       4,       5,       6 },
      ['hitpoints']     = {  1900,    2100,    2300,    2600,    2900,    3200 },
      ['dps']           = {   140,     160,     180,     210,     240,     270 },
      ['training cost'] = { 25000,   29000,   33000,   37000,   42000,   46000 },
      ['research cost'] = {     0, 2000000, 3000000, 5000000, 7000000, 9000000 },
   },
   ['pekka'] = {
      ['name']          = 'P.E.K.K.A',
      ['resource']      = 'Elixir',
      ['housing space'] = 25,
      ['imagenum']      = {     1,       2,       3,       4,       5,      6 },
      ['hitpoints']     = {  2800,    3100,    3500,    4000,    4500,      5100 },
      ['dps']           = {   240,     270,     310,     360,     410,      470 },
      ['training cost'] = { 28000,   32000,   36000,   40000,   45000,      50000 },
      ['research cost'] = {     0, 3000000, 5000000, 6000000, 7500000,      10000000 },
   },
  ['babydragon'] = {
      ['name']          = 'Baby Dragon/Home Village',
      ['resource']      = 'Elixir',
      ['housing space'] = 10,
      ['imagenum']      = {     1,       1,       3,       4,       5 },
      ['hitpoints']     = {  1200,    1300,    1400,    1500,    1600 },
      ['dps']           = {    75,      85,      95,     105,     115 },
      ['training cost'] = { 15000,   16000,   17000,   18000,   19000 },
      ['research cost'] = {     0, 5000000, 6000000, 7000000, 8000000 },
   },
   ['miner'] = {
      ['name']          = 'Miner',
      ['resource']      = 'Elixir',
      ['housing space'] = 5,
      ['imagenum']      = {     1,       1,       3,       3,       5 },
      ['hitpoints']     = {   550,     610,     670,     730,       800 },
      ['dps']           = {    80,      88,      96,     104,       112 },
      ['training cost'] = {  4200,    4800,    5200,    5600,       6000 },
      ['research cost'] = {     0, 6000000, 7000000, 8000000, 9500000 },
   },
   ['minion'] = {
      ['name']          = 'Minion',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 2,
      ['imagenum']      = {  1,     1,     3,     3,     5,      6,      7 },
      ['hitpoints']     = { 55,    60,    66,    72,    78,     84,     90 },
      ['dps']           = { 35,    38,    42,    46,    50,     54,     58 },
      ['training cost'] = {  6,     7,     8,     9,    10,     11,     12 },
      ['research cost'] = {  0, 10000, 20000, 30000, 40000, 100000, 140000 },
   },
   ['hogrider'] = {
      ['name']          = 'Hog Rider',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 5,
      ['imagenum']      = {   1,     1,     3,     3,     5,      6,      7 },
      ['hitpoints']     = { 270,   312,   360,   415,   480,    590,    700 },
      ['dps']           = {  60,    70,    80,    92,   105,    118,    135 },
      ['training cost'] = {  40,    45,    52,    58,    65,     90,    115 },
      ['research cost'] = {   0, 20000, 30000, 40000, 50000, 100000, 150000 },
   },
   ['valkyrie'] = {
      ['name']          = 'Valkyrie',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 8,
      ['imagenum']      = {   1,     1,     3,     3,      5,   6 },
      ['hitpoints']     = { 750,   800,   850,   900,   1100,   1200 },
      ['dps']           = {  94,   106,   119,   133,    148,   163 },
      ['training cost'] = {  70,   100,   130,   160,    190,   220 },
      ['research cost'] = {   0, 50000, 60000, 70000, 110000,   150000 },
   },
   ['golem'] = {
      ['name']          = 'Golem',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 30,
      ['imagenum']      = {    1,     1,     3,     3,     5,      6,   7 },
      ['hitpoints']     = { 4500,  5000,  5500,  6000,  6300,   6600,   6900 },
      ['dps']           = {   38,    42,    46,    50,    54,     58,   62 },
      ['training cost'] = {  450,   525,   600,   675,   750,    825,   900 },
      ['research cost'] = {    0, 60000, 70000, 80000, 90000, 150000,   200000 },
   },
   ['witch'] = {
      ['name']          = 'Witch',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 12,
      ['imagenum']      = {   1,     1,      3 },
      ['hitpoints']     = { 270,   300,    330 },
      ['dps']           = {  50,    60,     70 },
      ['training cost'] = { 250,   350,    450 },
      ['research cost'] = {   0, 75000, 160000 },
   },
   ['lavahound'] = {
      ['name']          = 'Lava Hound',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 30,
      ['imagenum']      = {    1,     1,     3,      4 },
      ['hitpoints']     = { 5700,  6200,  6700,   7200 },
      ['dps']           = {   10,    12,    14,     16 },
      ['training cost'] = {  390,   450,   510,    570 },
      ['research cost'] = {    0, 60000, 70000, 150000 },
   },
['bowler'] = {
      ['name']          = 'Bowler',
      ['resource']      = 'Dark Elixir',
      ['housing space'] = 6,
      ['imagenum']      = {   1,      1,      3 },
      ['hitpoints']     = { 290,    310,    350 },
      ['dps']           = {  65,     75,     85 },
      ['training cost'] = { 130,    150,    170 },
      ['research cost'] = {   0, 120000, 200000 },
   },
}
 
function p.troopStatistics( troopName, statistic, level, format, raw )
   local retVal
 
   troopName = string.lower( troopName or '' )
   statistic = string.lower( statistic or '' )
   level     = level or 0
   format    = not ( not format )
 
   -- Remove spaces and punctuation from troop name
   troopName = string.gsub( string.gsub( troopName, '%s+', '' ), '%p+', '' )
 
   if not p.troopData[ troopName ] then
      retVal = ''
   elseif not p.troopData[ troopName ][ statistic ] then
      retVal = ''
   else
      retVal = p.troopData[ troopName ][ 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
      if raw then
         return retVal
      else
         retVal = '{' .. table.concat( retVal, ',' ) .. '}'
      end
   end
 
   return retVal
end
 
function p.troopImage( troopName, level, size )
   local name   = p.troopStatistics( troopName, 'name' )
 
   if name == '' then
      return ''
   end
 
   local levels = p.troopStatistics( troopName, 'imagenum', level, nil, true )
 
   if type( levels ) == 'table' then
      local images = {}
 
      for k, v in pairs( levels ) do
         table.insert( images, '[[File:' .. name .. v .. '.png|' ..
            ( size and size or '100px' ) .. '|link=' .. name .. ']]' )
      end
 
      return table.concat( images )
   elseif levels > 0 then
      return '[[File:' .. name .. levels .. '.png|' ..
         ( size and size or '100px' ) .. '|link=' .. name .. ']]'
   else
      return ''
   end
end
 
function p.main( frame )
   local troopName = frame.args[ 'troop' ] 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 ]
   local size      = frame.args[ 'size' ] or frame.args[ 4 ]
 
   if troopName == '' then troopName = nil end
   if statistic == '' then statistic = nil end
   if format == '' then format = nil end
   if size == '' then size = nil end
 
   if statistic == 'image' then
      return frame:preprocess( p.troopImage( troopName, level, size ) )
   end
 
   return p.troopStatistics( troopName, statistic, level, format )
end
 
return p

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.