Crisis Interaction
The Crisis Interaction system is an optional gameplay layer that adds template-based crisis creation, decision trees, collective contributions, and ambient interaction cards. The system is gated behind a feature flag — when disabled, only the legacy manual crisis creator is available.
Feature Flags
Two independent flags in src/lib/crises/featureFlag.ts gate the crisis system:
| Flag | Function | When false / absent | When true |
|---|---|---|---|
isCrisisInteractionEnabled() | Gates template-based creation, decision trees, collective contributions, ambient interaction cards | Only the legacy manual crisis creator is available; admin panel hides template-based UI | Template-based creation, decision trees, and interaction cards are available |
isAutoDisastersEnabled() | Gates the auto-disaster spawner | No automatic disaster spawning | Auto-disaster spawner runs on its schedule |
Both flags read from the gameState document (crisisInteractionEnabled and autoDisastersEnabled respectively). They are independent — you can have template-based crisis creation without auto-disasters, or vice versa.
Template-Based Crisis Creation
When isCrisisInteractionEnabled() is true, admins and players can create crises from pre-defined templates rather than crafting each crisis manually. Templates live in src/lib/crises/templates.ts and cover realistic scenarios:
- Economic shocks (recessions, inflation spikes, currency crises)
- Natural disasters (earthquakes, hurricanes, pandemics)
- Political crises (scandals, government shutdowns, diplomatic rows)
- Sector-specific disruptions (energy shocks, supply-chain breaks)
Each template defines:
| Field | Description |
|---|---|
effects | Flat or tick effects on state metrics (GDP, unemployment, inflation, etc.) |
durationTurns or durationByScope | How long the crisis lasts, optionally per scope |
interactionDefinition | Optional decision tree, collective contribution setup, and auto-resolve behavior |
When the flag is off, the admin panel shows only the legacy manual crisis creator — a freeform tool with no template guidance, no decision trees, and no interaction cards.
Decision Trees
A decision tree is a branching narrative attached to a crisis. When a crisis with an interactionDefinition is activated, a CrisisInteraction document is created:
- The first node in the
decisionTreearray becomes thecurrentNodeId - Players (or admins) select an option from the current node
- The selected option may advance to a next node (
nextNodeId), debit the treasury (collectiveContribution), or terminate the tree (currentNodeId = null) - If
autoResolveOnExpiryis true, the interaction auto-resolves when the crisis expires
Collective Contributions
Some decision-tree options require a collective contribution — a treasury debit that funds a collective response to the crisis. The engine checks the treasury balance before applying the contribution:
if (treasury < option.collectiveContribution) {
throw "Insufficient treasury funds. Required: X, Available: Y"
}
await debitTreasury(db, countryId, option.collectiveContribution)
interaction.collectiveCurrent += option.collectiveContribution
This means crisis response has a real fiscal cost — choosing the "full response" option may drain the treasury, forcing tradeoffs with other spending priorities.
Ambient Interaction Cards
When crisis interaction is enabled, the actions page renders ambient interaction cards for active crises with interaction definitions. These cards surface the current decision-tree node to the player and let them choose an option without navigating to a separate crisis page.
When the flag is off, the actions page does not render interaction cards — active crises are visible only through the legacy crisis management interface.
Auto-Disaster Spawner
The isAutoDisastersEnabled() flag gates a separate subsystem: the auto-disaster spawner (src/lib/crises/autoDisasterSpawn.ts). When enabled, the spawner automatically creates disaster crises on a schedule, using the same template system as manual template-based creation.
| Setting | Behavior |
|---|---|
| Off | No automatic disasters — only manually created crises occur |
| On | Auto-disaster spawner runs on its schedule, creating disaster crises from templates |
Auto-disasters use the same template definitions as manual template-based creation, so the decision trees, effects, and durations are consistent. The difference is purely the trigger: manual (admin/player action) vs. automatic (spawner schedule).
Legacy Manual Crisis Creator
When crisis interaction is off, the only crisis creation path is the legacy manual crisis creator — a freeform tool that lets admins define effects, duration, and scope without a template. This path has:
- No decision trees
- No collective contributions
- No interaction cards
- No template guidance
The legacy creator is always available regardless of flag state. The flag only gates the richer template-based system on top.
Strategic Implications
| Decision | Impact |
|---|---|
| Crisis interaction off | Crises are simple shocks — apply effects, wait them out. No player choices during the crisis. |
| Crisis interaction on | Crises become interactive — players face decision trees with fiscal tradeoffs, collective contributions, and branching outcomes. |
| Auto-disasters off | Crises only occur when someone manually creates them. |
| Auto-disasters on | Disasters occur on a schedule, forcing governments to maintain readiness even without active adversaries. |
The flags are game-admin decisions, not per-player choices. Once on, they apply to all crises in the game.
Related Systems
- RPG Stats & Debates — Separate feature flag, independent of crisis interaction
- Player Random Events — Separate feature flag, independent of crisis interaction
- International Trade — Crises can affect trade affinity and tariffs
- Core Systems — Turn structure, action economy