Commit Graph
41 Commits
Author SHA1 Message Date
Shard 84284be4d0 Fix active ability target gating for server-resolved ownership scopes 2026-03-26 14:32:31 +00:00
f700fd5de6 Implement multiplayer extension: 2-10 players FFA/Team/Multi-Team
Core engine:
- Add SeatIndex, TeamIndex, IsEliminated to PlayerState
- Add SeatOrder, GameMode to GameState with helpers: ActiveSeats(),
  GetNextActiveSeat(), GetEnemyIds(), AreAllies()
- Add StartingZones to Board for per-seat placement validation
- Add BoardShape, PlayerCount to GameRules
- New BoardShapeGenerator: Rectangle (up to 4 seats) + Cross shapes
- N-player Initialize() overload; old 2-player overload delegates to it
- EndTurn uses GetNextActiveSeat() instead of hardcoded GetOpponentId()
- Attack finds target across all enemy players; EliminatePlayer() helper
  allows multi-player elimination without immediate game over
- PlaceArchSpirit validates via StartingZones (legacy row fallback preserved)
- AbilitySystem.Own() uses AreAllies() for team-aware ownership checks

Database:
- GameSession: +player_count, +game_mode, +additional_players_json
- CustomLobby: +game_mode, +team_count, +additional_players_json
- EF migration: AddMultiplayerSlots (applied)

Handlers:
- GameCreateCustomLobbyHandler: honours MaxPlayers/GameMode/TeamCount from request
- GameJoinCustomLobbyHandler: multi-slot join up to MaxPlayers
- GameLobbyReadyHandler: N-player all-ready check; seats/team assignment by mode
- GameReadyHandler: builds N-player list from AdditionalPlayersJson
- GameHandlerBase.LoadActiveSessionAsync: recognises additional players

Client:
- Game.gd: get_opponents() returns all non-local players;
  get_opponent() kept as backward-compat alias returning first opponent

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-25 23:57:36 -04:00
c692d8ec64 Implement UnitSentToDiscard trigger — enables Bloodlust abilities
New TriggerEventKind.UnitSentToDiscard fires whenever a unit is moved to the
discard pile, carrying SourceId = the killer unit's instance ID and
ActorId = the victim's player — consistent with UnitDeath convention.

Wired in 4 paths:
- GameEngine.cs attack: attacker killed by counterattack (SourceId = target)
- GameEngine.cs attack: target killed by attacker (SourceId = attacker)
- AbilitySystem KillUnit: ability/effect-driven death (SourceId = ctx.Source)
- AbilitySystem SendToDiscardEffect: direct discard effect (SourceId = ctx.Source)

OnUnitSentToDiscardTrigger is now matched in TriggerMatches. CausedBy field
acts as killer ownership scope; CausedBy="ExactSelf" checks SourceId == this
unit's InstanceId via the existing Own() helper, enabling:

  Bloodlust Aggression:
    { type:"OnUnitSentToDiscard", unitType:"Spirit", ownership:"Enemy",
      causedBy:"ExactSelf" }
    → ModifyDamageEffect { Amount:1 }, Duration: PermanentInMatch

  Bloodlust Vitality:
    { type:"OnUnitSentToDiscard", unitType:"Spirit", ownership:"Enemy",
      causedBy:"ExactSelf" }
    → ModifyMPEffect { Amount:1, StatTarget:"Max" }, Duration: UntilEndOfTurn

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-25 21:14:44 -04:00
2a15bd2eb3 Fix crashes, add ModifyAttackRange effects, ArchSpirit swap in deck editor
- Bazaar Deck tab crash: null-safe float conversion for usdPrice in store_item_row.gd
- Leaderboard crash: freed-object guard in _on_leaderboard_ok (is_instance_valid check)
- Add ModifyMinAttackRangeEffect / ModifyMaxAttackRangeEffect with clamp-to-0 and correct reversal tracking
- AbilityBuilder: add new range effects to Stat Modification group + _amountOnlyTypes
- collection.set_arch_spirit: new handler, request record, and service registration
- Deck editor: show Tier-1 commander row with Change button + ArchSpirit picker panel

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-25 11:25:44 -04:00
9c42e5c1c8 Aura: self-apply Actions + ClearOnLeave / LingerDuration on leave
Previously, Aura abilities only fired OnEnterAuraRange / OnLeaveAuraRange
trigger events — their own Actions were never executed. Auras now directly
apply their Actions to any unit that enters range (using WhileSourceOnBattlefield
by default) and handle departure via three modes:

