skirmishVictory.package
- .metadata139 B
- README.md2.1 KB
- package.yaml1.0 KB
- rules.module
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
victory | Wins when |
|---|---|
conquest | every enemy building is destroyed (a side that never built is not beaten by having none) |
annihilation | every enemy unit and building is gone |
regicide | the enemy hero dies while yours lives |
kingOfTheHill | a side holds the centre alone for hillSeconds in total |
treasury | a side gathers treasuryGoal gold and wood first |
survival | the 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.