Log inGet started
World

Warfront: Real-Time Strategy Skirmish Kit

README.md

skirmishVictory

The six ways to win a strategy skirmish, as pure rules: no entities, no engine calls, nothing synced. Your game reads its own match a few times a second, hands the judge a small state table, and the judge says who won and why, plus the objective line each side should see.

local Victory = require("skirmishVictory.rules")
local judge = Victory.new({ victory = "kingOfTheHill", hillSeconds = 90 }, { teams = { 1, 2 } })

-- every quarter second or so, on the machine that runs the match:
local winner, reason, code = judge:step(dt, {
	time = secondsSinceTheFightBegan,
	teams = {
		[1] = { units = 12, workers = 5, buildings = 3, townHalls = 1, heroes = 0, everBuilt = true, gathered = 840 },
		[2] = { units = 9, workers = 4, buildings = 2, townHalls = 1, heroes = 0, everBuilt = true, gathered = 610 },
	},
	hill = { [1] = 3, [2] = 0 },   -- units standing in the centre zone
})
if winner then print(winner, reason) end   -- 0 is a draw
local line = judge:objective(state, 1)       -- { label = "King of the Hill", text = "Centre yours · you 0:41 · enemy 0:00 / 1:30" }

The six rules

victoryWins when
conquestevery enemy building is destroyed (a side that never built is not beaten by having none)
annihilationevery enemy unit and building is gone
regicidethe enemy hero dies while yours lives
kingOfTheHilla side holds the centre alone for hillSeconds in total
treasurya side gathers treasuryGoal gold and wood first
survivalthe defender (opts.defender, the first team by default) still has a town hall when survivalSeconds run out

Victory.ORDER lists them in menu order; Victory.describe(code, "won" | "lost" | "watch", cfg, names) gives the end line from either side's point of view.

Where it comes from

It is the rules half of Warfront, the RTS skirmish in the world "Warfront: Real-Time Strategy Skirmish Kit" (rtsSkirmishKit), split out so other strategy games can use it on its own. rtsSkirmishKit's rtsSkirmishKit.victory forwards here.