Module:Rounds: Difference between revisions

mNo edit summary
mNo edit summary
Line 62: Line 62:
}
}


local function getGroupNames(data, groups, highlightType, highlightMod)
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
for i, group in ipairs(groups) do
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)
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>",
Line 75: Line 80:
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
Line 90: Line 89:
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)
Line 107: Line 99:
end
end
end
end
return text, rbe, cash * data.getCashModForRound(roundNumber)
return cash * data.getCashModForRound(roundNumber)
end
end


Line 137: Line 128:
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, 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>"), 0.0, 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