- Persist (default): effects expire at their configured Duration unchanged
- ClearOnLeave: effects are reverted immediately when the unit leaves range
- LingerDuration: effects switch to the specified duration when leaving range,
  allowing them to outlive the aura's reach (and the source if it leaves)

Server:
- AbilityDefinition: add ClearOnLeave (bool) and LingerDuration (DurationModel?)
- AbilitySystem: add ApplyAuraEffects + HandleAuraLeave helpers;
  refactor FireAuraTransition to take FieldCard + AbilityDefinition and call
  both helpers; update all six call sites in EvaluateAuraTransitions /
  EvaluateAurasOnEnter / EvaluateAurasOnLeave to use the unified path

Admin:
- AbilityBuilder: add AuraClearOnLeave / AuraLingerDurationStr / N draft fields;
  parse + compile round-trip; 3-radio On Leave UI + optional Linger duration select;
  update Aura help row to describe the new behaviour

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-24 21:11:56 -04:00
afb083093a Hill Training: ExactSelf trigger + TileAffinityMatches FieldCard fix
- AbilitySystem: add TileAffinityMatchesCondition case for FieldCard subject
  so activation conditions check the tile the unit is currently standing on
  (previously only handled Coord subjects; triggered abilities pass FieldCard)
- AbilityBuilder: add "ExactSelf" to OwnershipValues dropdown for trigger events
  so designers can restrict triggers to only this specific unit instance
- AbilityBuilder help section: add Trigger Ownership table documenting all
  ownership values including ExactSelf with clear explanation of instance-level scope

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 14:23:30 -04:00
dingo 2b7b6aa2ba Fixed but in AbilitySystem for resolving affinity 2026-03-23 13:55:36 -04:00
a870f2391b Add AffinitySystem.Decompose + fix SetAffinity for non-basic affinities
SetAffinity previously hardcoded Base1=Void which is only correct for
basic affinities. Non-basics like Jungle need (Forest,Forest), Island
needs (Lake,Hill), etc. — Void+Jungle would fall through to PureVoid.

Added AffinitySystem.Decompose(Affinity) which reverse-maps every
resolved affinity to its canonical (Base1, Base2) pair. SetAffinity
on tiles now calls Decompose so any affinity — basic or non-basic —
is stored correctly and Resolve() returns the intended value.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 13:04:01 -04:00
04dd457efa Fix SetAffinity tile layout: Base1=Void, Base2=affinity
Setting both slots to the same basic affinity produces the wrong
resolved value (Lake+Lake→Ocean). Basic tiles are represented as
(Void, Basic) per §8, so SetAffinity now sets Base1=Void and
Base2=newAffinity. Both original slot values are still tracked
for reversal when the duration expires.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 13:01:08 -04:00
a768f1b27c Fix Battlefield tile targeting and SetAffinity on tiles
Bug: Battlefield/All tile targets were always empty — the tile
resolution path required client-provided coords for every case,
but board-wide abilities (Scope=Battlefield, All=true) never send
coords from the client. Added server-side enumeration of all board
tiles for this case.

Fix: SetAffinity on a tile now writes both Base1 and Base2 to
the new affinity so AffinitySystem.Resolve returns the correct
value unambiguously. Reversal tracks both slots independently so
both are restored when the duration expires.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 12:33:03 -04:00
14609428e6 Fix three bugs blocking SetAffinity on tile targets
Bug 1 — SetAffinityEffect silently ignored for Coord targets:
ExecuteEffect had no tile case for SetAffinityEffect (only handled
CardInstance). Added case that writes to Base2 and tracks the original
value for duration reversal using a "tile:X,Y" target ref.

