feat(ability): implement AbilityBuilderR3 + engine additions

Engine:
- AbilityDefinition: add SourceZoneGate (zone-restricted triggers) and TriggerLimitPerGame
- Effects: add StatModOperator (Add/Subtract/Multiply/Divide/Percent) on all stat mod effects; reversal stored as delta
- Action/CostEntry: add CostPickMode enum (Random/SelfPick/EnemySeePick/EnemyRandomPick/EnemyPick)
- PendingCostPick: new model for interactive cost pause/resume (mirrors PendingTriggeredTarget)
- GameState: PendingCostPick field
- GameMessages: CostPickRequestPush, GameCostPickRequest, GameCostPickResponse records
- AbilitySystem: FireTrigger scans Hand/Discard/Deck when SourceZoneGate set; per-game trigger limit tracking; ApplyStatOperator helper; PayCosts/ResumeCostPick for interactive cost flow
- GameCostPickHandler + ServiceRegistration wiring

Admin:
- AbilityBuilderR3.razor: full ability builder at /cards/ability-builder-r3 (39 triggers, 69 effects, 32 conditions, form/canvas/mermaid modes, compiles to engine-native $type JSON)
- AbilityBuilderR2-Draft.razor: fix switch expression no-best-type error

Docs:
- BuilderR3.md: master plan document

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>
This commit is contained in:
dingo
2026-04-18 20:15:13 -04:00
co-authored by Claude Happy
parent 26fa4c810d
commit 8f3911e881
20 changed files with 5290 additions and 133 deletions
+38
View File
@@ -67,6 +67,7 @@ var _message_poll_timer: Timer = null
var _message_poll_in_flight: Dictionary = {}
var _bubble_visible_requested := false
var _bubble_host: Control = null
var _bubble_visibility_owners: Dictionary = {}
const MESSAGE_POLL_INTERVAL_SEC := 0.2
@@ -112,6 +113,7 @@ func _on_auth_success(_uid: String, _dn: String) -> void:
## (e.g. MainScreen._ready / _exit_tree).
func set_bubble_visible(v: bool) -> void:
_bubble_visible_requested = v
_bubble_visibility_owners.clear()
if is_instance_valid(_overlay):
if _overlay.has_method("set_overlay_visible"):
_overlay.call("set_overlay_visible", v)
@@ -119,6 +121,20 @@ func set_bubble_visible(v: bool) -> void:
_overlay.visible = v
func claim_bubble_visibility(owner: Node) -> void:
if not is_instance_valid(owner):
return
_bubble_visibility_owners[owner.get_instance_id()] = weakref(owner)
_apply_bubble_visibility()
func release_bubble_visibility(owner: Node) -> void:
if not is_instance_valid(owner):
return
_bubble_visibility_owners.erase(owner.get_instance_id())
_apply_bubble_visibility()
func set_bubble_host(host: Control) -> void:
_bubble_host = host
if is_instance_valid(_overlay) and _overlay.has_method("set_bubble_host"):
@@ -128,6 +144,7 @@ func set_bubble_host(host: Control) -> void:
func _clear_state() -> void:
_bubble_visible_requested = false
_bubble_host = null
_bubble_visibility_owners.clear()
if is_instance_valid(_overlay):
if _overlay.has_method("set_overlay_visible"):
_overlay.call("set_overlay_visible", false)
@@ -355,6 +372,27 @@ func _setup_message_polling() -> void:
add_child(_message_poll_timer)
func _apply_bubble_visibility() -> void:
var stale_ids: Array = []
var should_show := false
for owner_id: Variant in _bubble_visibility_owners.keys():
var owner_ref: WeakRef = _bubble_visibility_owners[owner_id]
var owner : Variant = owner_ref.get_ref()
if owner == null:
stale_ids.append(owner_id)
continue
should_show = true
for owner_id: Variant in stale_ids:
_bubble_visibility_owners.erase(owner_id)
_bubble_visible_requested = should_show
if is_instance_valid(_overlay):
if _overlay.has_method("set_overlay_visible"):
_overlay.call("set_overlay_visible", should_show)
else:
_overlay.visible = should_show
func _start_message_polling() -> void:
if is_instance_valid(_message_poll_timer):
_message_poll_timer.start()