--!strict local Runtime = script.Parent.Parent local Types = require(Runtime.Types) local Common = require(Runtime.Common) local Kinds = require(game.ReplicatedStorage.Hunter.EventKinds) local Strings = require(game.ReplicatedStorage.Hunter.Strings) type Fighter = Types.Fighter local function start(ctx: Types.ModeContext): Types.ModeInstance local lifeActive, miniNumber = false, 0 local lifeEnds, nextMini = math.huge, ctx.liveAt + 2 local function runOneLife(members: {Player}, fighters: {Fighter}, now: number): boolean if lifeActive then local b, o = 0, 0 for _, f in fighters do if f.side == "Blue" then b += 1 else o += 1 end end if (b > 0 and o > 0) and now < lifeEnds then ctx.status(Strings.lifeActive(miniNumber, b, o, math.ceil(lifeEnds - now))) return false end local side: Types.Side? = if b == o then nil elseif b > o then "Blue" else "Orange" if side then ctx.scoring.add(side, 1, Kinds.MiniRoundEnded) end ctx.events.fire(Kinds.MiniRoundEnded, {side = side, index = miniNumber}) if ctx.scoring.get("Blue") >= 3 or ctx.scoring.get("Orange") >= 3 then return true end for _, p in members do ctx.bench(p) end lifeActive, nextMini = false, now + 4 end if now >= nextMini then ctx.balanceWaiting() end local ready: {Player} = {} local b, o = false, false for _, p in members do local c = p.Character local h = c and c:FindFirstChildOfClass("Humanoid") if not c or not c.PrimaryPart or not h or h.Health <= 0 then continue end table.insert(ready, p) if Common.sideOf(p) == "Blue" then b = true else o = true end end if b and o and now >= nextMini then for _, p in ready do ctx.deploy(p) end miniNumber += 1 lifeActive, lifeEnds = true, now + 45 ctx.status(Strings.lifeStart(miniNumber)) ctx.events.fire(Kinds.MiniRoundStarted, {index = miniNumber}) elseif not b or not o then ctx.status(Strings.lifeWaiting) else ctx.status(Strings.lifeNext(math.ceil(nextMini - now))) end return false end return Common.instance(ctx, { step = function(now, _, fighters) return runOneLife(ctx.members(), fighters, now) end, death = function(player) ctx.bench(player) end, }) end return {id = "OneLife", usesMap = true, start = start}