Bug 2 — ApplyReversal couldn't find tile targets:
The reversal lookup only searched players' card zones. Added parsing
of the "tile:X,Y" ref format to produce the Coord used to re-execute
the SetBaseAffinity2 reversal effect.

Bug 3 — TileIsOccupied / TileIsUnoccupied / TileAffinityMatches
conditions not implemented in EvaluateCondition:
All three tile condition types fell through to the default (return true),
so conditions like TileIsOccupied were silently no-ops. Implemented all
three with proper tile lookup and occupant/affinity checks.

Wavecrasher (SetAffinity Lake on occupied tiles, ForNTurns:2) now
correctly selects only occupied tiles, changes their affinity, and
reverts them automatically after two turns.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-23 12:23:39 -04:00
324537ded0 SummonToken: structured admin editor + affinity enforcement + art URLs
- AbilityBuilder.razor: replace raw JSON textarea with full structured
  editor for SummonToken effects. Supports two modes:
  • Existing Card — searchable autocomplete from Spirit card catalog
  • Custom Token — inline editor for all Spirit stats (name, affinity,
    health/defense/damage, movement type/MP, attack range, LOS, all
    permission flags, genus tags, abilities JSON, 2D art URL, 3D model URL)
  Compiles TileFilter[TileAffinityMatchesFilter] when affinity is non-Void,
  enabling client-side tile highlighting to match server enforcement.

- AbilitySystem.cs (SummonTokenEffect): validate that the target tile's
  affinity is compatible with the token's affinity before placing.

- GameState.cs (CardInstance): add Art2dUrl + ModelUrl so summoned tokens
  can carry visual asset references through the game state.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-22 16:15:36 -04:00
23643d0934 Fix ArchSpirit ability activation + Ownership:Target auto-resolution
- AbilitySystem.cs: ActivateAbility was only searching player.Field for the
  source unit, but player.ArchSpirit is stored in a separate field and was never
  checked. Active abilities on an ArchSpirit now work correctly.

- game_screen.gd: Add "Target" to auto_ownerships so the client skips the
  player-picker UI for Ownership:Target actions. The server auto-resolves them
  from ctx.ResolvedTargets (the owner of the previously targeted card), which
  is exactly what Bounce needs: refund SP to the owner of the returned spirit
  without asking the user to choose a player.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-22 10:42:56 -04:00
2c737458a8 Fix ability builder crash + implement TargetOwnership.Target for Player targets
- AbilityBuilder.razor: ReadFixed now checks if the JSON node is a JsonObject
  before calling GetValue<int>() on it. Previously, a ValueExpr like
  {"Ref":"Target.SpCost"} caused an InvalidOperationException that was swallowed
  silently by ParseJson's catch block, leaving the builder showing no abilities.

- AbilitySystem.cs: TargetOwnership.Target on Player-type selectors now resolves
  to the owner of the last CardInstance in ctx.ResolvedTargets. This enables
  abilities like Bounce: Action 1 returns a spirit to hand, Action 2 targets that
  spirit's owner (Ownership:Target) to refund its channel cost via a Ref value.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-22 10:21:35 -04:00
Shard 7d572ae55c Standardize active ability execution between unit and card paths 2026-03-19 23:53:05 +00:00
Shard 7ca86ce858 Enforce CanMove and CanUseAbility suppression in game flow 2026-03-19 22:55:04 +00:00
Shard 7a90e2b8ab Unify ability schema: canonical AbilitiesJson with EffectsJson compatibility 2026-03-19 21:20:27 +00:00
e9476a3775 Fix ReturnToHandEffect: revoke passives + skip target conditions at activation
- Skip ActivationConditions with Subject=="Target" in ActivateAbility (mirrors
  AbilitiesJson code path) so conditions like IsOnTileWithAffinity{Target,Lake}
  aren't evaluated against the source unit at activation time
- Add RevokePassivesForSource call in ReturnToHandEffect before removing the
  unit from the field, matching SendToDiscardEffect pattern

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-19 15:49:16 -04:00
adae8cfc43 Fix: ValueExpr now resolves Target.* and ActionN.Target.* references
Extends ResolveValue to support dynamic references to the resolved target's
properties (SpCost, StCost, Damage, Health, Defense, MP). Also adds Self.SpCost
and Self.StCost.

