Module:Rounds: Difference between revisions

saving progress
 
mNo edit summary
 
(4 intermediate revisions by the same user not shown)
Line 5: Line 5:
Red = "Red", Blue = "Blue", Green = "Green", Yellow = "Yellow", Pink = "Pink", Black = "Black", White = "White",
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",
Zebra = "Zebra", Lead = "Lead", Rainbow = "Rainbow",Ceramic = "Ceramic",MOAB = "MOAB", BFB = "BFB", ZOMG = "ZOMG",
Camo = "Camo", Regrow = "Regen"
Camo = "Camo ", Regrow = "Regen "
},
},
bloonLink = {
bloonLink = {
Line 13: Line 13:
Rainbow = "[[Rainbow Bloon (BTD5)|Rainbow]]", Ceramic = "[[Ceramic Bloon (BTD5)|Ceramic]]", MOAB = "[[MOAB (BTD5)|MOAB]]",
Rainbow = "[[Rainbow Bloon (BTD5)|Rainbow]]", Ceramic = "[[Ceramic Bloon (BTD5)|Ceramic]]", MOAB = "[[MOAB (BTD5)|MOAB]]",
BFB = "[[BFB (BTD5)|BFB]]", ZOMG = "[[ZOMG (BTD5)|ZOMG]]",
BFB = "[[BFB (BTD5)|BFB]]", ZOMG = "[[ZOMG (BTD5)|ZOMG]]",
Camo = "[[Camo Bloon (BTD5)|Camo]]", Regrow = "[[Regen Bloon (BTD5)|Regen]]"
Camo = "[[Camo Bloon (BTD5)|Camo]] ", Regrow = "[[Regen Bloon (BTD5)|Regen]] "
},
},
bloonRbe = {
bloonRbe = {
Line 35: Line 35:
}
}


local function getGroupNames(data, groups, highlightType, highlightMod)
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 sFormat = string.format
local text = {}
local text = {}
local rbe = 0
local cash = 0
local duration = 0
for i, group in ipairs(groups) do
for i, group in ipairs(groups) do
local timing = (group.Count == 1 or group.Duration == 0) and sFormat("At: %gs", group.StartTime) or sFormat("Duration: %gs — %gs", group.StartTime, group.StartTime + group.Duration)
-- 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>",
text[i] = sFormat("<span class='explain' title='%s'>%s%s%s%s ×%i</span>",
timing,
timing,
Line 45: Line 78:
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.Bloon],
data.bloonName[group.bloon],
group.Count)
group.count)
if highlightType == group.Bloon then text[i] = sFormat("'''%s'''", text[i]) end
if highlightType == group.bloon then text[i] = sFormat("'''%s'''", text[i]) end
end
return text
-- rbe
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 roundNumber < data.freeplayRoundStart then
if data.moabLayerRbe[group.Bloon] then
if data.moabLayerRbe[group.bloon] then
rbe = rbe + (((data.moabLayerRbe[group.Bloon] * moabHealthRule) + data.moabChildrenRbe[group.Bloon]) * group.Count)
rbe = rbe + (((data.moabLayerRbe[group.bloon] * moabHealthRule) + data.moabChildrenRbe[group.bloon]) * group.count)
else
else
rbe = rbe + (data.bloonRbe[group.Bloon] * group.Count)
rbe = rbe + (data.bloonRbe[group.bloon] * group.count)
end
end
else
else
-- todo
end
end
end
-- cash
return rbe
end
 
local function getTotalCashOfGroups(data, groups, roundNumber)
local cash = 0
for i, group in ipairs(groups) do
if roundNumber < data.freeplayRoundStart then
if roundNumber < data.freeplayRoundStart then
cash = cash + (data.bloonValue[group.Bloon] * group.Count)
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)
end
end
-- duration
if group.start + group.duration > duration then duration = group.start + group.duration end
end
end
return text, rbe, duration, cash * data.getCashModForRound(roundNumber)
return cash * data.getCashModForRound(roundNumber)
end
end


Line 88: Line 110:
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:BTD5 rounds/" .. roundSet)["Rounds"]
local rounds = mw.loadJsonData("JSON:Rounds/" .. roundSet)["rounds"]
local totalRbe, totalCashFromPops, totalCashFromRoundEnds, totalXp = 0, 0, 0, 0
local totalRbe, totalCashFromPops, totalCashFromRoundEnds, totalXp = 0, 0, 0, 0
Line 94: Line 116:
-- create table header
-- create table header
local tableHeader = {
local tableHeader = {
sFormat([=[{|class="wikitable sortable mw-collapsible %s" style="text-align:center"
sFormat([=[{|class="wikitable sortable mw-collapsible center-col-3 center-col-4 center-col-5 %s"
!№
!№
!class="unsortable"|[[Bloon]] groups
!class="unsortable"|[[Bloon]] groups
Line 110: Line 132:
for roundNumber, groups in ipairs(rounds) do
for roundNumber, groups in ipairs(rounds) do
local rbe = getTotalRbeOfGroups(data, groups, roundNumber, ceramicHealthRule, moabHealthRule)
local text, rbe, duration, cashFromPops = getStatsOfGroup(data, groups, roundNumber, ceramicHealthRule, moabHealthRule)
totalRbe = totalRbe + rbe
totalRbe = totalRbe + rbe
-- round number, duration, rbe, and total rbe are always included
-- round number, duration, rbe, and total rbe are always included
local row = {
local row = {
sFormat("|-\n!%i\n|%s||%gs||%s (%s)", roundNumber, tConcat(getGroupNames(BTD5, groups), "<br>"), 0.0, lang:formatNum(rbe), lang:formatNum(totalRbe))
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)
-- insert cash column (excluded in BTDB/BTDB2)
if useCash then
if useCash then
local cashFromPops = getTotalCashOfGroups(data, groups, roundNumber)-- * cashPerPopRule
--local cashFromPops = getTotalCashOfGroups(data, groups, roundNumber)-- * cashPerPopRule
totalCashFromPops = totalCashFromPops + cashFromPops
totalCashFromPops = totalCashFromPops + cashFromPops
totalCashFromRoundEnds = totalCashFromRoundEnds + baseCashPerRoundRule + roundNumber
totalCashFromRoundEnds = totalCashFromRoundEnds + baseCashPerRoundRule + roundNumber
Line 145: Line 167:
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