Skip to content

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.

json
{
  "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:

  • seconds or durationSeconds
  • ms or durationMs

metric_reached

Compare a metric value set by scripts or systems.

Params:

  • metricId
  • value
  • op (optional): gte (default), gt, lt, lte, eq

score_reached

Compare a score value.

Params:

  • scoreId
  • value
  • subjectId (optional, default leader)
  • op (optional)

score_leader

Check the current leader for a score.

Params:

  • scoreId
  • value (optional)
  • minLead (optional): required lead over second place
  • op (optional)

event_received

Check for a named event signal.

Params:

  • eventId
  • value (optional, default 1)
  • op (optional)

players_remaining

Shortcut for metric_reached on players_alive with lte default comparison.

Params:

  • value (optional, default 1)

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]