Usage in ability JSON:
  {"Ref": "Target.SpCost"}        — current action's target's SP cost
  {"Ref": "Action0.Target.SpCost"} — cross-action: action 0's target's SP cost

Enables effects like "return target to hand and refund its channel cost":
  Action 0: Target spirit → ReturnToHand
  Action 1: Target Owner (Player) → ModifySP {"Ref": "Action0.Target.SpCost"}

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-18 14:32:11 -04:00
5d3ee92553 Fix: Repentance/Instinct card target selection + server active ability execution
Client: Repentance/Instinct cards with Active abilities in abilitiesJson now
enter ABILITY_TARGET mode instead of sending play_card immediately. Units on
matching tile affinities (IsOnTileWithAffinity) are highlighted in blue; the
player clicks a target unit and the card is sent with the selected unit target.

Server: FireCardEffects now also processes Active abilities from AbilitiesJson
(after the existing EffectsJson path). Source-side ActivationConditions are
checked; target-side conditions (Subject=Target) are trusted from the client.

New Game.gd helper: send_play_card_with_targets sends play_card with a targets
array so the server can route unit selections to the active ability handler.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-18 14:05:49 -04:00
66452313d5 Fix: conditional passive re-evaluation + INSUFFICIENT_TARGETS crash
Issue 1 — ActivationConditions on passives were never checked:
- ApplyPassivesForSource and ApplyPassivesToNewTarget now evaluate
  ActivationConditions against the source unit before executing each
  passive ability (e.g. IsOnTileWithAffinity: Lake only grants the buff
  when the unit is actually on a Lake tile).

Issue 1 — Passives not re-evaluated on movement / tile changes:
- Added ReEvaluateConditionalPassives(state): for every unit with at
  least one conditional passive, revoke all WhileSourceOnBattlefield
  effects then reapply with conditions re-checked. Units without
  conditional passives are skipped with zero overhead.
- Called after MoveUnit (unit changes tile affinity),
  ActivateAbility (ability may change board state),
  and ChannelCard Terramorpha path (tile affinities change).

Issue 2 — INSUFFICIENT_TARGETS thrown from ApplyPassivesToNewTarget:
- ResolveTargets: when restrictTargets is set (passive-to-new-target
  mode only) and filtering produces zero candidates, return [] silently
  instead of throwing. An ExactSelf source-buff simply has no valid
  target among the new unit — that is expected, not an error.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-18 11:04:03 -04:00
4f0f0e9c0f Feature: ability-level Duration override + WhileSourceOnBattlefield in duration list
AbilityDefinition gains an optional Duration property. When set it is used
as forceDuration for every ExecuteActions call that resolves that ability,
overriding whatever per-action Duration individual effects specify.

- Active abilities: def.Duration is threaded through as forceDuration
- Triggered abilities: same
- Passive abilities: def.Duration ?? WhileSourceOnBattlefield (both
  ApplyPassivesForSource and ApplyPassivesToNewTarget paths)

AbilityBuilder admin panel:
- Duration row added after type-specific fields (dropdown + N input for ForNTurns)
- "WhileSourceOnBattlefield" added to the DurationTypeValues list
- Parse and compile paths updated for the new Duration field

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-17 23:15:05 -04:00
0f416127b1 Fix: Genus not propagated to CardInstance/FieldCard — breaks passive conditions
DefinitionToInstance and ToFieldCard both omitted copying Genus, so
HasGenusCondition and GenusContainsFilter always evaluated against null
(returning false). All three data-flow gaps are now fixed:
- DefinitionToInstance: def.Genus?.ToList() → CardInstance.Genus
- ToFieldCard:          source.Genus?.ToList() → FieldCard.Genus
- FilterMatches:        GenusContainsFilter now handled (was falling to _ => true)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-17 17:29:42 -04:00
f60457b716 Fix: implement Passive ability execution with per-target conditions
Passive abilities (e.g. 'All Merfolk +1 attack') were never executed
because AbilityType.Passive had no runtime processing.

Three root causes fixed:

