Module:Rounds
Jump to navigation
Jump to search
Documentation for this module may be created at Module:Rounds/doc
local p = {}
local BTD5 = {
bloonName = {
Red = "Red", Blue = "Blue", Green = "Green", Yellow = "Yellow", Pink = "Pink", Black = "Black", White = "White",
Zebra = "Zebra", Lead = "Lead", Rainbow = "Rainbow",Ceramic = "Ceramic",MOAB = "MOAB", BFB = "BFB", ZOMG = "ZOMG",
Camo = "Camo ", Regrow = "Regen "
},
bloonLink = {
Red = "[[Red Bloon (BTD5)|Red]]", Blue = "[[Blue Bloon (BTD5)|Blue]]", Green = "[[Green Bloon (BTD5)|Green]]",
Yellow = "[[Yellow Bloon (BTD5)|Yellow]]", Pink = "[[Pink Bloon (BTD5)|Pink]]", Black = "[[Black Bloon (BTD5)|Black]]",
White = "[[White Bloon (BTD5)|White]]", Zebra = "[[Zebra Bloon (BTD5)|Zebra]]", Lead = "[[Lead Bloon (BTD5)|Lead]]",
Rainbow = "[[Rainbow Bloon (BTD5)|Rainbow]]", Ceramic = "[[Ceramic Bloon (BTD5)|Ceramic]]", MOAB = "[[MOAB (BTD5)|MOAB]]",
BFB = "[[BFB (BTD5)|BFB]]", ZOMG = "[[ZOMG (BTD5)|ZOMG]]",
Camo = "[[Camo Bloon (BTD5)|Camo]] ", Regrow = "[[Regen Bloon (BTD5)|Regen]] "
},
bloonRbe = {
Red = 1, Blue = 2, Green = 3, Yellow = 4, Pink = 5, Black = 11,
White = 11, Zebra = 23, Lead = 23, Rainbow = 47, Ceramic = 104
},
moabLayerRbe = { MOAB = 200, BFB = 1500, ZOMG = 4000 },
moabChildrenRbe = { MOAB = 416, BFB = 1664, ZOMG = 6656 },
bloonValue = {
Red = 1, Blue = 2, Green = 3, Yellow = 4, Pink = 5, Black = 11, White = 11,
Zebra = 23, Lead = 23, Rainbow = 47, Ceramic = 95, MOAB = 381, BFB = 1525, ZOMG = 6101
},
freeplayRoundStart = 86,
getCashModForRound = function(roundNumber)
if roundNumber <= 50 then return 1.0
elseif roundNumber > 50 and roundNumber <= 60 then return 0.5
elseif roundNumber > 60 and roundNumber <= 85 then return 0.2
elseif roundNumber > 85 and roundNumber <= 100 then return 0.1
else return 0.02 end
end
}
local BMC = {
bloonName = {
Red = "Red", Blue = "Blue", Green = "Green", Yellow = "Yellow", Pink = "Pink", Black = "Black", White = "White",
Zebra = "Zebra", Lead = "Lead", Rainbow = "Rainbow",Ceramic = "Ceramic",MOAB = "MOAB", BFB = "BFB", ZOMG = "ZOMG",
DDT = "DDT", Camo = "Camo ", Regrow = "Regrow "
},
bloonLink = {
Red = "[[Red Bloon (BMC)|Red]]", Blue = "[[Blue Bloon (BMC)|Blue]]", Green = "[[Green Bloon (BMC)|Green]]",
Yellow = "[[Yellow Bloon (BMC)|Yellow]]", Pink = "[[Pink Bloon (BMC)|Pink]]", Black = "[[Black Bloon (BMC)|Black]]",
White = "[[White Bloon (BMC)|White]]", Zebra = "[[Zebra Bloon (BMC)|Zebra]]", Lead = "[[Lead Bloon (BMC)|Lead]]",
Rainbow = "[[Rainbow Bloon (BMC)|Rainbow]]", Ceramic = "[[Ceramic Bloon (BMC)|Ceramic]]", MOAB = "[[MOAB (BMC)|MOAB]]",
BFB = "[[BFB (BMC)|BFB]]", ZOMG = "[[ZOMG (BMC)|ZOMG]]", DDT = "[[DDT (BMC)|DDT]]",
Camo = "[[Camo Bloon (BMC)|Camo]] ", Regrow = "[[Regrow Bloon (BMC)|Regrow]] "
},
bloonRbe = {
Red = 1, Blue = 2, Green = 3, Yellow = 4, Pink = 5, Black = 11,
White = 11, Zebra = 23, Lead = 23, Rainbow = 47, Ceramic = 104
},
moabLayerRbe = { MOAB = 132, BFB = 990, ZOMG = 2640, DDT = 198 },
moabChildrenRbe = { MOAB = 416, BFB = 1664, ZOMG = 6656, DDT = 416 },
bloonValue = {
Red = 1, Blue = 2, Green = 3, Yellow = 4, Pink = 5, Black = 11, White = 11,
Zebra = 23, Lead = 23, Rainbow = 47, Ceramic = 95, MOAB = 381, BFB = 1525, ZOMG = 6101, DDT = 381
},
freeplayRoundStart = 31
}
local function getStatsOfGroup(data, groups, roundNumber, ceramicHealthRule, moabHealthRule, highlightType, highlightMod)
local sFormat = string.format
local text = {}
local rbe = 0
local cash = 0
local duration = 0
for i, group in ipairs(groups) do
-- group text
local timing = (group.count == 1 or group.duration == 0) and sFormat("At: %gs", group.start) or sFormat("Duration: %gs — %gs", group.start, group.start + group.duration)
text[i] = sFormat("<span class='explain' title='%s'>%s%s%s%s ×%i</span>",
timing,
group.fortified and data.bloonName.Fortified or "",
group.camo and data.bloonName.Camo or "",
group.regrow and data.bloonName.regrow or "",
data.bloonName[group.bloon],
group.count)
if highlightType == group.bloon then text[i] = sFormat("'''%s'''", text[i]) end
-- rbe
if roundNumber < data.freeplayRoundStart then
if data.moabLayerRbe[group.bloon] then
rbe = rbe + (((data.moabLayerRbe[group.bloon] * moabHealthRule) + data.moabChildrenRbe[group.bloon]) * group.count)
else
rbe = rbe + (data.bloonRbe[group.bloon] * group.count)
end
else
-- todo
end
-- cash
if roundNumber < data.freeplayRoundStart then
cash = cash + (data.bloonValue[group.bloon] * group.count)
else
cash = cash + (data.bloonValueFreeplay[group.bloon] * group.count)
end
-- duration
if group.start + group.duration > duration then duration = group.start + group.duration end
end
return text, rbe, duration, cash * data.getCashModForRound(roundNumber)
end
local function full(data, roundSet, collapsed, useCash, useXp, startRoundRule, endRoundRule, cashPerPopRule, baseCashPerRoundRule, cashPerRoundAdditions, ceramicHealthRule, moabHealthRule)
local sFormat = string.format
local tConcat = table.concat
local lang = mw.language.new("en")
local rounds = mw.loadJsonData("JSON:Rounds/" .. roundSet)["rounds"]
local totalRbe, totalCashFromPops, totalCashFromRoundEnds, totalXp = 0, 0, 0, 0
-- create table header
local tableHeader = {
sFormat([=[{|class="wikitable sortable mw-collapsible center-col-3 center-col-4 center-col-5 %s"
!№
!class="unsortable"|[[Bloon]] groups
!data-sort-type="number"|Duration
!data-sort-type="number"|[[RBE]]]=], collapsed and "mw-collapsed" or "")
}
if useCash then tableHeader[#tableHeader+1] = '!data-sort-type="currency"|[[Cash]]' end
if useXp then tableHeader[#tableHeader+1] = '!class="unsortable"|Base [[Experience|XP]]' end
-- add table header to output
local ret = {
tConcat(tableHeader, "\n")
}
for roundNumber, groups in ipairs(rounds) do
local text, rbe, duration, cashFromPops = getStatsOfGroup(data, groups, roundNumber, ceramicHealthRule, moabHealthRule)
totalRbe = totalRbe + rbe
-- round number, duration, rbe, and total rbe are always included
local row = {
sFormat("|-\n!%i\n|%s||%gs||%s (%s)", roundNumber, tConcat(text, "<br>"), duration, lang:formatNum(rbe), lang:formatNum(totalRbe))
}
-- insert cash column (excluded in BTDB/BTDB2)
if useCash then
--local cashFromPops = getTotalCashOfGroups(data, groups, roundNumber)-- * cashPerPopRule
totalCashFromPops = totalCashFromPops + cashFromPops
totalCashFromRoundEnds = totalCashFromRoundEnds + baseCashPerRoundRule + roundNumber
row[#row+1] = sFormat("$%s + $%s ($%s + $%s)", lang:formatNum(cashFromPops), lang:formatNum(baseCashPerRoundRule + roundNumber),
lang:formatNum(totalCashFromPops), lang:formatNum(totalCashFromRoundEnds))
end
-- insert xp column (included in BTD6/BTDB2)
if useXp then
local xp = data.getXpForRound(roundNumber)
totalXp = totalXp + xp
row[#row+1] = sFormat("%s (%s)", xp, totalXp)
end
-- add row
ret[roundNumber+1] = tConcat(row, "||")
end
ret[#ret+1] = "|}"
return tConcat(ret, "\n")
end
p["BTD5 full"] = function(frame)
return full(BTD5, frame.args[1], frame.args["collapsed"], true, false,
tonumber(frame.args["start round"]), tonumber(frame.args["end round"]),
tonumber(frame.args["cash per pop"]), 99, {},
tonumber(frame.args["ceramic health"]), tonumber(frame.args["moab health"]))
end
-- this is just for bloonprint hideout for now
p["BMC full"] = function(frame)
return full(BMC, frame.args[1], frame.args["collapsed"], false, false,
tonumber(frame.args["start round"]), tonumber(frame.args["end round"]),
0, 0, {},
tonumber(frame.args["ceramic health"]), tonumber(frame.args["moab health"]))
end
p["BTD6 full"] = function(frame)
return full(BTD6, frame.args[1], frame.args["collapsed"], true, true,
tonumber(frame.args["start round"]), tonumber(frame.args["end round"]),
tonumber(frame.args["cash per pop"]), 100, {},
tonumber(frame.args["ceramic health"]), tonumber(frame.args["moab health"]))
end
return p