Restructure: move agnostic context docs to Shared/context-files

This commit is contained in:
dingo
2026-02-22 14:17:53 +00:00
parent d711c50d4e
commit 4dc5691c51
8 changed files with 17 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
# Shared Context Files
These context files are domain-agnostic and intended for both Client and Server:
- abilities.md
- affinity.md
- card-design.md
- gameplay.md
- object-context.md
+536
View File
@@ -0,0 +1,536 @@
# Abilities
This file is the canonical reference for the ability and effect system. The same model is used by:
- Unit abilities (`ArchSpirit` and `Spirit`)
- `Instinct` card effects
- `Repentance` card effects
The system is designed to be fully data-driven. Every ability, effect, condition, and target is expressible through the schema below — no additional programming required to create new content.
---
## 1) Ability Structure
```
AbilityDefinition {
Type: Active | Passive | Aura | Triggered
ActivationConditions: Condition[] // optional; if any unmet, ability cannot fire
Actions: Action[]
// Active only:
Cost: CostEntry[]? // see §6.6 in gameplay.md for cost types
Range: { Min, Max }? // targeting range from source unit, in tiles
UsesPerTurn: N // default 1
// Aura only:
AuraRange: { Min, Max }
// Triggered only:
TriggerCondition: Condition
}
```
---
## 2) Ability Types
### 2.1 Active
Manually activated by the controlling player.
- Default: once per turn. May be increased or decreased by effects.
- Optional **cost** — any supported cost type (see §6.6 in gameplay.md).
- Optional **range** — min/max tile distance from source unit to valid targets.
- Optional **activation conditions** — ability cannot be activated unless all conditions are met.
- Supports N or more targets via the target selector on each action.
### 2.2 Aura
Always active while the unit is in play and conditions are met.
- Applies effects passively to all valid targets within `AuraRange` (min/max tiles from source).
- Optional **activation conditions** — if any are unmet, the aura is fully suppressed.
- No manual activation. No cost.
- **Instant stat modifiers** (e.g. `ModifyDamage`, `ModifyMP`) apply when a unit enters range and are removed when the unit leaves range or the aura is suppressed.
- **Per-turn effects** (e.g. `DealDamage`, `Heal`, `DOT`) apply once per turn to each unit currently in range, resolved during the start-of-turn triggers phase for the aura owner's turn.
### 2.3 Passive
Always active while the unit is in play and conditions are met.
- No range constraint.
- Optional **activation conditions** — if any are unmet, the passive is fully suppressed.
- No manual activation. No cost.
### 2.4 Triggered
Automatically fires when the trigger condition is met.
- Defined by a `TriggerEvent` from the catalog in §8, plus optional state conditions.
- Fires once per trigger event unless modified by an effect.
- Not manually activated. No cost.
---
## 3) Action Model
All effect execution — whether from unit abilities, `Instinct` cards, or `Repentance` cards — uses the same Action model.
An action is the atomic unit of targeting and effect delivery. An ability contains one or more actions that resolve in sequence. Each action may have its own target, conditions, and effects.
```
Action {
Target: TargetSelector
Conditions: Condition[] // optional; if any unmet, this action is skipped
Effects: Effect[]
Duration: DurationModel
}
```
**Interrupt rule**: All actions within a single ability (or card play) resolve in full sequence before any interrupt window opens. Opponents cannot interrupt between individual actions of the same ability.
**Instinct and Repentance**: The `Effects` field on these card types is an `Action[]` using this same model.
**ChooseOne**: An ability or card may branch into mutually exclusive effect paths, with the controlling player selecting which branch to take at resolution time.
```
ChooseOne {
Branches: [
{ Label: string, Actions: Action[] },
...
]
}
```
`ChooseOne` may appear anywhere an `Action[]` can appear. When reached, the player controlling the source is presented with the branch labels and must select exactly one. Only the selected branch's actions resolve. Conditions on individual actions within a branch still apply normally.
Example: "Discard a card from your hand OR pay 2 SP and channel it — all channeling rules apply."
---
## 4) Target Selector
```
TargetSelector {
Scope: Hand | Deck | Discard | Battlefield | Player | AnyZone
Type: Unit | ArchSpirit | Spirit | SpiritToken | Ruin | Tile | Card | Player
Ownership: Self | Owner | Ally | Enemy | Any | Random
Count: N | UpToN | All
Filters: Filter[]
}
```
- `Unit` — alias for `Spirit | ArchSpirit | SpiritToken`; use when targeting any unit type without restriction
- `AnyZone` — target a card regardless of which zone it currently occupies
- `Self` — the source unit itself (see §4.3)
- `UpToN` — player may select between 0 and N valid targets; fewer than N is valid
### 4.1 Unit/Card Filters
- `GenusContains(tag)`
- `AffinityMatches(affinity)`
- `HealthBelow(N)` / `HealthAbove(N)`
- `DamageRange(min, max)`
- `DefenseRange(min, max)`
- `MPRange(min, max)`
- `HasFlag(flag)` — e.g., `CanAttack`, `CanMove`, `CanBeSacrificed`
- `TierIs(N)` — ArchSpirit only; matches a specific tier
- `IsAdjacentToSource` — target must be adjacent to the source unit
- `CardTypeIs(type)`
- `CardSPCostRange(min, max)`
- `CardSTCostRange(min, max)`
- `WithinRange(min, max)` — from source unit, in tiles
### 4.2 Tile Filters
- `TileAffinityMatches(affinity)`
- `TileIsOccupied(unitType?)`
- `TileIsUnoccupied`
- `TileWithinRange(min, max)` — from source unit, in tiles
- `TileIsAdjacentToUnit(ownership, filter?)` — tile is adjacent to a unit matching the filter
- `TileIsOnPlayerSide(ownership)` — tile falls within the starting side of the specified player
### 4.3 Ownership Values
- `Self` — the specific unit using the ability (not just any unit the owner controls)
- `Target` — the entity resolved as this action's target; used to reference the current target in conditions or subsequent chained actions
- `Owner` — any unit/card controlled by the ability's owner
- `Ally` — controlled by a teammate (distinct from owner in team modes)
- `Enemy` — controlled by an opponent
- `Any` — any player's units/cards
- `Random` — random selection from valid pool after all other filters apply
---
### 4.4 Chained Targeting
Some abilities need a second target defined relative to a first (e.g., "target an enemy Spirit, then target a tile adjacent to that Spirit"). This is expressed by referencing a prior action's resolved target in a subsequent action's filter.
```
Action 1: { Target: { Scope: Battlefield, Type: Spirit, Ownership: Enemy }, ... }
Action 2: { Target: { Scope: Battlefield, Type: Tile, Filters: [TileIsAdjacentToUnit(ref: Action1.Target)] }, ... }
```
Actions reference prior resolved targets by index (`Action1.Target`, `Action2.Target`, etc.).
---
## 5) Effect Types
### 5.1 Stat Modification
Applies to `Spirit`, `ArchSpirit`, `SpiritToken`:
- `ModifyHealth(amount, target: current | max)` — increase or decrease health
- `ModifyDefense(amount, target: current | max)` — increase or decrease defense
- `ModifyDamage(amount)` — increase or decrease damage
- `ModifyMP(amount, target: current | max)` — increase or decrease movement points
- `SetMovementType(type)` — change movement style (`Walk`, `Flight`, `Jump`, `Teleport`)
- `SetAttackRange(min, max)` — change attack range
- `ModifyCost(sp?, st?)` — change SP or ST cost
- `GrantAdditionalAttack(N)` — allow the unit to attack N additional times this turn; stacks with multiple applications
- `SetStatModMultiplier(stat, multiplier)` — multiply any incoming stat modifications to the specified stat by the given value (e.g. `SetStatModMultiplier(Damage, 2.0)` doubles all Damage modifiers applied to this unit)
---
### 5.2 Flag Modification
Applies to `Spirit`, `ArchSpirit`, `SpiritToken`, or `Player`:
Unit flags:
- `SetCanMove(bool)`
- `SetCanAttack(bool)`
- `SetCanDefend(bool)` — if false, incoming damage bypasses defense
- `SetCanBeAttacked(bool)`
- `SetCanBeBlocked(bool)` — if false, damage dealt ignores target defense
- `SetCanBeObstructed(bool)` — if false, unit ignores movement obstruction
- `SetCanUseAbility(bool)`
- `SetCanBeSacrificed(bool)` — Spirit only
Player flags:
- `SetCanDrawCards(bool)`
- `SetAccumulatesSP(bool)`
- `SetCanChannelSpirit(bool)`
- `SetCanSacrificeSpirit(bool)`
- `SetCanAscendArchSpirit(bool)`
- `SetCanTransitionArchSpirit(bool)`
- `SetCanChannelRepentance(bool)`
- `SetCanChannelInstinct(bool)`
- `SetCanChannelRuin(bool)`
- `SetCanChannelTerramorphaMono(bool)`
- `SetCanChannelTerramorphaDi(bool)`
- `SetCanChannelTerramorphaTri(bool)`
---
### 5.3 Ability Modification
Applies to `Spirit`, `ArchSpirit`, `SpiritToken`:
- `AddAbility(abilityDef)` — add a new ability to the unit
- `RemoveAbility(abilityRef)` — permanently remove an ability
- `EnableAbility(abilityRef)` — re-enable a disabled ability
- `DisableAbility(abilityRef)` — disable without removing
---
### 5.4 Genus Modification
Applies to `Spirit`, `ArchSpirit`, `SpiritToken`:
- `AddGenus(tag)`
- `RemoveGenus(tag)`
---
### 5.5 Player Resource Modification
Applies to `Player`:
- `ModifySP(amount)` — increase or decrease current SP
- `ModifySPAccumulation(amount)` — increase or decrease SP gained per turn
- `ModifyST(amount)` — increase or decrease current ST
- `ModifyCardsDrawnPerTurn(amount)` — change per-turn draw count
---
### 5.6 Tile Modification
Applies to `Tile`:
- `SetBaseAffinity1(affinity)` — set Base1 affinity slot directly
- `SetBaseAffinity2(affinity)` — set Base2 affinity slot directly
- `PushAffinity(affinity)` — push basic affinity into Base2; Base2 shifts to Base1
- `PushFinalAffinity(affinity)` — set Base1/Base2 to the pair yielding the target final affinity
---
### 5.7 Zone and Card Operations
- `DrawCards(N, player)` — target player draws N cards
- `DiscardCards(N, player, filter?)` — discard N cards; optional filter or random selection
- `ReturnToHand(card)` — move card from discard/battlefield to hand
- `ReturnToDeck(card, position: top | bottom | random)` — move card to deck
- `ReturnToBattlefield(card)` — place card from discard/hand onto battlefield
- `SendToDiscard(card)` — move card from any zone to discard
- `SearchDeck(filter, thenAction)` — find card matching filter, then perform defined action
- `ShuffleDeck(player)` — shuffle target player's deck
- `RevealCards(N, toOwnership)` — reveal N hand cards to specified players
- `PlaceOnDeck(card, position: top | bottom)` — place card on top or bottom of deck
- `ChannelCard(card, payCost: bool)` — channel a card directly from hand (or as selected via filter); `payCost: true` deducts normal SP/ST channel costs and all channeling rules apply; `payCost: false` channels the card without cost
---
### 5.8 Combat and Damage
- `DealDamage(amount, bypassDefense?: bool)` — deal damage to target; optionally bypass defense
- `Heal(amount)` — restore health up to max
- `DealDamageToSelf(amount, bypassDefense?: bool)` — source unit takes damage
- `DOT(amount, duration, bypassDefense?: bool)` — damage over time; applies `amount` each turn tick
- `HOT(amount, duration)` — heal over time; restores `amount` each turn tick
---
### 5.9 Displacement
Moves a unit without spending that unit's MP.
- `PushUnit(tiles, awayFromSource)` — move target N tiles away from the source
- `PullUnit(tiles, towardSource)` — move target N tiles toward the source
- `DisplaceUnit(tiles, direction)` — move target N tiles in a fixed cardinal/hex direction
Rules:
- Does not consume the displaced unit's MP.
- Blocked if destination tile is occupied or invalid; unit stops at last valid tile.
- Does not respect the displaced unit's own movement type or obstruction flags.
---
### 5.10 Control Effects
Applies to `Spirit`, `ArchSpirit`, `SpiritToken`:
- `TakeControl(duration)` — transfers control of the target unit to the ability owner for the specified duration; the unit acts as a friendly unit for that player until the effect expires, then returns to its original owner
- `SetFixedSacrificeReturn(stAmount)` — overrides the standard sacrifice formula for this unit; when sacrificed, the controller receives exactly `stAmount` ST instead of the formula result (see §6.15 in gameplay.md)
---
### 5.11 Token Summoning
- `SummonToken(tokenDef, targetTile)` — place a `SpiritToken` onto the target tile; `tokenDef` references a token definition specifying the token's stats, abilities, and genus; follows normal occupancy rules for the tile
---
## 6) Condition Types
Conditions can gate an entire ability or individual actions. If the condition group is not satisfied, the gated ability or action is skipped.
### 6.0 Logical Operators
Conditions may be grouped with logical operators:
- `AND` (default) — all conditions in the group must be met
- `OR` — at least one condition in the group must be met
- `XOR` — exactly one condition in the group must be met
Groups may be nested to express compound logic:
```
OR [
AND [ SPAtLeast(2), UnitCountOnBattlefield(Enemy, Spirit, >=, 1) ]
HandSizeAtLeast(3, subject: Target)
]
```
### 6.0.1 Condition Subject
Each condition evaluates against a **subject** — the entity whose state is checked:
- `subject: Self` (default) — evaluates against the source unit or the ability owner
- `subject: Target` — evaluates against the current action's resolved target
Example: `UnitCountOnBattlefield(Owner, Spirit, >, 1, subject: Target)` checks whether *the targeted player* controls more than 1 Spirit, not the ability's owner.
### 6.0.2 EventData Reference
`Triggered` ability actions have access to the payload of the triggering event via `EventData`. This allows effects to reference numeric values from the event rather than fixed constants.
Available fields (availability depends on the triggering event):
- `EventData.Amount` — the numeric magnitude of the event (e.g., HP gained, damage dealt, SP spent)
- `EventData.Source` — the unit or player that caused the event
- `EventData.Target` — the unit or player the event acted upon
`EventData` fields may be used anywhere a numeric value or unit reference is accepted in an effect or condition within the same action sequence.
Example: `OnHealed(Enemy, ArchSpirit)` → `DealDamage(EventData.Amount * 3)` — when an enemy ArchSpirit gains HP, deal 3× that amount as damage.
### 6.1 Unit Conditions
- `HealthBelow(N)` / `HealthAbove(N)`
- `DefenseIs(N)`
- `HasGenus(tag)`
- `HasAbility(abilityRef)`
- `IsOnTileWithAffinity(affinity)`
- `IsAdjacentTo(unitType, ownership)`
- `WithinRangeOf(target, min, max)`
- `MovementTypeIs(type)`
### 6.2 Player Conditions
- `SPAtLeast(N)` / `SPAtMost(N)`
- `STAtLeast(N)` / `STAtMost(N)`
- `HandSizeAtLeast(N)` / `HandSizeAtMost(N)`
- `DeckSizeAtLeast(N)`
- `DiscardSizeAtLeast(N)`
### 6.3 Tile Conditions
- `TileAffinityMatches(affinity)`
- `TileIsOccupied(unitType?)`
- `TileIsUnoccupied`
### 6.4 Turn/Timing Conditions
- `IsOwnTurn`
- `IsOpponentTurn`
- `IsAllyTurn`
- `IsActivePlayerTurn(ownership)` — scoped to a specific player ownership group
### 6.5 Battlefield Conditions
- `UnitCountOnBattlefield(ownership, unitType, comparator, N)` — e.g. "ally Spirit count >= 3"
- `CardInZone(cardRef, zone)`
---
## 7) Duration Model
All effects support a duration. Reversible effects retain source and modifier context for rollback when duration ends.
- `Instant` — one-time change, no ongoing state
- `UntilEndOfTurn`
- `UntilStartOfOwnerTurn`
- `UntilStartOfSourceOwnerTurn`
- `ForNTurns(N)`
- `WhileCondition(condition)`
- `PermanentInMatch`
Duration anchors can be scoped to a specific player:
- Until end of `X` player's turn
- Until start of `X` player's turn
Delayed timing:
- Effect starts after `X` turns
- Effect ends after `X` turns
---
## 8) Trigger Event Catalog
All `Triggered` abilities specify a `TriggerEvent` from this catalog. Every event supports an **ownership scope** (`Owner | Ally | Enemy | Any`) applied to the acting unit, player, or card. Most events also accept an optional **filter** using the same filter types as §4.
---
### 8.1 Turn Phase
- `OnTurnStart(player)` — start of the specified player's turn
- `OnTurnEnd(player)` — end of the specified player's turn
---
### 8.2 Channeling
Single event, parameterized by card type:
- `OnChanneled(type, ownership, filter?)` — a card of the given type is channeled
- `type`: `Spirit | Terramorpha | Repentance | Instinct | Ruin`
---
### 8.3 ArchSpirit Tier Actions
- `OnAscend(ownership)` — an ArchSpirit is ascended to the next tier
- `OnTransition(ownership)` — an ArchSpirit is transitioned out and replaced
---
### 8.4 Unit Actions
- `OnUnitMove(ownership, filter?)` — a unit spends MP to move to a tile
- `OnUnitAttack(ownership, filter?)` — a unit declares an attack
- `OnUnitAbilityActivated(ownership, filter?)` — a unit activates an Active ability
- `OnUnitMPSpent(ownership, filter?, amount?)` — a unit spends movement points
---
### 8.5 Damage and Healing
- `OnDamageDealt(sourceOwnership, targetOwnership, type: HP | Defense | Any, amount?)` — damage lands on a unit
- `OnDamagePrevented(targetOwnership, filter?)` — incoming damage is fully blocked by defense or an effect
- `OnHealed(targetOwnership, filter?, amount?)` — a unit is restored health
---
### 8.6 Unit Lifecycle
- `OnUnitEnterBattlefield(unitType, ownership, filter?)` — a unit is placed on the battlefield (any cause)
- `OnUnitLeaveBattlefield(unitType, ownership, filter?)` — a unit leaves the battlefield (any cause)
- `OnUnitDeath(unitType, ownership, filter?)` — a unit's HP reaches 0
- `OnUnitSentToDiscard(unitType, ownership, filter?, causedBy?)` — a unit is sent to the discard from the battlefield by any means other than death (e.g. used as a cost, forced removal)
- `OnSpiritSacrificed(ownership, filter?)` — a Spirit is sacrificed (see §6.15 in gameplay.md)
- `OnTokenSummoned(ownership, filter?)` — a SpiritToken enters the battlefield
**`causedBy` parameter**: An optional ownership reference (`Self | Owner | Ally | Enemy | Any`) that filters events to only those caused by a specific unit or player. Applies to unit lifecycle events and unit action events where the acting entity can be identified.
Example: `OnUnitSentToDiscard(Spirit, Any, causedBy: Self)` — fires only when this unit is the one that sent a spirit to the discard.
---
### 8.7 Unit State Changes
- `OnStatModified(ownership, filter?, stat?)` — a mutable stat on a unit is changed
- `OnAbilityAdded(ownership, filter?)` — an ability is added to a unit
- `OnAbilityRemoved(ownership, filter?)` — an ability is removed from a unit
- `OnGenusChanged(ownership, filter?)` — a unit's genus tags are modified
---
### 8.8 Ruin
- `OnRuinActivation(ruinOwnership, occupantOwnership?)` — a Ruin fires one of its abilities
- `OnUnitOccupyRuin(unitOwnership, filter?)` — a unit moves onto a tile containing a Ruin
---
### 8.9 Tile
- `OnTileAffinityChanged(filter?)` — a tile's Base1 or Base2 affinity changes
---
### 8.10 Player Resources
- `OnSPGained(player, amount?)`
- `OnSPSpent(player, amount?)`
- `OnSTGained(player, amount?)`
- `OnSTSpent(player, amount?)`
---
### 8.11 Card Zone Events
- `OnCardDrawn(player, filter?)`
- `OnCardDiscarded(player, cause: voluntary | forced, filter?)`
- `OnCardReturnedToHand(player, filter?)`
- `OnCardReturnedToDeck(player, filter?)`
- `OnDeckShuffled(player)`
- `OnCardsRevealed(player, filter?)`
---
### 8.12 Effect and Targeting Lifecycle
- `OnTargetedByAbility(targetOwnership, sourceOwnership, filter?)` — a unit or player is selected as a target of an ability action (fires before effects resolve)
- `OnEffectApplied(targetOwnership, sourceOwnership, filter?)` — an effect successfully resolves on a target (fires after resolution; distinct from targeting if action conditions blocked the effect)
- `OnEnterAuraRange(auraOwnership, unitOwnership, filter?)` — a unit moves into the active range of an aura ability
- `OnLeaveAuraRange(auraOwnership, unitOwnership, filter?)` — a unit moves out of the active range of an aura ability
+97
View File
@@ -0,0 +1,97 @@
# Affinity Rules (Current Understanding)
This file documents the current affinity system as a strict rules reference.
## 1) Slot Model
Each tile has two affinity slots:
- `Base1`: older slot (filled first)
- `Base2`: newer slot (filled second, most recent)
When pushing a new basic affinity `X` to a tile:
1. Current `Base2` shifts into `Base1`.
2. New affinity `X` becomes `Base2`.
Equivalent update:
- `Base1 = old(Base2)`
- `Base2 = X`
## 2) Basic Affinities
- `Void`
- `Aether`
- `Lake`
- `Hill`
- `Forest`
- `Field`
## 3) Derived Tile Affinity
The tile's active affinity is determined by the pair `(Base1, Base2)`.
## 4) Non-Basic Affinity Map
Combination key uses `Base1 + Base2`.
- `Ocean = Lake + Lake`
- `Island = Lake + Hill` or `Hill + Lake`
- `Marsh = Lake + Field` or `Field + Lake`
- `Swamp = Lake + Forest` or `Forest + Lake`
- `Mountain = Hill + Hill`
- `Steppe = Hill + Field` or `Field + Hill`
- `Fort = Hill + Forest` or `Forest + Hill`
- `Plains = Field + Field`
- `Grove = Field + Forest` or `Forest + Field`
- `Jungle = Forest + Forest`
- `GatewayLake = Lake + Void`
- `GatewayHill = Hill + Void`
- `GatewayField = Field + Void`
- `GatewayForest = Forest + Void`
- `UnstableAether = Aether + (Void or Hill or Forest or Field or Lake)`
- `UnstableAether = (Void or Hill or Forest or Field or Lake) + Aether`
- `PerfectAether = Aether + Aether`
- `PureVoid = Void + Void`
## 5) Notes on Order
Current interpretation:
- Most terrain combinations are order-insensitive (both orders listed).
- `Gateway*` is directional only and requires `Base2 = Void` (`X + Void` only).
- `UnstableAether` is explicitly both directions.
## 6) Example Slot Evolution
Starting tile slots:
- `Base1 = Lake`
- `Base2 = Hill`
Push `Forest`:
- New `Base1 = Hill`
- New `Base2 = Forest`
- Tile affinity resolves from `Hill + Forest` -> `Fort`
## 7) Resolution Completeness
Every `(Base1, Base2)` pair is valid and must resolve to a defined affinity result.
## 8) Basic Affinity on Tiles
Tiles can resolve to a basic affinity when:
- `Base1 = Void`
- `Base2 = <BasicAffinity>`
Examples:
- `Void + Lake` resolves as tile basic `Lake`
- `Void + Hill` resolves as tile basic `Hill`
- `Void + Forest` resolves as tile basic `Forest`
- `Void + Field` resolves as tile basic `Field`
- `Void + Aether` resolves to `UnstableAether` (special case, not basic)
## 9) Card Affinity vs Tile Affinity
Cards use almost the same affinity set as tiles, with exclusions:
- Cards do use basic and standard non-basic affinities.
- Cards do not use `Gateway*`.
- Cards do not use `UnstableAether`.
`PerfectAether` is valid via `Aether + Aether`.
+139
View File
@@ -0,0 +1,139 @@
# Card Design (WIP)
This file is the canonical reference for card types, their mutable state properties, and card-specific rules.
---
## 1) CardState (Shared)
Non-mutable:
- `DefinitionId`
- `LibraryId` (unique GUID per card instance)
- `Name`
- `Description`
- `CardType`
Targeting note: `CardType` is valid for targeting/scoping. All mutable properties are valid selectors.
---
## 2) CardState.ArchSpirit
Mutable:
- `MinChannelRange`
- `MaxChannelRange`
- `SPCost`
- `STCost`
- `OtherCosts`
- `Affinity`
- `AttackType`
- `RequiresLOS`
- `MinAttackRange`
- `MaxAttackRange`
- `CanAttack`
- `Damage`
- `CanDefend` (if false, incoming damage bypasses defense)
- `Health`
- `CanMove`
- `MovementType`
- `MovementPoints`
- `CanBeObstructed` (if false, ignores movement obstruction)
- `Defense`
- `CanBeAttacked`
- `CanBeBlocked` (if false, damage dealt ignores defense)
- `CanUseAbility`
- `AddAbility`
- `RemoveAbility`
- `EnableAbility`
- `DisableAbility`
- `Genus`
---
## 3) CardState.Spirit
Mutable:
- `SPCost`
- `STCost`
- `OtherCosts`
- `Affinity`
- `AttackType`
- `RequiresLOS`
- `MinAttackRange`
- `MaxAttackRange`
- `CanAttack`
- `Damage`
- `CanDefend` (if false, incoming damage bypasses defense)
- `Health`
- `CanMove`
- `MovementType`
- `MovementPoints`
- `CanBeObstructed` (if false, ignores movement obstruction)
- `Defense`
- `CanBeAttacked`
- `CanBeBlocked` (if false, damage dealt ignores defense)
- `CanBeSacrificed`
- `CanUseAbility`
- `AddAbility`
- `RemoveAbility`
- `EnableAbility`
- `DisableAbility`
- `Genus`
---
## 4) CardState.Repentance
Mutable:
- `SPCost`
- `STCost`
- `OtherCosts`
- `Affinity`
- `Effects` (`Action[]` — see **abilities.md**)
Rules:
- Goes to discard once played unless an effect says otherwise.
- Can only be played if the player's ArchSpirit is on a tile matching the Repentance affinity.
---
## 5) CardState.Terramorpha
Mutable:
- `SPCost`
- `STCost`
- `OtherCosts`
- `Affinity`
- `TerramorphaMode` (`Mono`, `Di`, `Tri`)
---
## 6) CardState.Ruin
Mutable:
- `SPCost`
- `STCost`
- `OtherCosts`
- `Affinity`
- `Abilities`
Rules:
- Channeled to a random battlefield tile matching Ruin affinity.
- One ability activates at random at the start of the occupying player's turn, after SP gain and card draw.
- The occupying unit is a valid target for all Ruin abilities regardless of which player controls the Ruin — the controller is not exempt from its negative effects.
---
## 7) CardState.Instinct
Mutable:
- `SPCost`
- `STCost`
- `OtherCosts`
- `Affinity`
- `Effects` (`Action[]` — see **abilities.md**)
Rules:
- Goes to discard once played unless an effect says otherwise.
- Can only be played if the player's ArchSpirit is on a tile matching Instinct affinity.
- Can be played during any player's turn or as a non-play interrupt.
+513
View File
@@ -0,0 +1,513 @@
# Gameplay Rules (Current Scope)
This file captures confirmed gameplay rules so far.
It is intentionally incomplete and will be expanded in later passes.
## 1) Match Entry and Deck Selection
1. Players create decks of cards.
2. Deck size has no minimum and no maximum.
3. Every deck must contain at least one `Tier 1` `ArchSpirit`.
4. Players can enter either:
- Ranked match
- Custom match (join or create)
5. Before match start, each player selects:
- The deck they will use
- The `Tier 1 ArchSpirit` they will start with
## 2) Match Size and Battlefield
1. Matches support `2..N` players.
2. Battlefield size scales based on player count.
3. Each player has a defined starting side.
4. Grid styles supported:
- `Square`
- `Hex`
## 3) Opening Placement
1. Each player places their selected `Tier 1 ArchSpirit` on a tile in the first row of their side.
2. On placement, the `ArchSpirit` affinity is pushed to the placement tile itself and all valid adjacent tiles:
- Square grid (non-corner): the placement tile + `3` adjacent tiles = `4` tiles total.
- Square grid (corner): the placement tile + `2` adjacent tiles = `3` tiles total.
- Hex grid (non-corner edge): the placement tile + `4` adjacent tiles = `5` tiles total.
3. Edge-side explanation:
- On a square edge, the tile behind the ArchSpirit is off the board, so only 3 adjacent tiles are valid.
- On a hex edge, two sides face off the board, leaving four valid adjacent tiles.
- Example (square, 5,0 placement): tiles `4,0`, `5,0`, `5,1`, `6,0` all receive the affinity push.
## 3.1 Opening Draw
1. At game start, each player draws `7` cards.
2. This value is the default and may be overridden by custom match settings.
## 4) Turn Order
## 4.1 Free-for-All
Turn order is randomized among all players.
## 4.2 Team Play
1. Team order alternates by team.
2. Within each team slot, player order is randomized among that team's players.
3. Example:
- Team 1 Player A
- Team 2 Player C
- Team 1 Player B
- Team 2 Player D
## 5) Turn Economy
1. Base SP gain per turn is driven by game settings:
- Ranked: static/default ranked setting
- Custom: defined by custom rules
2. Effects may modify SP gained per turn.
3. SP currently has no enforced cap.
4. SP cap should be supported by settings in the future.
5. Default per-turn card draw is `1`; may be modified by effects.
## 5.1 Resource Rules
1. `Sacrifice Tokens` are a separate resource from `SP`.
2. `Sacrifice Tokens` do not accumulate automatically per turn.
3. `Sacrifice Tokens` are obtained by other game effects/systems and spent to pay card costs.
## 6) Turn Flow (Current High-Level)
1. Active player takes actions during their turn.
2. Active player clicks "end turn" when finished; `UntilEndOfTurn` effects expire at this point.
3. Turn advances to next player in current turn order.
## 6.0 Start-of-Turn Phase
At the start of each turn, the following resolve in order:
1. MP replenishment — all friendly `ArchSpirit` and `Spirit` units restore movement points.
2. Defense restoration — all friendly `ArchSpirit` and `Spirit` units restore defense to max.
3. SP gain — the active player gains their current SP accumulation amount.
4. Start-of-turn triggered abilities resolve.
5. Card draw — the active player draws their current per-turn card count.
6. Draw-triggered abilities resolve.
7. Ruin activations — one ability activates at random for each Ruin tile occupied by a friendly unit.
## 6.1 Hand Rules
1. There is no enforced hand size limit.
## 6.2 Turn-Timing Rule (Current)
During the active player's turn, they may channel:
- `Spirit`
- `Ruins`
- `Terramorpha`
- `Repentance`
- `Instinct`
The active player may continue channeling cards while they can still pay all required costs.
Channeling cards and taking unit actions (move, attack, ability, sacrifice) may be freely interleaved with no required ordering.
Special timing exception:
- `Instinct` cards may also be played during other players' turns.
- `Instinct` cards may also be played as non-play interrupts.
## 6.2.1 Card Resolution and Interrupt Windows
1. Card resolution follows play order (first played, first resolved in sequence).
2. Between each card played and between each unit action (move, attack, ability use), there is a `10` second interrupt window.
3. During that window, opponents may interrupt by playing an `Instinct`.
4. An ability's actions resolve in full sequence without interrupt windows between individual actions — the window opens only after the entire ability has resolved.
## 6.3 Channeling Spirits
1. A player may channel Spirit cards to tiles in the active `ArchSpirit`'s channeling range.
2. Channeling range is an `ArchSpirit`-specific property with `min` and `max` values.
3. Range rules:
- `min` can never be less than `1` in normal cases.
- If channeling range is set to `0`, that `ArchSpirit` cannot channel.
4. Channeling requires:
- Paying the channel cost
- Affinity validity on the target tile
5. Affinity validation:
- If the card has a basic affinity, `Base1` or `Base2` on the target tile must match that basic affinity.
- If the card has a non-basic affinity, the target tile must match that final resolved affinity exactly.
## 6.4 Channeling Terramorpha
1. Players may channel `Terramorpha` cards by paying their cost.
2. Terramorpha pushes affinity to target tiles.
3. Terramorpha can target any tile on the battlefield.
4. Terramorpha types:
- `Mono`: pushes affinity to one target tile.
- `Di-morpha`: target one tile, then target one adjacent tile.
- `Tri-morpha`: target one tile, then target one adjacent tile, then target one adjacent tile.
## 6.5 Unit Actions Per Turn
1. A player may move their `ArchSpirit` and `Spirit` units until each unit is out of movement points.
2. `ArchSpirit` can attack once per turn, unless modified by an ability/effect.
3. `Spirit` can attack once per turn, unless modified by an ability/effect.
4. `ArchSpirit` can use one activated ability per turn, unless modified by an ability/effect.
5. `Spirit` can use one activated ability per turn, unless modified by an ability/effect.
## 6.6 Cost Types (Channeling and Activated Abilities)
Supported costs include:
- `Spirit Points`
- `Sacrifice Tokens`
- Discard card from hand (with optional restrictions such as specific card, card type, or card cost)
- Move card from top of deck to discard
- Move card from bottom of deck to discard
- Send a controlled `Spirit` from battlefield to discard
- Deal damage to own `ArchSpirit`
- Deal damage to own `Spirit`
## 6.7 ArchSpirit Tier Actions
## 6.7.1 Transition
1. `Transition` swaps the `ArchSpirit` in play with a `Tier 1 ArchSpirit` from that player's hand.
2. `Transition` can only be performed during that player's turn.
3. The outgoing `ArchSpirit` goes to discard.
4. The incoming `ArchSpirit` enters with full health and defense.
5. `Transition` uses the incoming `ArchSpirit`'s channeling cost.
6. The incoming `ArchSpirit` may move, attack, and use abilities during the turn it enters.
## 6.7.2 Ascend
1. `Ascend` upgrades the in-play `ArchSpirit` by exactly one tier (for example `Tier 1 -> Tier 2`).
2. `Ascend` can only be performed during that player's turn.
3. The target higher-tier `ArchSpirit` must be the direct predecessor/successor line of the in-play `ArchSpirit`.
4. Valid example:
- `ArchSpirit A Tier 1 -> ArchSpirit A Tier 2`
5. Invalid examples:
- `ArchSpirit A Tier 1 -> ArchSpirit B Tier 2`
- `ArchSpirit A Tier 1 -> ArchSpirit A Tier 3+`
6. `Ascend` uses the incoming (higher-tier) `ArchSpirit`'s channeling cost.
7. The higher-tier `ArchSpirit` source zone is not restricted (hand, deck, or other).
8. The incoming `ArchSpirit` may move, attack, and use abilities during the turn it enters.
## 6.8 Movement Rules (Spirit and ArchSpirit)
1. Movement is `1-to-1`: moving one tile spends one MP.
3. A tile can contain at most one `Spirit` or `ArchSpirit` at a time.
4. Movement can be obstructed by other `Spirit`/`ArchSpirit` units.
5. Each `Spirit` defines:
- Whether its own movement can be obstructed
- Whether it obstructs movement for others
6. Supported movement styles include:
- `Walk`
- `Flight`
- `Jump`
- `Teleport`
7. Movement style behavior:
- `Walk`: can be obstructed by any `Spirit` or `ArchSpirit` occupying a tile.
- `Flight`: can only be obstructed by units with `Flight`.
- `Jump`: cannot be obstructed. Has a min/max movement range. Costs `1 MP` per tile landed on (not per tile traversed in path).
- `Teleport`: cannot be obstructed. Same min/max range model as `Jump`. Costs `1 MP` per tile landed on.
8. Line-of-sight (`LOS`) requirements:
- `Walk` and `Flight` do not require LOS (path-based movement).
- `Jump` does not require LOS.
- `Teleport` requires LOS.
9. Pathing:
- Movement pathing is built through adjacent tiles.
- On `Square` grids, diagonal movement is not allowed.
- On `Hex` grids, pathing uses standard BFS over adjacent tiles with 1-to-1 tile movement cost.
## 6.9 ArchSpirit/Spirit Shared Properties
## 6.9.1 Genus
1. `Genus` is an array of type tags (examples: `Goblin`, `Undead`, `Warrior`).
2. A unit is affected by any effect that matches any of its genus tags.
## 6.9.2 Health
1. A unit with `Health <= 0` is dead.
2. Dead units go to the discard unless an ability/effect specifies otherwise.
## 6.9.3 Defense
1. Defense restores to max at the start of each turn (see §6.0).
2. Incoming damage is applied to `Defense` first.
3. Damage is applied to `Health` only after `Defense` reaches `0`.
4. Example:
- Start: `Health = 5`, `Defense = 2`
- Take `1` damage -> `Health = 5`, `Defense = 1`
- Before defense restore, take `2` damage -> `Defense` goes to `0`, remaining `1` damage applies to health -> `Health = 4`
- At next turn start, defense restores to its full value (`2` in this example)
## 6.10 Attack System (Spirit and ArchSpirit)
1. `Spirit` and `ArchSpirit` units define:
- `attackStyle`
- `minAttackRange`
- `maxAttackRange`
- `damage`
2. Units can target friendly units (`Spirit`/`ArchSpirit`) with attacks, but friendly-target attack attempts require confirmation.
3. Damage normally applies through defense first, unless an ability/effect specifies defense bypass.
4. Attack style may define whether line-of-sight (`LOS`) is required.
5. Attack definitions may be:
- Single target
- Multi-target (`N` targets)
6. Attacks may include dynamic damage modifiers that decrease or increase damage based on defined factors.
7. Attacks may be `AOE`.
8. Attack range behavior may be constrained to linear-only targeting.
9. Attack range behavior may be constrained to diagonal-only targeting.
## 6.11 Ability System
See **abilities.md** for the full ability model (types, action model, effect types, conditions, durations).
## 6.12 Mutable Properties
See **object-context.md** for the canonical mutable property inventory and **card-design.md** for card-specific state properties.
## 6.13 Card Instance Rule
Gameplay operates on card instances.
There is no permanent card loss/gain of base definitions during play.
## 6.14 Stateful Mutation Model (Object-by-Object)
All mutable changes support duration metadata so effects can expire or be undone.
Duration model (applies to all objects):
- `Instant` (one-time change, no ongoing state)
- `UntilEndOfTurn`
- `UntilStartOfOwnerTurn`
- `UntilStartOfSourceOwnerTurn`
- `ForNTurns`
- `WhileCondition`
- `PermanentInMatch`
For reversible/temporary effects, the game must retain source + modifier context so rollback can be resolved correctly when duration ends.
## 6.14.1 PlayerState (Mutable Properties)
- `SPTotal`
- `SPAccumulationAmount`
- `AccumulatesSP` (bool)
- `STTotal`
- `CardsDrawnPerTurn`
- `CanDrawCards` (bool)
- `CanAscendArchSpirit` (bool)
- `CanTransitionArchSpirit` (bool)
- `CanChannelSpirit` (bool)
- `CanSacrificeSpirit` (bool)
- `CanChannelRepentance` (bool)
- `CanChannelInstinct` (bool)
- `CanChannelRuin` (bool)
- `CanChannelTerramorphaMono` (bool)
- `CanChannelTerramorphaDi` (bool)
- `CanChannelTerramorphaTri` (bool)
## 6.14.2 TileState (Mutable Properties)
- `BaseAffinitySlot1`
- `BaseAffinitySlot2`
- `PushAffinity` (push basic affinity into Base2 with slot shift)
- `PushFinalAffinity` (set Base1/Base2 to the pair required for a target final affinity)
- Occupancy-driven behavior/effects
- Occupant-targeting behavior/effects
Current occupant classes that tile behavior can reference:
- `Spirit`
- `ArchSpirit`
- `SpiritToken` (temporary spirit/summon)
- `Ruin`
## 6.14.3 Canonical Object Property Inventory (WIP)
This section is the normalized source for object properties.
## 6.14.3.1 Player
Non-mutable:
- `Id`
- `Name`
- `SelectedDeck`
- `SelectedArchSpirit`
Mutable:
- See `PlayerState` in `6.14.1`.
## 6.14.3.2 Tile
Non-mutable:
- `Id`
- `Coords`
Mutable:
- `CanBeOccupiedBy`: `Spirit`, `ArchSpirit`, `Ruin`
- `BaseAffinitySlot1`
- `BaseAffinitySlot2`
- `PushAffinity`
- `PushFinalAffinity`
- Occupancy-based effects
- Occupant-targeting effects
## 6.14.3.3 Battlefield
Non-mutable:
- Battlefield is a collection of tiles.
Mutable:
- Derived from tile state mutations and battlefield-level effects/rules.
## 6.14.3.4 CardState
See **card-design.md** for full CardState definitions (Shared, ArchSpirit, Spirit, Repentance, Terramorpha, Ruin, Instinct).
## 6.14.3.5 Deck / Hand / Discard Mutable Operations
Deck:
- Return card from `Hand`/`Discard`/`Battlefield` to deck
- Shuffle deck
- Place card from source zone to top or bottom of deck
- Draw `X` cards
- Place `X` cards from deck into discard
Hand:
- Discard `N` cards
- Reveal cards to `N` players
- Discard random cards
- Target player selects card(s) to discard
- Put `N` cards from hand on top/bottom of deck
- Put `N` cards from hand to battlefield as Instinct
- Play `N` cards from hand for modified cost `X`
Discard:
- Return cards from discard to deck
- Return cards from discard to hand
- Return cards from discard to battlefield
## 6.14.4 Global Targeting Filters and Location Scopes
Additional target filters:
- `Owner`
- `Ally`
- `Enemy`
- `Any`
- `Random`
Location scopes:
- `Hand`
- `Deck`
- `Discard`
- `Battlefield`
## 6.14.5 Duration Rule Primitives
Supported duration timing patterns:
- `UntilEndOfTurn`
- `UntilStartOfTurn`
- Duration anchors can be scoped to specific player turns:
- Until end of `X` player's turn
- Until start of `X` player's turn
- Delayed start/end:
- Effect starts after `X` turns
- Effect ends after `X` turns
- Conditional durations:
- While condition `X` is true
- While condition `X` is false
## 6.14.6 Summon and Occupancy Limits
1. There are no summon limits.
2. If a tile is in valid range and meets summon requirements, it is a valid summon target.
3. Every tile on the battlefield can be occupied.
## 6.15 Sacrifice Action
1. Sacrifice is a free action (does not consume an attack or ability use).
2. A player may sacrifice a `Spirit` only if that `Spirit` is adjacent to the player's `ArchSpirit`.
3. The sacrificed `Spirit` goes to discard.
4. Sacrifice value is computed first:
- `SpiritSacValue = (CardSTCost * 3) + CardSPCost`
5. Sacrifice Token (`ST`) return is computed from current `ST` and `SpiritSacValue`.
6. Sacrifice return function:
```csharp
public int GetSTReturn(int CurrentST, int SpiritSacValue)
{
int STReturn = 0;
if (CurrentST == 0)
{
if (SpiritSacValue <= 15)
{
STReturn = 1;
}
if (SpiritSacValue >= 16)
{
STReturn = 2;
}
}
if (CurrentST == 1)
{
if (SpiritSacValue <= 2)
{
STReturn = 0;
}
if (SpiritSacValue >= 3 && SpiritSacValue <= 15)
{
STReturn = 1;
}
if (SpiritSacValue >= 16)
{
STReturn = 2;
}
}
if (CurrentST == 2)
{
if (SpiritSacValue <= 6)
{
STReturn = 0;
}
if (SpiritSacValue >= 7 && SpiritSacValue <= 15)
{
STReturn = 1;
}
if (SpiritSacValue >= 16)
{
STReturn = 2;
}
}
if (CurrentST == 3)
{
if (SpiritSacValue <= 9)
{
STReturn = 0;
}
if (SpiritSacValue >= 10 && SpiritSacValue <= 15)
{
STReturn = 1;
}
if (SpiritSacValue >= 16)
{
STReturn = 2;
}
}
if (CurrentST >= 4)
{
STReturn = 0;
}
return STReturn;
}
```
## 7) Win Condition (Current)
Last `ArchSpirit` standing wins.
## 8) Deferred Rules (To Be Added Next)
The following are intentionally not defined yet:
- Full timing windows and reaction timing
- Affinity push timing and replacement edge cases
- Elimination timing details for team modes
- Mulligan rules
- Status effects, death checks, and simultaneous resolution order
- Ranked ruleset constants and custom rules schema
- Full adjacent-tile targeting constraints for `Di-morpha`/`Tri-morpha`
+78
View File
@@ -0,0 +1,78 @@
# Object Context
This file is the canonical reference for all game objects, their properties, the ability action model, and the full catalog of effect and condition types.
---
## 1) Object Definitions
### 1.1 Player
Non-mutable:
- `Id`
- `Name`
- `SelectedDeck`
- `SelectedArchSpirit`
Mutable (see §6.14.1 in gameplay.md):
- `SPTotal`
- `SPAccumulationAmount`
- `AccumulatesSP` (bool)
- `STTotal`
- `CardsDrawnPerTurn`
- `CanDrawCards` (bool)
- `CanAscendArchSpirit` (bool)
- `CanTransitionArchSpirit` (bool)
- `CanChannelSpirit` (bool)
- `CanSacrificeSpirit` (bool)
- `CanChannelRepentance` (bool)
- `CanChannelInstinct` (bool)
- `CanChannelRuin` (bool)
- `CanChannelTerramorphaMono` (bool)
- `CanChannelTerramorphaDi` (bool)
- `CanChannelTerramorphaTri` (bool)
---
### 1.2 Tile
Non-mutable:
- `Id`
- `Coords`
Mutable:
- `CanBeOccupiedBy`: `Spirit`, `ArchSpirit`, `Ruin`
- `BaseAffinitySlot1`
- `BaseAffinitySlot2`
- `PushAffinity` (push basic affinity into Base2 with slot shift)
- `PushFinalAffinity` (set Base1/Base2 to the pair required for a target final affinity)
- Occupancy-based effects
- Occupant-targeting effects
Occupant classes tile behavior can reference:
- `Spirit`
- `ArchSpirit`
- `SpiritToken`
- `Ruin`
---
### 1.3 Battlefield
Non-mutable:
- Collection of tiles.
Mutable:
- Derived from tile state mutations and battlefield-level effects.
---
### 1.4 CardState
See **card-design.md** for the full CardState definitions (Shared, ArchSpirit, Spirit, Repentance, Terramorpha, Ruin, Instinct).
---
## 2) Ability and Effect System
See **abilities.md** for the full ability action model, target selectors, effect types, condition types, and duration model.