1. Passive abilities are now applied when units enter the battlefield
   and reversed when they leave (new DurationType.WhileSourceOnBattlefield).
   - ApplyPassivesForSource: runs a unit's passives against all current targets
   - ApplyPassivesToNewTarget: applies existing passives to a newly-entered unit
   - RevokePassivesForSource: reverses all passive effects on source death/leave
   - Hooked into GameEngine.Channel, Transition and AbilitySystem
     ReturnToBattlefield, SummonToken, KillUnit, SendToDiscard

2. Action conditions with Subject="Target" now filter per-target instead of
   aborting the entire action (which evaluated against ctx.Source).
   Source-level conditions still gate the whole action; target-level ones
   are evaluated individually and skip non-matching targets.

3. ExecuteActions/ResolveTargets gain a restrictTargets parameter used by
   ApplyPassivesToNewTarget to avoid double-applying existing passive buffs
   to units that already received them when the passive source entered.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-17 15:54:00 -04:00
dingo 92f61dcd76 Ability Range fix 2026-03-13 17:36:57 -04:00
dingo 60268fd310 Ability changes 2026-03-13 09:47:06 -04:00
8e3f64d9d1 Fix: ability WithinRange/IsAdjacentToSource filters + ModelCache web CORS
- AbilitySystem: implement WithinRangeFilter (Manhattan distance min/max) and
  IsAdjacentToSourceFilter in FilterMatches — both were falling through to
  _ => true, so range constraints on targeting were silently ignored
- Program.cs: add GET /cdn/{**path} proxy endpoint with
  Access-Control-Allow-Origin: * so browser web clients can fetch GLB models
  (Ceph RadosGW / cdn.aeternalisgames.com has no CORS headers)
- ModelCache.gd: on web export, rewrite cdn.aeternalisgames.com URLs to go
  through hub.aeternalisgames.com/cdn proxy; disk/memory cache still keyed
  on the original CDN URL for consistency across platforms

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-10 10:39:13 -04:00
da6899b2c7 Fix: include ArchSpirit in Battlefield ability target candidates
BuildCandidates only added p.Field to the candidate pool for
Scope=Battlefield, leaving p.ArchSpirit (stored as a separate
PlayerState property) out. A Unit-typed ability targeting the
opponent's ArchSpirit would match zero candidates → INSUFFICIENT_TARGETS.

Also include p.ArchSpirit in the AnyZone pool for consistency.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-09 22:58:28 -04:00
51a7f9e8d2 Fix: extend $type-anywhere deserialization to Condition, TriggerEvent, and Filter
Refactor EffectPolymorphicConverter into a generic PolymorphicAbilityConverter<T>
base class, add concrete converters for all four abstract ability model types:
Effect, Condition, TriggerEvent, and Filter — all share the same abstract +
[JsonPolymorphic] pattern and the same ordering constraint from the admin builder.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-09 20:17:01 -04:00
5ed0ec87e3 Fix: deserialize polymorphic Effect when $type is not the first JSON property
[JsonPolymorphic] on an abstract base class requires $type to appear first in
the JSON object. Card abilities authored in the admin tool don't guarantee this
ordering (e.g. {"N":1,"$type":"DrawCards","Player":"Owner"}), causing a
NotSupportedException at ParseAbilities time.

Add EffectPolymorphicConverter which overrides CanConvert to intercept only
typeof(Effect) (not concrete derived types). It buffers the full JSON object,
finds $type at any position, looks up the concrete type from the [JsonDerivedType]
attribute map, then deserializes via the default converter. Because CanConvert
returns false for concrete types, there is no infinite recursion even for nested
Effect[] (e.g. ApplyOnEventEffect.Effects).

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-09 19:51:43 -04:00
bc65e8b9d4 Fix: add ExactSelf to TargetOwnership enum + resolve in AbilitySystem
`ExactSelf` was accepted by the admin builder dropdown but crashed on
deserialization because the TargetOwnership enum was missing the value.

