Module:Rounds: Difference between revisions
Jump to navigation
Jump to search
saving progress |
saving progress |
||
| Line 33: | Line 33: | ||
else return 0.02 end | else return 0.02 end | ||
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 | |||
} | } | ||
| Line 39: | Line 66: | ||
local text = {} | local text = {} | ||
for i, group in ipairs(groups) do | for i, group in ipairs(groups) do | ||
local timing = (group. | 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>", | text[i] = sFormat("<span class='explain' title='%s'>%s%s%s%s ×%i</span>", | ||
timing, | timing, | ||
| Line 45: | Line 72: | ||
group.camo and data.bloonName.Camo or "", | group.camo and data.bloonName.Camo or "", | ||
group.regrow and data.bloonName.regrow or "", | group.regrow and data.bloonName.regrow or "", | ||
data.bloonName[group. | data.bloonName[group.bloon], | ||
group. | group.count) | ||
if highlightType == group. | if highlightType == group.bloon then text[i] = sFormat("'''%s'''", text[i]) end | ||
end | end | ||
return text | return text | ||
| Line 57: | Line 84: | ||
for i, group in ipairs(groups) do | for i, group in ipairs(groups) do | ||
if roundNumber < data.freeplayRoundStart then | if roundNumber < data.freeplayRoundStart then | ||
if data.moabLayerRbe[group. | if data.moabLayerRbe[group.bloon] then | ||
rbe = rbe + (((data.moabLayerRbe[group. | rbe = rbe + (((data.moabLayerRbe[group.bloon] * moabHealthRule) + data.moabChildrenRbe[group.bloon]) * group.count) | ||
else | else | ||
rbe = rbe + (data.bloonRbe[group. | rbe = rbe + (data.bloonRbe[group.bloon] * group.count) | ||
end | end | ||
else | else | ||
| Line 75: | Line 102: | ||
for i, group in ipairs(groups) do | for i, group in ipairs(groups) do | ||
if roundNumber < data.freeplayRoundStart then | if roundNumber < data.freeplayRoundStart then | ||
cash = cash + (data.bloonValue[group. | cash = cash + (data.bloonValue[group.bloon] * group.count) | ||
else | else | ||
cash = cash + (data.bloonValueFreeplay[group.bloon] * group.count) | cash = cash + (data.bloonValueFreeplay[group.bloon] * group.count) | ||
| Line 88: | Line 115: | ||
local tConcat = table.concat | local tConcat = table.concat | ||
local lang = mw.language.new("en") | local lang = mw.language.new("en") | ||
local rounds = mw.loadJsonData("Module: | local rounds = mw.loadJsonData("Module:Rounds/" .. roundSet)["rounds"] | ||
local totalRbe, totalCashFromPops, totalCashFromRoundEnds, totalXp = 0, 0, 0, 0 | local totalRbe, totalCashFromPops, totalCashFromRoundEnds, totalXp = 0, 0, 0, 0 | ||
| Line 145: | Line 172: | ||
p["BTD5 full"] = function(frame) | p["BTD5 full"] = function(frame) | ||
return full(BTD5, frame.args[1], frame.args["collapsed"], true, false, | return full(BTD5, frame.args[1], frame.args["collapsed"], true, false, | ||
frame.args["start round"], frame.args["end round"], | tonumber(frame.args["start round"]), tonumber(frame.args["end round"]), | ||
frame.args["cash per pop"], 99, {}, | tonumber(frame.args["cash per pop"]), 99, {}, | ||
frame.args["ceramic health"], frame.args["moab health"]) | 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 | end | ||
p["BTD6 full"] = function(frame) | p["BTD6 full"] = function(frame) | ||
return full(BTD6, frame.args[1], frame.args["collapsed"], true, true, | return full(BTD6, frame.args[1], frame.args["collapsed"], true, true, | ||
frame.args["start round"], frame.args["end round"], | tonumber(frame.args["start round"]), tonumber(frame.args["end round"]), | ||
frame.args["cash per pop"], 100, {}, | tonumber(frame.args["cash per pop"]), 100, {}, | ||
frame.args["ceramic health"], frame.args["moab health"]) | tonumber(frame.args["ceramic health"]), tonumber(frame.args["moab health"])) | ||
end | end | ||
return p | return p | ||
Revision as of 10:49, 22 July 2025
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 getGroupNames(data, groups, highlightType, highlightMod)
local sFormat = string.format
local text = {}
for i, group in ipairs(groups) do
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
end
return text
end
local function getTotalRbeOfGroups(data, groups, roundNumber, ceramicHealthRule, moabHealthRule)
local rbe = 0
for i, group in ipairs(groups) do
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
end
end
return rbe
end
local function getTotalCashOfGroups(data, groups, roundNumber)
local cash = 0
for i, group in ipairs(groups) do
if roundNumber < data.freeplayRoundStart then
cash = cash + (data.bloonValue[group.bloon] * group.count)
else
cash = cash + (data.bloonValueFreeplay[group.bloon] * group.count)
end
end
return 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("Module:Rounds/" .. roundSet)["rounds"]
local totalRbe, totalCashFromPops, totalCashFromRoundEnds, totalXp = 0, 0, 0, 0
-- create table header
local tableHeader = {
sFormat([=[{|class="wikitable sortable mw-collapsible %s" style="text-align:center"
!№
!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 rbe = getTotalRbeOfGroups(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(getGroupNames(BTD5, groups), "<br>"), 0.0, 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