From 2b7b6aa2baa49fb0993172223ab5848227e16336 Mon Sep 17 00:00:00 2001 From: dingo Date: Mon, 23 Mar 2026 13:55:36 -0400 Subject: [PATCH] Fixed but in AbilitySystem for resolving affinity --- .claude/plan.md | 126 +----------------- .claude/settings.local.json | 4 +- .../components/notification_row.gd.uid | 1 + .../collection/components/ability_row.gd.uid | 1 + .../collection/components/stat_row.gd.uid | 1 + .../components/deck_picker_button.gd.uid | 1 + .../components/active_game_row.gd.uid | 1 + .../components/lobby_browser_row.gd.uid | 1 + .../components/rules_editor_dialog.gd.uid | 1 + .../components/leaderboard_row.gd.uid | 1 + .../components/starter_deck_card.gd.uid | 1 + .../src/SOR.Game/Abilities/AbilitySystem.cs | 2 +- Server/src/SOR.Game/Grid/AffinitySystem.cs | 15 +++ 13 files changed, 29 insertions(+), 127 deletions(-) create mode 100644 Client/origin-client/scenes/account/components/notification_row.gd.uid create mode 100644 Client/origin-client/scenes/collection/components/ability_row.gd.uid create mode 100644 Client/origin-client/scenes/collection/components/stat_row.gd.uid create mode 100644 Client/origin-client/scenes/common/components/deck_picker_button.gd.uid create mode 100644 Client/origin-client/scenes/free_play/components/active_game_row.gd.uid create mode 100644 Client/origin-client/scenes/free_play/components/lobby_browser_row.gd.uid create mode 100644 Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd.uid create mode 100644 Client/origin-client/scenes/leaderboard/components/leaderboard_row.gd.uid create mode 100644 Client/origin-client/scenes/starter_deck/components/starter_deck_card.gd.uid diff --git a/.claude/plan.md b/.claude/plan.md index cc5eb42..0bfdcfd 100644 --- a/.claude/plan.md +++ b/.claude/plan.md @@ -1,125 +1 @@ -# Plan: Deferred Rebuild + Movement Path Animation - -## Goal -1. Let attack/damage/death animations play to completion before `_rebuild_units` destroys the nodes. -2. Move units along a BFS path (avoiding occupied tiles) while playing the Moving animation, before the rebuild snaps them to their new positions. -3. Hand and HUD update immediately; only the board (unit nodes) is delayed. - ---- - -## New constants (near ANIM_ALIASES) -```gdscript -const MOVE_STEP_SECS : float = 0.28 # seconds per grid step during move anim -const POST_ANIM_SECS : float = 1.2 # seconds to hold after one-shot anims -``` - -## New state variables (near _prev_unit_hp) -```gdscript -var _prev_unit_pos : Dictionary = {} # instanceId → Vector2i -var _move_anims : Dictionary = {} # instanceId → Tween -var _pending_rebuild : Dictionary = {} # latest state awaiting delayed rebuild -var _rebuild_tween : Tween = null -``` - ---- - -## New functions - -### `_update_prev_state(state)` — replaces HP tracking in _rebuild_units -Called immediately in `_on_state_updated` (before the delayed rebuild) so the -next state update has correct baselines for both HP and position. - -```gdscript -func _update_prev_state(state: Dictionary) -> void: - _prev_unit_hp.clear() - _prev_unit_pos.clear() - for player: Dictionary in state.get("players", []): - var arch := player.get("archSpirit", {}) - for unit: Dictionary in ([arch] + player.get("field", [])): - if unit.is_empty(): continue - var iid := str(unit.get("instanceId", "")) - if iid.is_empty(): continue - _prev_unit_hp[iid] = int(unit.get("currentHealth", 0)) - var pd = unit.get("position") - if pd is Dictionary and not pd.is_empty(): - _prev_unit_pos[iid] = Vector2i(pd.get("x",0), pd.get("y",0)) -``` - -### `_bfs_path(from, to, blocked)` → `Array[Vector2i]` -4-directional BFS. `blocked` is `Dictionary[Vector2i, true]` of impassable tiles; -the destination is always treated as passable. -Returns the list of steps NOT including `from`, INCLUDING `to`. -Falls back to `[to]` if no path found (shouldn't happen on a connected grid). - -### `_animate_unit_move(iid, from_coord, to_coord, blocked)` → `float` -1. Look up `_unit_bodies[iid]`; guard with `is_instance_valid`. -2. BFS path from `from_coord` to `to_coord` using `blocked`. -3. Kill any existing tween in `_move_anims[iid]`. -4. Call `_play_unit_anim(iid, "moving", true)` (looping). -5. Create Tween (EASE_IN_OUT / TRANS_SINE). For each step in path, tween - `body.position` to `Vector3(wp.x, body.position.y, wp.z)` over `MOVE_STEP_SECS`. - (Keep body's current Y so placeholder and model heights both work.) -6. Chain a callback: erase from `_move_anims`, call `_play_unit_anim(iid,"idle",true)`. -7. Store tween in `_move_anims[iid]`. -8. Return `path.size() * MOVE_STEP_SECS`. - -### `_play_move_animations(state)` → `float` -Called before rebuild, using `_prev_unit_pos` as the "before" snapshot. -- Build `blocked: Dictionary` from all values in `_prev_unit_pos`. -- For each unit in `state` that has a position change vs `_prev_unit_pos`: - - Erase the mover's old coord from `blocked` (they've left it). - - Call `_animate_unit_move(iid, old, new, blocked)`. - - Track max duration. -- Returns max duration across all movers. - -### `_schedule_rebuild(state, delay)` → `void` -- Store `state` in `_pending_rebuild`. -- Kill + null `_rebuild_tween` if one exists. -- If `delay <= 0`: call `_rebuild_units(state)` synchronously and return. -- Else: `_rebuild_tween = create_tween()`, `.tween_callback(λ).set_delay(delay)`. - The lambda: `_rebuild_tween = null; _rebuild_units(_pending_rebuild)`. - ---- - -## Modified functions - -### `_play_damage_animations` — returns `bool` -Change return type from `void` to `bool`. -Return `true` if any `_play_unit_anim` call was made (HP drop or missing unit). - -### `_rebuild_units` -- **Remove** the HP tracking block at the bottom (moved to `_update_prev_state`). -- **Remove** `_prev_unit_hp.clear()` — no longer owned here. -- **Add** at the top: kill all tweens in `_move_anims`, then `.clear()` it. - -### `_add_unit_mesh` — model load callback -In the model load callback, before `b.position = wp + Vector3(0,0.5,0)`, check: -```gdscript -if not _move_anims.has(iid): # only reset pos if not currently moving - b.position = wp + Vector3(0, 0.5, 0) -``` -This prevents a loaded model from snapping back to the original tile mid-tween. - -### `_on_state_updated` — new structure -``` -1. print / _rebuild_ownership / camera / board [unchanged, immediate] -2. _play_move_animations(state) → move_dur -3. _play_damage_animations(state) → dmg_played -4. [immediate UI] _rebuild_hand(Game.get_hand()), _update_hud(state), print -5. _update_prev_state(state) [update tracking now, before delayed rebuild] -6. delay = move_dur; if dmg_played: delay = maxf(delay, POST_ANIM_SECS) -7. _schedule_rebuild(state, delay) -8. [selection restoration match block — immediate, same as before] -9. [auto-draw await — same as before] -``` - ---- - -## What this achieves -- Attack animation fires on click → plays for ~1-2s → state update arrives → - damage anim plays → 1.2s delay → rebuild. Total: seamless. -- Unit moves → move animation plays cell-by-cell along BFS path → - rebuild fires after path completes. Hand/HUD update immediately. -- If a new state arrives during the delay (rapid opponent actions), the - pending rebuild is replaced with the latest state; old animations may - be cut short, which is acceptable. +# Tile Highlight Texture System \ No newline at end of file diff --git a/.claude/settings.local.json b/.claude/settings.local.json index fe3ed44..34911f3 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -12,7 +12,9 @@ "Bash(dotnet ef database update:*)", "Bash(dotnet ef migrations list:*)", "Bash(ls -la \"C:\\\\GameDev\\\\SOR\\\\Server\\\\src\\\\SOR.Content\\\\Handlers\"\" 2>/dev/null || echo \"Directory not found \")", - "Bash(ls -la \"C:\\\\GameDev\\\\SOR\\\\Server\\\\src\\\\SOR.Cdn\"\" | grep -i \"cdnclient|httpclient \")" + "Bash(ls -la \"C:\\\\GameDev\\\\SOR\\\\Server\\\\src\\\\SOR.Cdn\"\" | grep -i \"cdnclient|httpclient \")", + "Bash(dotnet ef migrations add:*)", + "Bash(wc:*)" ] } } diff --git a/Client/origin-client/scenes/account/components/notification_row.gd.uid b/Client/origin-client/scenes/account/components/notification_row.gd.uid new file mode 100644 index 0000000..d379a3e --- /dev/null +++ b/Client/origin-client/scenes/account/components/notification_row.gd.uid @@ -0,0 +1 @@ +uid://q0hlke8ixefd diff --git a/Client/origin-client/scenes/collection/components/ability_row.gd.uid b/Client/origin-client/scenes/collection/components/ability_row.gd.uid new file mode 100644 index 0000000..be9ad6d --- /dev/null +++ b/Client/origin-client/scenes/collection/components/ability_row.gd.uid @@ -0,0 +1 @@ +uid://ci4kls86gx7tt diff --git a/Client/origin-client/scenes/collection/components/stat_row.gd.uid b/Client/origin-client/scenes/collection/components/stat_row.gd.uid new file mode 100644 index 0000000..122f14e --- /dev/null +++ b/Client/origin-client/scenes/collection/components/stat_row.gd.uid @@ -0,0 +1 @@ +uid://cqckgl1qcf4ig diff --git a/Client/origin-client/scenes/common/components/deck_picker_button.gd.uid b/Client/origin-client/scenes/common/components/deck_picker_button.gd.uid new file mode 100644 index 0000000..6ee23ef --- /dev/null +++ b/Client/origin-client/scenes/common/components/deck_picker_button.gd.uid @@ -0,0 +1 @@ +uid://palraukmfkql diff --git a/Client/origin-client/scenes/free_play/components/active_game_row.gd.uid b/Client/origin-client/scenes/free_play/components/active_game_row.gd.uid new file mode 100644 index 0000000..1fe93ba --- /dev/null +++ b/Client/origin-client/scenes/free_play/components/active_game_row.gd.uid @@ -0,0 +1 @@ +uid://duvpyqc2piams diff --git a/Client/origin-client/scenes/free_play/components/lobby_browser_row.gd.uid b/Client/origin-client/scenes/free_play/components/lobby_browser_row.gd.uid new file mode 100644 index 0000000..00a125f --- /dev/null +++ b/Client/origin-client/scenes/free_play/components/lobby_browser_row.gd.uid @@ -0,0 +1 @@ +uid://bj0b8omrekgug diff --git a/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd.uid b/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd.uid new file mode 100644 index 0000000..9358cca --- /dev/null +++ b/Client/origin-client/scenes/free_play/components/rules_editor_dialog.gd.uid @@ -0,0 +1 @@ +uid://dogruvcpjj2rt diff --git a/Client/origin-client/scenes/leaderboard/components/leaderboard_row.gd.uid b/Client/origin-client/scenes/leaderboard/components/leaderboard_row.gd.uid new file mode 100644 index 0000000..a30308c --- /dev/null +++ b/Client/origin-client/scenes/leaderboard/components/leaderboard_row.gd.uid @@ -0,0 +1 @@ +uid://c08ks64fno7sd diff --git a/Client/origin-client/scenes/starter_deck/components/starter_deck_card.gd.uid b/Client/origin-client/scenes/starter_deck/components/starter_deck_card.gd.uid new file mode 100644 index 0000000..4320d9b --- /dev/null +++ b/Client/origin-client/scenes/starter_deck/components/starter_deck_card.gd.uid @@ -0,0 +1 @@ +uid://dlg1akq48dcvm diff --git a/Server/src/SOR.Game/Abilities/AbilitySystem.cs b/Server/src/SOR.Game/Abilities/AbilitySystem.cs index 0884836..6fb99b9 100644 --- a/Server/src/SOR.Game/Abilities/AbilitySystem.cs +++ b/Server/src/SOR.Game/Abilities/AbilitySystem.cs @@ -1558,7 +1558,7 @@ public static class AbilitySystem { var tile = ctx.State.Board.GetTile(fc.Position.Value); return tile is not null - && AffinitySystem.Resolve(tile.Base1, tile.Base2) == iotwa.Affinity; + && AffinitySystem.IsAffinityValid(tile, iotwa.Affinity); } case MovementTypeIsCondition mti when subject is CardInstance ci: return ci.MovementType == mti.MovementType; diff --git a/Server/src/SOR.Game/Grid/AffinitySystem.cs b/Server/src/SOR.Game/Grid/AffinitySystem.cs index 6292008..1d25ada 100644 --- a/Server/src/SOR.Game/Grid/AffinitySystem.cs +++ b/Server/src/SOR.Game/Grid/AffinitySystem.cs @@ -156,10 +156,25 @@ public static class AffinitySystem if (Resolve(tile.Base1, tile.Base2) == Affinity.PerfectAether && ElementalBasics.Contains(cardAffinity)) return true; + if (Resolve(tile.Base1, tile.Base2) == Affinity.UnstableAether) + return false; if (BasicAffinities.Contains(cardAffinity)) return tile.Base1 == cardAffinity || tile.Base2 == cardAffinity; return Resolve(tile.Base1, tile.Base2) == cardAffinity; } + + /// + /// Checks if Tile is a Basic Affinity + /// + public static bool IsBasicAffinity(Affinity affinity) + { + if (affinity == Affinity.Lake || + affinity == Affinity.Hill || + affinity == Affinity.Field || + affinity == Affinity.Forest) + return true; + else return false; + } }