Module:TowerDefenseWaves: Difference between revisions
From IdleOn MMO Wiki
imported>Kiokurashi No edit summary |
imported>Kiokurashi No edit summary |
||
Line 14: | Line 14: | ||
function p.generateWaves(frame) | function p.generateWaves(frame) | ||
local ret = "{{#tag:tabber|\n1-30=\n{{TDwaves/head|Waves}}\n" | local ret = "{{#tag:tabber|\n1-30=\n{{TDwaves/head|Waves}}\n" | ||
local countList = explode(frame.args.MonsterCount, ",") | local countList = tonumber.explode(frame.args.MonsterCount, ",") | ||
local skull = explode(frame.args.Skull, ",") | local skull = tonumber.explode(frame.args.Skull, ",") | ||
local size = explode(frame.args.Size, ",") | local size = tonumber.explode(frame.args.Size, ",") | ||
local color = explode(frame.args.Type, ",") | local color = tonumber.explode(frame.args.Type, ",") | ||
local waves = frame.args.MaxWave | local waves = tonumber.frame.args.MaxWave | ||
local baseHP = frame.args.BaseHealth | local baseHP = tonumber.frame.args.BaseHealth | ||
local sizeText = {"Null", "Zoomo", "Normo", "Largo", "Gigao", "last"} | local sizeText = {"Null", "Zoomo", "Normo", "Largo", "Gigao", "last"} | ||
local colorText = {"first", "Grey", "Red", "Blue", "Green", "Yellow", "Purple"} | local colorText = {"first", "Grey", "Red", "Blue", "Green", "Yellow", "Purple"} |
Revision as of 03:18, 29 March 2022
Documentation for this module may be created at Module:TowerDefenseWaves/doc
local p = {}
local function explode(list, delimiter)
if delimiter == nil then
delimiter = "%s"
end
t = {}
for str in string.gmatch(list, "([^" .. delimiter .. "]+)") do
table.insert(t, str)
end
return t
end
function p.generateWaves(frame)
local ret = "{{#tag:tabber|\n1-30=\n{{TDwaves/head|Waves}}\n"
local countList = tonumber.explode(frame.args.MonsterCount, ",")
local skull = tonumber.explode(frame.args.Skull, ",")
local size = tonumber.explode(frame.args.Size, ",")
local color = tonumber.explode(frame.args.Type, ",")
local waves = tonumber.frame.args.MaxWave
local baseHP = tonumber.frame.args.BaseHealth
local sizeText = {"Null", "Zoomo", "Normo", "Largo", "Gigao", "last"}
local colorText = {"first", "Grey", "Red", "Blue", "Green", "Yellow", "Purple"}
for i = 1, waves do
local wavePos = i % 30
local multi = math.floor(i / 30)
local waveSkull = math.min(skull[wavePos] + (2 * multi), 16)
local enemyNum = countList[wavePos] + (math.ceil(countList[wavePos] / 3) * multi)
local health = math.ceil(baseHP * (3 ^ (size[wavePos] - 2)) * ((3 + 0.3 * waveSkull)^waveSkull))
local sizeW = size[wavePos]
local coloreW = color[wavePos]
-- Ceil(BaseHP * (3 ^ (size - 2)) * ((3 + 0.3 * skull)^skull))
if((i > 1) and (wavePos == 1)) then ret = ret .. "\n{{!}}-{{!}}\n" .. i .. "-" .. (i + 29) .."=\n{{TDwaves/head|Waves}}\n" end
-- {{TDwaves/row|31|3|Skull2|Normo|Grey|52|156}}
ret = ret .. "{{TDwaves/row|" .. i .. "|" .. enemyNum .. "|Skull" .. waveSkull .. "|" .. sizeText[sizeW] .. "|" .. colorText[colorW] .. "|" .. health .. "|" .. (health * enemyNum) .. "}}\n";
end
ret = ret .. "}}\n"
return ret
end
return p