- Added `ExactSelf` to `TargetOwnership` enum in Action.cs
- BuildCandidates treats ExactSelf like Self/Owner (actor's player pool)
- ResolveTargets post-filters to ctx.Source.InstanceId when ExactSelf

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-08 17:47:59 -04:00
11ebdc40d7 Fix: abilitiesJson null crash, battlefield popup, ExactSelf ability filter
Client (game_screen.gd):
- Fix crash when clicking a unit with null abilitiesJson: server sends the key
  with a null value, so dict.get(key,default) returns null — guard both uses
  (_show_ability_panel and _on_hold_timer_fired) with explicit null check.
- Add double-click on battlefield units to open a full CardDetailPopup showing
  name, affinity, stats, and ability descriptions. Popup is instantiated once
  in _ready() and reused; aliases movementPoints/abilities keys as expected.

Server (Filters.cs / AbilitySystem.cs):
- IsSelf filter now matches by CardDefinitionId (definition-level: any copy of
  the same card). This is the appropriate semantic for "self" as a type scope.
- IsExactSelf filter added: matches by InstanceId (instance-level: only this
  specific unit on the battlefield). Use this to prevent duplicate-instance
  trigger bleed where two copies of a card both fire when only one acted.
- TriggerMatches now accepts the evaluating FieldCard and forwards its
  InstanceId to Own() for all ownership checks.
- Own() gains "ExactSelf" scope: fires only when occ.Data.SourceId matches the
  evaluating unit's InstanceId — eliminating the definition-level bleed bug.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-03-08 16:28:06 -04:00
c493b1b50b Admin portal: dark mode, account management, chat fixes, ability builder
• Light/dark mode toggle: Bootstrap 5.3 data-bs-theme, theme persisted to
  localStorage via admin.js, Moon/Sun icon button in sidebar, flash-free
  inline <script> in App.razor applies saved theme before first render.

• Account management: Add "Create Account" button + new /accounts/new page
  (email, display name, password, role checkboxes). AccountDetail now has
  interactive role assignment (Add/Remove Admin/SuperAdmin — SuperAdmin
  actions gated with <AuthorizeView Roles="SuperAdmin">) and a force-reset
  password section (RemovePasswordAsync + AddPasswordAsync, no current
  password required).

• Chat fixes: stat card labels changed from text-muted → text-white-50 for
  readability on bg-dark; card-headers now have border-bottom border-secondary
  to visually separate from card bodies; "View" button relabeled "View & Post"
  to surface the hidden compose feature.

• Ability builder (AbilityBuilder.razor): structured UI replacing the raw
  textarea in CardEditor. Supports all 4 ability types (Active/Passive/Aura/
  Triggered) with type-specific fields (range, uses/turn, aura range, trigger
  dropdown). Each ability holds structured actions (scope/type/ownership/count
  dropdowns) and effects (59 types in 11 grouped optgroups; each auto-populates
  a JSON fields template on type selection). Description field stores plain-
  English text in the JSON. Raw JSON toggle + Apply for power users. Live
  compiled JSON preview.

• AbilitySystem: added JsonStringEnumConverter so JSONB enums serialize as
  human-readable strings ("Active" vs 0, "Battlefield" vs 3, etc.).
• AbilityDefinition: added optional Description property (admin-only metadata).

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-27 10:36:02 -05:00
92d2e34a68 Implement missing ability effect handlers and gameplay rules
- GameState: add CardInstance fields — CanBeAttacked, CanBeBlocked,
  CanBeObstructed, CanUseAbility, CanBeSacrificed, ExtraAttacksRemaining,
  FixedSacrificeReturn, DisabledAbilities, IsRevealed
- GameState: add PendingDeferredEffect model + GameState.PendingDeferredEffects
- GameEngine.Attack: enforce CanBeAttacked; ExtraAttacksRemaining (extra
  attacks decrement rather than exhausting)
- GameEngine.Sacrifice: enforce CanBeSacrificed; use FixedSacrificeReturn
  override when set
- GameEngine.EndTurn: reset ExtraAttacksRemaining to 0 with other resets

AbilitySystem effect handlers (18 new):
  §5.1  GrantAdditionalAttackEffect
  §5.2  SetCanBeAttacked/Blocked/Obstructed/UseAbility/BeSacrificed
  §5.3  AddAbility/RemoveAbility/EnableAbility/DisableAbility
  §5.7  ReturnToBattlefield, SearchDeck, RevealCards, PlaceOnDeck
  §5.9  DisplaceUnit (absolute direction: N/S/E/W/NE/NW/SE/SW)
  §5.10 GrantMovementControl, SetFixedSacrificeReturn
  §5.12 ApplyOnEvent (deferred; fires once on trigger; cancelled on source death)

AbilitySystem additions:
- ActivateAbility: enforce CanUseAbility + DisabledAbilities
- FireCardEffects / ActivateAbility: requireClientTargets=true for
  mandatory explicit-target validation (gameplay-todo.md)
- ResolveTargets: empty candidates when clientTargets=null + mandatory
  selector, causing INSUFFICIENT_TARGETS for required but missing targets
- FireTrigger: drain PendingDeferredEffects that match the current event
- KillUnit: cancel PendingDeferredEffects whose source is dying
- ParseDirection, TileMatchesFilters helpers
- CreateTokenFieldCard: copy new CardInstance flag fields

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-26 21:28:41 -05:00
7c89f4d0db Fix ability lock-out guards, implement SummonTokenEffect, thread card targets
- GameEngine.Transition: enforce CanTransitionArchSpirit flag
- GameEngine.ChannelCard: enforce CanChannelSpirit, CanChannelRepentance,
  CanChannelInstinct, CanChannelRuin, CanChannelTerramorphaMono/Di/Tri
- GameEngine.ChannelCard: accept IReadOnlyList<AbilityTarget>? cardTargets;
  thread through FireCardEffects for Repentance/Instinct effects
- AbilitySystem.FireCardEffects: accept and forward clientTargets to ExecuteActions
- AbilitySystem.ExecuteEffect: implement SummonTokenEffect — deserialize TokenDefJson,
  create SpiritToken FieldCard, place on board, fire UnitEnterBattlefield + aura enter
- GamePlayCardRequest: add IReadOnlyList<AbilityTarget>? Targets for unit/tile inputs
- GamePlayCardHandler: pass req.Targets to ChannelCard

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-26 21:10:20 -05:00
dingo ab8dc4a032 Interum manual push 2026-02-26 19:19:34 -05:00
8c5b65192f Add aura range evaluation — EnterAuraRange/LeaveAuraRange triggers
- Add EnterAuraRange and LeaveAuraRange to TriggerEventKind enum
- Add TriggerMatches cases for OnEnterAuraRangeTrigger / OnLeaveAuraRangeTrigger
  with AuraOwnership + UnitOwnerMatches (ally/enemy/any) scope filtering
- Add EvaluateAuraTransitions (on move), EvaluateAurasOnEnter (on channel),
  EvaluateAurasOnLeave (on sacrifice/kill) public methods to AbilitySystem
- Bidirectional evaluation: moving unit vs. stationary auras + moving unit's
  own auras vs. stationary units
- Hook into GameEngine: MoveUnit, ChannelCard (Spirit), Sacrifice
- KillUnit now calls EvaluateAurasOnLeave before board removal

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-26 16:48:50 -05:00
39b80ccbdd Add duration tracking — TrackEffect, TrackTick, ExpireActiveEffects, TickActiveEffects
- ExecuteEffect now builds and stores reversal effects in GameState.ActiveEffects
  for all non-Instant durations (stat deltas, flag toggles, genus, affinity)
- DOT/HOT effects register tick entries instead of reversals
- TrackedDuration wrapper records owner + IsTick flag alongside DurationModel
- ExpireActiveEffects handles UntilEndOfTurn, UntilStartOfOwnerTurn, ForNTurns,
  WhileCondition; applies reversal on expiry for non-tick entries
- TickActiveEffects fires DOT/HOT damage/healing each turn end
- GameEngine.EndTurn: tick → expire(end) after TurnEnd trigger;
  expire(start) after player switch, before TurnStart trigger

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-26 16:35:37 -05:00
be8c0844c6 Add AbilitySystem — core effect execution, trigger hooks, activate_ability handler
- AbilitySystem.cs: full rewrite — ActivateAbility, FireTrigger, FireCardEffects,
  ExecuteActions, ResolveTargets, ExecuteEffect (§5.1–5.10), condition evaluation,
  filter evaluation, trigger matching, value/affinity resolution
- GameState.cs: CardInstance gains AbilitiesJson, EffectsJson, AbilityUsesThisTurn,
  Genus; PlayerState gains SpAccumulationBonus, DrawPerTurnBonus and 12 action-
  restriction flags; GameState gains ActiveEffects list; new ActiveEffect class
- GameMessages.cs: GameActivateAbilityRequest/Response + AbilityTarget DTO
- GameEngine.cs: ActivateAbility public method; trigger hooks in ChannelCard,
  MoveUnit, Attack (UnitAttack + UnitDeath), Sacrifice, EndTurn (TurnEnd/TurnStart),
  Ascend, Transition; AbilitiesJson/EffectsJson copied in DefinitionToInstance,
  BuildPlayerState, ToFieldCard; Repentance/Instinct/Ruin now fire EffectsJson inline
- GameActivateAbilityHandler: game.activate_ability message handler
- ServiceRegistration: register GameActivateAbilityHandler

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-26 16:16:46 -05:00
dingo 2fe3803599 Interum manual push 2026-02-26 13:11:03 -05:00
9b6b7191f0 Add square grid system, positional combat, sacrifice, and Placement phase
Grid infrastructure (SOR.Game/Grid/):
- Coord — immutable (X,Y) struct with Manhattan distance, adjacency, BFS helpers
- Tile — mutable affinity slots (Base1/Base2) + occupancy tracking
- Board — 8×8 (configurable) grid, PlaceUnit/RemoveUnit/MoveUnit/BuildOccupancyMap
- Pathfinding — Walk/Flight BFS (GetReachableWithCost), Jump/Teleport range (GetJumpRange)
- LineOfSight — supercover DDA; occupied intermediate tiles block LOS
- AffinitySystem — full Resolve table for all 20+ affinities per affinity.md,
  PushAffinity, ApplyPlacementAffinity, IsAffinityValid (basic vs non-basic rules)

Combat (SOR.Game/Combat/):
- AttackSystem — Manhattan range + optional LOS validation (§6.10)
- SacrificeSystem — exact ST return formula from gameplay.md §6.15

Abilities (SOR.Game/Abilities/):
- AbilitySystem stub — future pass per abilities.md

Game engine / state changes:
- GamePhase: added Placement phase (before Draw)
- GameRuleSet + GameRules: added BoardWidth/BoardHeight (default 8×8)
- GameState: added Board, PlayerOneAccountId; CardInstance gains MovementType,
  MaxMp, MinAttackRange, MaxAttackRange, RequiresLos, MinChannelRange,
  MaxChannelRange, IsLeader (moved from FieldCard); FieldCard adds Position + CurrentMp
- [JsonPolymorphic] on CardInstance so FieldCard survives JSONB round-trip
- JsonStringEnumConverter added to GameEngine serializer options
- GameEngine.Initialize: creates Board + sets Placement phase; no opening draw yet
- GameEngine.PlaceArchSpirit: validates row, pushes affinity, triggers opening draw
  and SP gain when both players placed
- GameEngine.ChannelCard (was PlayCard): validates channeling range + affinity for Spirits
- GameEngine.MoveUnit: Walk/Flight BFS, Jump (1 MP/landing), Teleport (LOS + 1 MP)
- GameEngine.Attack: adds range+LOS validation via AttackSystem
- GameEngine.Sacrifice: adjacency + SacrificeSystem ST formula
- GameEngine.EndTurn: now also restores MP (§6.0 step 1) for next player
- ToDto: includes Board tiles with resolved affinities; CardInstanceDto gets Position,
  CurrentMp, MaxMp, MovementType

New handlers: game.place_arch_spirit, game.move_unit, game.sacrifice
Updated handlers: game.play_card (target tile), GameReadyHandler (new Initialize sig)
Migration: AddBoardDimensions (board_width/board_height on game_rule_sets)

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
2026-02-26 11:22:30 -05:00