Minigame Win Conditions
This document describes the data-driven win condition system used by the Games SDK runtime. Win conditions are evaluated while a match is in RUNNING state.
Win Rules
Rules are grouped, ordered by priority, and evaluated until the first group matches. Each group uses ALL or ANY logic for its conditions.
{
"winRules": {
"groups": [
{
"id": "time-limit",
"priority": 10,
"logic": "ALL",
"conditions": [
{ "type": "timer_elapsed", "params": { "seconds": "600" } }
]
},
{
"id": "score-cap",
"priority": 5,
"logic": "ANY",
"conditions": [
{ "type": "score_reached", "params": { "scoreId": "points", "value": "100" } }
]
}
]
}
}When a group matches, the match is closed with the reason win:<groupId>.
Condition Types
timer_elapsed
Trigger when the match runtime reaches a duration.
Params:
secondsordurationSecondsmsordurationMs
metric_reached
Compare a metric value set by scripts or systems.
Params:
metricIdvalueop(optional):gte(default),gt,lt,lte,eq
score_reached
Compare a score value.
Params:
scoreIdvaluesubjectId(optional, default leader)op(optional)
score_leader
Check the current leader for a score.
Params:
scoreIdvalue(optional)minLead(optional): required lead over second placeop(optional)
event_received
Check for a named event signal.
Params:
eventIdvalue(optional, default1)op(optional)
players_remaining
Shortcut for metric_reached on players_alive with lte default comparison.
Params:
value(optional, default1)
Scores and Metrics
Scores and metrics are updated via the match runtime (setScore, addScore, setMetric, addMetric) and can be used by win conditions. The signal API increments event:<id> metrics automatically.
Editor Hooks
- Load win rules from a JSON file:
/gameedit winrules load <file> - Define score definitions:
/gameedit score add <id> [name] [mode] [aggregation] [order]