Files

19 lines
704 B
Luau

--!strict
local Types = require(script.Parent.Types)
local Scoring = {}
function Scoring.new(state: Instance, onAdd: ((Types.Side, number, string?, Player?) -> ())?, finalMultiplier: number?): Types.Scoring
local score: {[Types.Side]: number} = {Blue = 0, Orange = 0}
state:SetAttribute("BlueScore", 0)
state:SetAttribute("OrangeScore", 0)
return {
add = function(side, points, reason, credit)
if state:GetAttribute("RoundStage") == "FinalPush" then points *= finalMultiplier or 1 end
score[side] += points
state:SetAttribute(side .. "Score", score[side])
if onAdd then onAdd(side, points, reason, credit) end
end,
get = function(side) return score[side] end,
}
end
return Scoring