Skip to content

How It Works

All game logic lives in Runtime/Core, which is plain C# with no reference to UnityEngine. Nothing changes a match directly. A player, human or computer, submits a command (PlayCardCommand, AttackCommand, EndPhaseCommand, SubmitChoiceCommand, ConcedeCommand). The match checks it against the rules, carries it out, and reports what happened as an ordered list of events (CardMovedEvent, StatChangedEvent, TurnStartedEvent and so on).

Everything else is built on those two streams:

  • The match screen plays the events back as animations, one at a time.
  • The computer opponent is just another source of commands.
  • Online play sends commands to the host and events back to the players.
  • Replays are the starting seed plus the list of commands.

Because the core is deterministic (whole numbers only, its own seeded random numbers, no dependence on frame time), the same seed and the same commands always produce the same match.

GameDefinition (assets you edit)
| RulesCompiler
v
Ruleset (plain data) ---> Match (state, rules, turn system)
^ |
commands| |events
| v
MatchHost (the only full copy of the state)
^ |
bytes, via | | bytes: what each player may see
IClientTransport| v IHostTransport
MatchClient (one per player)
^ |
commands | | view + events
| v
MatchInput <-- MatchPresenter --> BoardView, animators, HUD
  • GameDefinition and the assets it points to describe your game. At the start of a match RulesCompiler turns them into a Ruleset, plain data the core can run.
  • Match holds the GameState and runs commands against it.
  • MatchHost owns the only full copy of the state. It seats players, applies their commands, plays for computer seats, and after every command sends each player a ClientGameView: the position as that player is allowed to see it. Cards in a hidden zone, such as the opponent’s hand, are sent as a count only.
  • MatchClient is one player’s connection: their latest view and the commands open to them.
  • MatchPresenter shows one client’s side of the match. MatchInput turns clicks and drags into commands.

The same classes serve local and online play. Against the computer or in hotseat, the host and clients run on one device joined by LocalTransport, which still passes real bytes, so anything that works locally also works over a network.

Card abilities and the rules of the game itself (drawing a card each turn, losing at 0 life) are ability graphs: triggers, effects, targets, values and flow nodes wired together in the graph editor. When an event happens, every graph with a matching trigger is queued and run one step at a time. Between steps the game’s own rules react, so “deal 3 damage, then count the survivors” sees the creature already destroyed.

When a graph needs a player’s decision (“choose an enemy creature”), the match pauses, sends a ChoiceRequestedEvent, and accepts only the answer (or a concession) until it arrives. A paused match can be copied, saved and resumed like any other.

Every part sits behind an interface or a base class with virtual members, and one asset, MatchInstaller, decides which implementation is used for each. Your replacement lives in your own folder; you never edit kit code. See Extending the Kit.