Client fixes, and ability fixes

This commit is contained in:
dingo
2026-04-30 19:27:52 -04:00
parent b985445ae9
commit ee21346fb0
11 changed files with 1446 additions and 70 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
{
"godotTools.editorPath.godot4": "c:\\Users\\tazj2\\OneDrive\\Desktop\\Godot_v4.5.1-stable_win64.exe\\Godot_v4.5.1-stable_win64_console.exe"
"godotTools.editorPath.godot4": "c:\\GameDev\\Godot_v4.5.1-stable_win64.exe"
}
@@ -443,7 +443,6 @@ anchor_top = 1.0
anchor_right = 0.75
anchor_bottom = 1.0
offset_top = -200.0
offset_bottom = 0.0
[node name="SpectatorMargin" type="MarginContainer" parent="HUD/SpectatorPlayersPanel"]
layout_mode = 2
+285 -26
View File
@@ -127,12 +127,16 @@ const _CARD_WIDGET_SCENE := preload("res://scenes/collection/components/CardWi
const _HAND_ARROW_REGULAR := preload("res://ui/icons/Green_Gem_Arrow_Button_Regular.png")
const _HAND_ARROW_HOVER := preload("res://ui/icons/Green_Gem_Arrow_Button_Hover.png")
const _HAND_ARROW_PRESSED := preload("res://ui/icons/Green_Gem_Arrow_Button_Click.png")
const _HITSPLAT_SHIELD_ICON := preload("res://ui/icons/Shield_Overlay_Gradient.png")
const _HITSPLAT_HEART_ICON := preload("res://ui/icons/Heart_Overlay_Gradient.png")
const HI_GREEN := Color(0.20, 0.90, 0.20, 0.40)
const HI_RED := Color(1.00, 0.25, 0.25, 0.50)
const HI_BLUE := Color(0.20, 0.50, 1.00, 0.40)
const HI_YELLOW := Color(1.00, 0.85, 0.10, 0.50)
const HI_ORANGE := Color(1.00, 0.60, 0.10, 0.45)
const HITSPLAT_LIFETIME := 0.75
const HITSPLAT_RISE_PIXELS := 42.0
# ── Camera state ──────────────────────────────────────────────────────────────
@@ -268,12 +272,16 @@ var _ambient_star_ctr : int = 0 # counter for unique ambient IDs
# ── Animation / facing state ───────────────────────────────────────────────────
var _local_is_p1 : bool = false # true when Auth.user_id == playerOneAccountId
var _prev_unit_hp : Dictionary = {} # instanceId → int, HP snapshot for damage detection
var _prev_unit_def: Dictionary = {} # instanceId → int, DEF snapshot for damage detection
var _prev_unit_pos: Dictionary = {} # instanceId → Vector2i, position snapshot for move detection
var _move_anims : Dictionary = {} # instanceId → Tween (active movement tweens)
var _last_attack_source_iid : String = "" # source of the most recent send_attack() call
var _last_attack_target_iid : String = "" # target of the most recent send_attack() call
var _tile_heights : Dictionary = {} # "x,y" → float, height of tile block
var _tile_y_bases : Dictionary = {} # "x,y" → float, vertical stagger offset
var _tile_visual_tops : Dictionary = {} # "x,y" → float, actual visual top Y in world space (updated after model loads)
var _hitsplat_layer : Control = null
var _hitsplat_canvas_layer : CanvasLayer = null
# Delayed rebuild: when animations need time to play we don't destroy unit nodes immediately.
var _pending_rebuild : Dictionary = {} # latest state waiting for the delayed rebuild
@@ -382,6 +390,7 @@ func _ready() -> void:
# Chat overlay — add to viewport root so it renders above everything.
Chat.claim_bubble_visibility(self)
Chat.set_bubble_host(_chat_bubble_host)
_ensure_hitsplat_layer()
if Game.is_spectating:
_is_spectating = true
@@ -404,6 +413,138 @@ func _process(delta: float) -> void:
env.sky_rotation.y += delta * SKY_ROTATION_SPEED
func _ensure_hitsplat_layer() -> Control:
if is_instance_valid(_hitsplat_layer):
return _hitsplat_layer
# Own CanvasLayer (layer 15) so hitsplats always render above the HUD (10)
# and all dynamic panels added to _hud, but below card popups (20).
_hitsplat_canvas_layer = CanvasLayer.new()
_hitsplat_canvas_layer.layer = 15
_hitsplat_canvas_layer.name = "HitsplatCanvas"
add_child(_hitsplat_canvas_layer)
_hitsplat_layer = Control.new()
_hitsplat_layer.name = "HitsplatLayer"
_hitsplat_layer.mouse_filter = Control.MOUSE_FILTER_IGNORE
_hitsplat_canvas_layer.add_child(_hitsplat_layer)
_hitsplat_layer.set_anchors_preset(Control.PRESET_FULL_RECT)
return _hitsplat_layer
func _hitsplat_screen_pos(iid: String) -> Vector2:
var body := _unit_bodies.get(iid) as StaticBody3D
if not is_instance_valid(body):
return Vector2.ZERO
var above_tile := float(body.get_meta("above_tile", 0.28))
var world_pos := body.global_position + Vector3(0.0, above_tile + 0.9, 0.0)
return _camera.unproject_position(world_pos)
func _queue_hitsplats(iid: String, def_amount: int, hp_amount: int, delay: float = 0.0) -> void:
if def_amount <= 0 and hp_amount <= 0:
return
if delay > 0.0:
var queued_iid := iid
var queued_def := def_amount
var queued_hp := hp_amount
var queued_anchor := _hitsplat_screen_pos(iid)
var t := create_tween()
t.tween_callback(func() -> void:
if queued_anchor == Vector2.ZERO:
_show_hitsplats(queued_iid, queued_def, queued_hp)
else:
_show_hitsplats_at_anchor(queued_iid, queued_def, queued_hp, queued_anchor)
).set_delay(delay)
return
_show_hitsplats(iid, def_amount, hp_amount)
func _show_hitsplats_once(shown: Dictionary, iid: String, def_amount: int, hp_amount: int,
delay: float = 0.0) -> void:
if def_amount <= 0 and hp_amount <= 0:
return
if shown.has(iid):
return
shown[iid] = true
_queue_hitsplats(iid, def_amount, hp_amount, delay)
func _show_hitsplats(iid: String, def_amount: int, hp_amount: int) -> void:
print("[HITSPLAT] _show_hitsplats iid=%s def=%d hp=%d" % [iid.substr(0, 8), def_amount, hp_amount])
if not _unit_bodies.has(iid):
print("[HITSPLAT] skipped — iid not in _unit_bodies")
return
var anchor := _hitsplat_screen_pos(iid)
if anchor == Vector2.ZERO:
print("[HITSPLAT] skipped — anchor is Vector2.ZERO (body invalid or not yet placed)")
return
_show_hitsplats_at_anchor(iid, def_amount, hp_amount, anchor)
func _show_hitsplats_at_anchor(iid: String, def_amount: int, hp_amount: int, anchor: Vector2) -> void:
if def_amount > 0:
_spawn_hitsplat(iid, def_amount, "Shield", _HITSPLAT_SHIELD_ICON, Color(0.24, 0.58, 1.0), anchor)
if hp_amount > 0:
# When both fire, delay the heart so shield appears first.
if def_amount > 0:
var q_iid := iid
var q_hp := hp_amount
var q_anchor := anchor
var t := create_tween()
t.tween_callback(func() -> void:
_spawn_hitsplat(q_iid, q_hp, "Heart", _HITSPLAT_HEART_ICON, Color(0.92, 0.24, 0.24), q_anchor)
).set_delay(0.2)
else:
_spawn_hitsplat(iid, hp_amount, "Heart", _HITSPLAT_HEART_ICON, Color(0.92, 0.24, 0.24), anchor)
func _spawn_hitsplat(iid: String, amount: int, icon_label: String, icon: Texture2D, tint: Color, anchor: Vector2) -> void:
print("[HITSPLAT] %s amount=%d iid=%s" % [icon_label, amount, iid.substr(0, 8)])
if amount <= 0:
print("[HITSPLAT] skipped — amount <= 0")
return
var layer := _ensure_hitsplat_layer()
if not is_instance_valid(layer):
print("[HITSPLAT] skipped — layer invalid")
return
print("[HITSPLAT] spawning at screen pos %s" % anchor)
var root := Control.new()
root.mouse_filter = Control.MOUSE_FILTER_IGNORE
root.size = Vector2(96.0, 40.0)
root.pivot_offset = root.size * 0.5
root.position = anchor - root.size * 0.5 + Vector2(0.0, -14.0)
layer.add_child(root)
var icon_rect := TextureRect.new()
icon_rect.texture = icon
icon_rect.expand_mode = TextureRect.EXPAND_IGNORE_SIZE
icon_rect.stretch_mode = TextureRect.STRETCH_KEEP_ASPECT_CENTERED
icon_rect.position = Vector2(0.0, 2.0)
icon_rect.size = Vector2(34.0, 34.0)
icon_rect.modulate = tint
root.add_child(icon_rect)
var lbl := Label.new()
lbl.text = str(amount)
lbl.position = Vector2(28.0, 0.0)
lbl.size = Vector2(68.0, 36.0)
lbl.horizontal_alignment = HORIZONTAL_ALIGNMENT_LEFT
lbl.vertical_alignment = VERTICAL_ALIGNMENT_CENTER
lbl.add_theme_font_size_override("font_size", 20)
lbl.add_theme_color_override("font_color", Color.WHITE)
root.add_child(lbl)
var tw := create_tween()
tw.set_parallel(true)
tw.tween_property(root, "position", root.position + Vector2(0.0, -HITSPLAT_RISE_PIXELS), HITSPLAT_LIFETIME)\
.set_trans(Tween.TRANS_CUBIC).set_ease(Tween.EASE_OUT)
tw.tween_property(root, "modulate:a", 0.0, HITSPLAT_LIFETIME)\
.set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_IN)
tw.finished.connect(func() -> void:
if is_instance_valid(root):
root.queue_free()
)
func _exit_tree() -> void:
if _is_spectating:
Game.stop_spectating()
@@ -1311,7 +1452,9 @@ func _is_ruin_instance(instance_id: String) -> bool:
func _tile_has_blocking_occupant(tile: Dictionary) -> bool:
var occupant_id := str(tile.get("occupantId", ""))
if occupant_id.is_empty() or occupant_id == "null":
print("[TileBlock] failing out")
return false
print("[TileBlock] returning this: ", not _is_ruin_instance(occupant_id))
return not _is_ruin_instance(occupant_id)
@@ -2167,25 +2310,50 @@ func _override_oneshot(iid: String, cb: Callable) -> void:
_oneshot_callbacks[iid] = cb
func _unit_action_duration(iid: String, action: String, fallback: float = 0.35) -> float:
var ap : AnimationPlayer = _anim_players.get(iid, null)
if ap == null or not is_instance_valid(ap):
return fallback
var def_id : String = _unit_def_ids.get(iid, "")
var desired := action
if not def_id.is_empty():
var override := ContentCache.get_anim_track(def_id, action)
if not override.is_empty():
desired = override
var track := _resolve_anim_track(ap, desired.to_lower())
if track.is_empty():
return fallback
var anim := ap.get_animation(track)
if anim == null:
return fallback
return maxf(fallback, float(anim.length))
## Counterattack phase 2: defender plays "attack", then triggers attacker "damaged".
func _play_counter_attack(defender_iid: String, attacker_iid: String) -> void:
func _play_counter_attack(defender_iid: String, attacker_iid: String,
attacker_def_loss: int, attacker_hp_loss: int, hitsplats_shown: Dictionary) -> void:
if not _unit_bodies.has(defender_iid): return
if not is_instance_valid(_unit_bodies.get(defender_iid) as Node): return
_play_unit_anim(defender_iid, "attack", false)
SFX.play(_sfx_for_unit(defender_iid, "attackSoundUrl"))
# After the counter-attack finishes: defender → idle, attacker → damaged.
_override_oneshot(defender_iid, func(_n: String) -> void:
var counter_time := _unit_action_duration(defender_iid, "attack")
var t := create_tween()
t.tween_callback(func() -> void:
_play_unit_anim(defender_iid, "idle", true)
if _unit_bodies.has(attacker_iid) and \
is_instance_valid(_unit_bodies.get(attacker_iid) as Node):
_play_unit_anim(attacker_iid, "damaged", false)
SFX.play(_sfx_for_unit(attacker_iid, "damagedSoundUrl"))
)
_show_hitsplats_once(hitsplats_shown, attacker_iid, attacker_def_loss, attacker_hp_loss)
).set_delay(counter_time)
## Full counterattack chain (starts after [param delay] seconds):
## delay → defender "damaged" → defender "attack" → attacker "damaged" + defender "idle"
func _play_counter_chain(defender_iid: String, attacker_iid: String, delay: float) -> void:
func _play_counter_chain(defender_iid: String, attacker_iid: String, delay: float,
defender_def_loss: int, defender_hp_loss: int,
attacker_def_loss: int, attacker_hp_loss: int,
hitsplats_shown: Dictionary) -> void:
var t := create_tween()
t.tween_callback(func() -> void:
if not _unit_bodies.has(defender_iid) or \
@@ -2193,9 +2361,12 @@ func _play_counter_chain(defender_iid: String, attacker_iid: String, delay: floa
return
_play_unit_anim(defender_iid, "damaged", false)
SFX.play(_sfx_for_unit(defender_iid, "damagedSoundUrl"))
_override_oneshot(defender_iid, func(_n: String) -> void:
_play_counter_attack(defender_iid, attacker_iid)
)
_show_hitsplats_once(hitsplats_shown, defender_iid, defender_def_loss, defender_hp_loss)
var damaged_time := _unit_action_duration(defender_iid, "damaged")
var td := create_tween()
td.tween_callback(func() -> void:
_play_counter_attack(defender_iid, attacker_iid, attacker_def_loss, attacker_hp_loss, hitsplats_shown)
).set_delay(damaged_time)
).set_delay(delay)
@@ -2225,34 +2396,55 @@ func _play_damage_animations(state: Dictionary) -> bool:
attack_remaining = maxf(0.0,
ap2.current_animation_length - ap2.current_animation_position)
break
if attacker_iid.is_empty() and not _last_attack_source_iid.is_empty() \
and _unit_bodies.has(_last_attack_source_iid):
attacker_iid = _last_attack_source_iid
attack_remaining = _unit_action_duration(attacker_iid, "attack")
# ── Collect who took damage / died ───────────────────────────────────────
var damaged_iids : Dictionary = {}
var defense_hits : Dictionary = {}
var health_hits : Dictionary = {}
var seen_iids : Dictionary = {}
for player: Dictionary in state.get("players", []):
var _arch_raw = player.get("archSpirit")
var _arch_list : Array = [] if _arch_raw == null else [_arch_raw]
for unit: Dictionary in (_arch_list + player.get("field", [])):
if unit.is_empty(): continue
var iid := str(unit.get("instanceId", ""))
var _hp_v = unit.get("currentHealth")
var new_hp := 0 if _hp_v == null else int(_hp_v)
var old_hp : int = _prev_unit_hp.get(iid, new_hp)
var iid := str(unit.get("instanceId", ""))
var _hp_v = unit.get("currentHealth")
var _def_v = unit.get("currentDefense")
var new_hp := 0 if _hp_v == null else int(_hp_v)
var new_def := 0 if _def_v == null else int(_def_v)
var old_hp : int = _prev_unit_hp.get(iid, new_hp)
var old_def : int = _prev_unit_def.get(iid, new_def)
seen_iids[iid] = true
if new_def < old_def:
defense_hits[iid] = old_def - new_def
if new_hp < old_hp:
health_hits[iid] = old_hp - new_hp
damaged_iids[iid] = true
var dying_iids : Dictionary = {}
for iid: String in _prev_unit_hp:
if not seen_iids.has(iid):
dying_iids[iid] = true
var dying_old_hp := int(_prev_unit_hp.get(iid, 0))
if dying_old_hp > 0:
health_hits[iid] = dying_old_hp
# Consume tracked target before any early return so it never bleeds into
# the next state update (e.g. a fully-blocked hit with 0 HP change).
var tracked_source : String = _last_attack_source_iid
var tracked_target : String = _last_attack_target_iid
_last_attack_source_iid = ""
_last_attack_target_iid = ""
if attacker_iid.is_empty() and not tracked_source.is_empty() and _unit_bodies.has(tracked_source):
attacker_iid = tracked_source
attack_remaining = _unit_action_duration(attacker_iid, "attack")
var hitsplats_shown : Dictionary = {}
if damaged_iids.is_empty() and dying_iids.is_empty():
if damaged_iids.is_empty() and defense_hits.is_empty() and dying_iids.is_empty():
# Fully-blocked attack: attacker is mid-swing but the defender's defense
# absorbed all damage → no HP change, but play the blocked SFX.
if attacker_iid != "" and not tracked_target.is_empty() \
@@ -2267,6 +2459,21 @@ func _play_damage_animations(state: Dictionary) -> bool:
SFX.play(_sfx_for_unit(blocked_iid, "blockedSoundUrl"))
return false
if damaged_iids.is_empty() and not defense_hits.is_empty():
for iid: String in defense_hits:
_show_hitsplats_once(hitsplats_shown, iid, int(defense_hits.get(iid, 0)), 0, attack_remaining)
if attacker_iid != "" and not tracked_target.is_empty() \
and tracked_target != attacker_iid:
var blocked_iid := tracked_target
if attack_remaining > 0.0:
var tb2 := create_tween()
tb2.tween_callback(func() -> void:
SFX.play(_sfx_for_unit(blocked_iid, "blockedSoundUrl"))
).set_delay(attack_remaining)
else:
SFX.play(_sfx_for_unit(blocked_iid, "blockedSoundUrl"))
return false
# ── Detect counterattack: attacker took damage while mid-attack ─────────
# The defender may have blocked all HP damage (defense stat), so we can't
# rely on them being in damaged_iids. Use the tracked target from the last
@@ -2286,26 +2493,62 @@ func _play_damage_animations(state: Dictionary) -> bool:
break
is_counterattack = defender_iid != ""
var display_delay := attack_remaining if attacker_iid != "" else 0.0
for iid: String in seen_iids:
_show_hitsplats_once(
hitsplats_shown,
iid,
int(defense_hits.get(iid, 0)),
int(health_hits.get(iid, 0)),
display_delay)
for iid: String in dying_iids:
_show_hitsplats_once(
hitsplats_shown,
iid,
int(defense_hits.get(iid, 0)),
int(health_hits.get(iid, 0)),
display_delay)
# ── Schedule animations ───────────────────────────────────────────────────
if is_counterattack:
# Full chain handles the attacker and primary defender.
_play_counter_chain(defender_iid, attacker_iid, attack_remaining)
_play_counter_chain(
defender_iid,
attacker_iid,
attack_remaining,
int(defense_hits.get(defender_iid, 0)),
int(health_hits.get(defender_iid, 0)),
int(defense_hits.get(attacker_iid, 0)),
int(health_hits.get(attacker_iid, 0)),
hitsplats_shown)
# Any other simultaneously-damaged units get a simple delay (uncommon).
for iid: String in damaged_iids:
for iid: String in seen_iids:
if iid == attacker_iid or iid == defender_iid:
continue
var def_loss := int(defense_hits.get(iid, 0))
var hp_loss := int(health_hits.get(iid, 0))
if def_loss <= 0 and hp_loss <= 0:
continue
var hit_iid := iid
var hit_def := def_loss
var hit_hp := hp_loss
var t2 := create_tween()
t2.tween_callback(func() -> void:
if _unit_bodies.has(hit_iid) and \
is_instance_valid(_unit_bodies.get(hit_iid) as Node):
_play_unit_anim(hit_iid, "damaged")
SFX.play(_sfx_for_unit(hit_iid, "damagedSoundUrl"))
if hit_hp > 0:
_play_unit_anim(hit_iid, "damaged")
SFX.play(_sfx_for_unit(hit_iid, "damagedSoundUrl"))
_show_hitsplats_once(hitsplats_shown, hit_iid, hit_def, hit_hp)
).set_delay(attack_remaining)
else:
for iid: String in damaged_iids:
for iid: String in seen_iids:
var def_loss := int(defense_hits.get(iid, 0))
var hp_loss := int(health_hits.get(iid, 0))
if def_loss <= 0 and hp_loss <= 0:
continue
var ap : AnimationPlayer = _anim_players.get(iid, null)
if ap != null and is_instance_valid(ap) and ap.is_playing() \
if hp_loss > 0 and ap != null and is_instance_valid(ap) and ap.is_playing() \
and _is_attack_track(ap.current_animation):
# This unit is mid-attack and took damage (self-damage or similar).
# Queue "damaged" to play right after the attack finishes.
@@ -2315,26 +2558,36 @@ func _play_damage_animations(state: Dictionary) -> bool:
ap.animation_finished.disconnect(old_cb)
_oneshot_callbacks.erase(iid)
var cap_iid := iid
var cap_def := def_loss
var cap_hp := hp_loss
var dmg_cb := func(_n: String) -> void:
_play_unit_anim(cap_iid, "damaged", false)
SFX.play(_sfx_for_unit(cap_iid, "damagedSoundUrl"))
_show_hitsplats_once(hitsplats_shown, cap_iid, cap_def, cap_hp)
ap.animation_finished.connect(dmg_cb, CONNECT_ONE_SHOT)
_oneshot_callbacks[iid] = dmg_cb
elif attack_remaining > 0.0:
# Bystander — delay "damaged" until after the attack lands.
var hit_iid := iid
var hit_def := def_loss
var hit_hp := hp_loss
var t := create_tween()
t.tween_callback(func() -> void:
if _unit_bodies.has(hit_iid) and \
is_instance_valid(_unit_bodies.get(hit_iid) as Node):
_play_unit_anim(hit_iid, "damaged")
SFX.play(_sfx_for_unit(hit_iid, "damagedSoundUrl"))
if hit_hp > 0:
_play_unit_anim(hit_iid, "damaged")
SFX.play(_sfx_for_unit(hit_iid, "damagedSoundUrl"))
_show_hitsplats_once(hitsplats_shown, hit_iid, hit_def, hit_hp)
).set_delay(attack_remaining)
else:
_play_unit_anim(iid, "damaged")
SFX.play(_sfx_for_unit(iid, "damagedSoundUrl"))
if hp_loss > 0:
_play_unit_anim(iid, "damaged")
SFX.play(_sfx_for_unit(iid, "damagedSoundUrl"))
_show_hitsplats_once(hitsplats_shown, iid, def_loss, hp_loss)
for iid: String in dying_iids:
_show_hitsplats_once(hitsplats_shown, iid, int(defense_hits.get(iid, 0)), int(health_hits.get(iid, 0)))
_play_unit_anim(iid, "dying")
SFX.play(_sfx_for_unit(iid, "deathSoundUrl"))
@@ -2346,6 +2599,7 @@ func _play_damage_animations(state: Dictionary) -> bool:
## correct baselines, independent of when the delayed rebuild fires.
func _update_prev_state(state: Dictionary) -> void:
_prev_unit_hp.clear()
_prev_unit_def.clear()
_prev_unit_pos.clear()
for player: Dictionary in state.get("players", []):
var arch : Dictionary = _safe_arch(player)
@@ -2354,6 +2608,7 @@ func _update_prev_state(state: Dictionary) -> void:
var iid := str(unit.get("instanceId", ""))
if iid.is_empty(): continue
_prev_unit_hp[iid] = int(unit.get("currentHealth") or 0)
_prev_unit_def[iid] = int(unit.get("currentDefense") or 0)
var pd = unit.get("position")
if pd is Dictionary and not (pd as Dictionary).is_empty():
_prev_unit_pos[iid] = Vector2i((pd as Dictionary).get("x", 0),
@@ -2734,7 +2989,9 @@ func _valid_play_tiles(card: Dictionary) -> Array:
var dist : int = _board_distance(tx, ty, ax, ay)
if dist < min_r or dist > max_r: continue
var tile : Dictionary = Game.get_tile(tx, ty)
if _tile_has_blocking_occupant(tile): continue
print("tile", tile)
print("[GettingAff]", card_affinity)
if not _tile_has_blocking_occupant(tile): continue
if card_affinity != "" and not _tile_matches_channel_affinity(tile, card_affinity): continue
results.append(Vector2i(tx, ty))
@@ -2752,16 +3009,17 @@ func _valid_play_tiles(card: Dictionary) -> Array:
func _tile_matches_channel_affinity(tile: Dictionary, card_affinity: String) -> bool:
var resolved_affinity : String = str(tile.get("resolvedAffinity", "Void"))
print("[AFFINITY_TILE]", resolved_affinity, card_affinity)
if resolved_affinity == "PerfectAether" and card_affinity in ["Lake", "Hill", "Forest", "Field"]:
return true
if resolved_affinity == "UnstableAether":
return false
if card_affinity in ["Void", "Aether", "Lake", "Hill", "Forest", "Field"]:
if card_affinity in ["Lake", "Hill", "Forest", "Field"]:
var base1 : String = str(tile.get("base1", "Void"))
var base2 : String = str(tile.get("base2", "Void"))
return base1 == card_affinity or base2 == card_affinity
return resolved_affinity == card_affinity
@@ -3609,6 +3867,7 @@ func _handle_board_click(mouse_pos: Vector2) -> void:
unit_id = _occ2
if not unit_id.is_empty():
if _is_enemy_unit(unit_id):
_last_attack_source_iid = _sel_unit_id
_last_attack_target_iid = unit_id
_play_unit_anim(_sel_unit_id, "attack")
SFX.play(_sfx_for_unit(_sel_unit_id, "attackSoundUrl"))
Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://byq7xs7axwuns"
path="res://.godot/imported/Heart_Overlay_Gradient.png-75d25d6294fdc60c096af3fbea7c207f.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://ui/icons/Heart_Overlay_Gradient.png"
dest_files=["res://.godot/imported/Heart_Overlay_Gradient.png-75d25d6294fdc60c096af3fbea7c207f.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

@@ -0,0 +1,40 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://85xdxg1nbkv5"
path="res://.godot/imported/Shield_Overlay_Gradient.png-d01c62dd2d8c812657cbd69605cfe261.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://ui/icons/Shield_Overlay_Gradient.png"
dest_files=["res://.godot/imported/Shield_Overlay_Gradient.png-d01c62dd2d8c812657cbd69605cfe261.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/uastc_level=0
compress/rdo_quality_loss=0.0
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/channel_remap/red=0
process/channel_remap/green=1
process/channel_remap/blue=2
process/channel_remap/alpha=3
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
+38 -23
View File
@@ -5109,6 +5109,27 @@ public static class AbilitySystem
/// moving unit's own auras sweeping over stationary units.
/// Call after updating the unit's position on the board.
/// </summary>
// Returns all units currently on the board for a given player, including ArchSpirit.
private static IEnumerable<FieldCard> BoardUnits(PlayerState player)
{
if (player.ArchSpirit?.Position.HasValue == true)
yield return player.ArchSpirit;
foreach (var fc in player.Field.OfType<FieldCard>().Where(f => f.Position.HasValue))
yield return fc;
}
// Finds the owner account-id of a unit, checking ArchSpirit and Field.
private static string? FindUnitOwner(GameState state, string unitId)
{
foreach (var (oid, pl) in state.Players)
{
if (pl.ArchSpirit?.InstanceId == unitId) return oid;
if (pl.Field.Any(c => c.InstanceId == unitId)) return oid;
}
return null;
}
public static GameState EvaluateAuraTransitions(
GameState state,
string movingUnitId,
@@ -5117,8 +5138,8 @@ public static class AbilitySystem
{
// Part 1: stationary aura-bearing units vs. moving unit's position change.
foreach (var (auraOwnerId, player) in state.Players)
foreach (var auraUnit in player.Field.OfType<FieldCard>()
.Where(f => f.Position.HasValue && f.InstanceId != movingUnitId).ToList())
foreach (var auraUnit in BoardUnits(player)
.Where(f => f.InstanceId != movingUnitId).ToList())
{
foreach (var def in ParseAbilities(auraUnit.AbilitiesJson)
.Where(d => d.Type == AbilityType.Aura && d.AuraRange is not null))
@@ -5133,13 +5154,11 @@ public static class AbilitySystem
// Part 2: moving unit's own auras vs. stationary units.
var movingUnit = state.Players.Values
.SelectMany(p => p.Field.OfType<FieldCard>())
.SelectMany(p => BoardUnits(p))
.FirstOrDefault(f => f.InstanceId == movingUnitId);
if (movingUnit is null) return state;
string? movingOwnerId = null;
foreach (var (oid, pl) in state.Players)
if (pl.Field.Any(c => c.InstanceId == movingUnitId)) { movingOwnerId = oid; break; }
var movingOwnerId = FindUnitOwner(state, movingUnitId);
if (movingOwnerId is null) return state;
foreach (var def in ParseAbilities(movingUnit.AbilitiesJson)
@@ -5147,8 +5166,8 @@ public static class AbilitySystem
{
int min = def.AuraRange!.Min, max = def.AuraRange.Max;
foreach (var (_, pl) in state.Players)
foreach (var other in pl.Field.OfType<FieldCard>()
.Where(f => f.Position.HasValue && f.InstanceId != movingUnitId).ToList())
foreach (var other in BoardUnits(pl)
.Where(f => f.InstanceId != movingUnitId).ToList())
{
var otherPos = other.Position!.Value;
FireAuraTransition(state, movingOwnerId, movingUnit, def, other.InstanceId,
@@ -5176,8 +5195,8 @@ public static class AbilitySystem
// Part 1: existing aura units — check if new unit entered their range.
foreach (var (auraOwnerId, player) in state.Players)
foreach (var auraUnit in player.Field.OfType<FieldCard>()
.Where(f => f.Position.HasValue && f.InstanceId != newUnitId).ToList())
foreach (var auraUnit in BoardUnits(player)
.Where(f => f.InstanceId != newUnitId).ToList())
{
foreach (var def in ParseAbilities(auraUnit.AbilitiesJson)
.Where(d => d.Type == AbilityType.Aura && d.AuraRange is not null))
@@ -5189,17 +5208,15 @@ public static class AbilitySystem
}
// Part 2: new unit's own auras — check all existing units.
string? newUnitOwnerId = null;
foreach (var (oid, pl) in state.Players)
if (pl.Field.Any(c => c.InstanceId == newUnitId)) { newUnitOwnerId = oid; break; }
var newUnitOwnerId = FindUnitOwner(state, newUnitId);
if (newUnitOwnerId is null) return state;
foreach (var def in ParseAbilities(newUnit.AbilitiesJson)
.Where(d => d.Type == AbilityType.Aura && d.AuraRange is not null))
{
foreach (var (_, pl) in state.Players)
foreach (var other in pl.Field.OfType<FieldCard>()
.Where(f => f.Position.HasValue && f.InstanceId != newUnitId).ToList())
foreach (var other in BoardUnits(pl)
.Where(f => f.InstanceId != newUnitId).ToList())
{
int dist = newPos.ManhattanDistance(other.Position!.Value);
if (dist >= def.AuraRange!.Min && dist <= def.AuraRange.Max)
@@ -5218,15 +5235,15 @@ public static class AbilitySystem
public static GameState EvaluateAurasOnLeave(GameState state, string leavingUnitId)
{
var leavingUnit = state.Players.Values
.SelectMany(p => p.Field.OfType<FieldCard>())
.SelectMany(p => BoardUnits(p))
.FirstOrDefault(f => f.InstanceId == leavingUnitId);
if (leavingUnit?.Position is null) return state;
var leavingPos = leavingUnit.Position.Value;
// Part 1: existing aura units — check if leaving unit was in their range.
foreach (var (auraOwnerId, player) in state.Players)
foreach (var auraUnit in player.Field.OfType<FieldCard>()
.Where(f => f.Position.HasValue && f.InstanceId != leavingUnitId).ToList())
foreach (var auraUnit in BoardUnits(player)
.Where(f => f.InstanceId != leavingUnitId).ToList())
{
foreach (var def in ParseAbilities(auraUnit.AbilitiesJson)
.Where(d => d.Type == AbilityType.Aura && d.AuraRange is not null))
@@ -5238,17 +5255,15 @@ public static class AbilitySystem
}
// Part 2: leaving unit's own auras — fire LeaveAuraRange for each in-range unit.
string? leavingOwnerId = null;
foreach (var (oid, pl) in state.Players)
if (pl.Field.Any(c => c.InstanceId == leavingUnitId)) { leavingOwnerId = oid; break; }
var leavingOwnerId = FindUnitOwner(state, leavingUnitId);
if (leavingOwnerId is null) return state;
foreach (var def in ParseAbilities(leavingUnit.AbilitiesJson)
.Where(d => d.Type == AbilityType.Aura && d.AuraRange is not null))
{
foreach (var (_, pl) in state.Players)
foreach (var other in pl.Field.OfType<FieldCard>()
.Where(f => f.Position.HasValue && f.InstanceId != leavingUnitId).ToList())
foreach (var other in BoardUnits(pl)
.Where(f => f.InstanceId != leavingUnitId).ToList())
{
int dist = leavingPos.ManhattanDistance(other.Position!.Value);
if (dist >= def.AuraRange!.Min && dist <= def.AuraRange.Max)
+26 -19
View File
@@ -770,26 +770,33 @@ public static class GameEngine
if (attacker.CurrentHealth <= 0)
{
AbilitySystem.EvaluateAurasOnLeave(state, attacker.InstanceId);
AbilitySystem.RevokePassivesForSource(state, attacker.InstanceId);
if (state.Board is not null) state.Board.RemoveUnit(attacker.InstanceId);
MoveToDiscard(activePlayer, attacker);
if (attacker.IsLeader)
{
EliminatePlayer(state, activePlayer, out gameOver);
}
else
{
AbilitySystem.EvaluateAurasOnLeave(state, attacker.InstanceId);
AbilitySystem.RevokePassivesForSource(state, attacker.InstanceId);
if (state.Board is not null) state.Board.RemoveUnit(attacker.InstanceId);
MoveToDiscard(activePlayer, attacker);
AbilitySystem.FireTrigger(state, new TriggerOccurrence
{
Kind = TriggerEventKind.UnitDeath,
ActorId = actorId,
UnitType = attacker.CardType,
Data = new TriggerEventData { TargetId = attacker.InstanceId },
});
// Attacker was killed by the target's counterattack.
AbilitySystem.FireTrigger(state, new TriggerOccurrence
{
Kind = TriggerEventKind.UnitSentToDiscard,
ActorId = actorId, // victim's player
UnitType = attacker.CardType,
Data = new TriggerEventData { TargetId = attacker.InstanceId, SourceId = target.InstanceId },
});
AbilitySystem.FireTrigger(state, new TriggerOccurrence
{
Kind = TriggerEventKind.UnitDeath,
ActorId = actorId,
UnitType = attacker.CardType,
Data = new TriggerEventData { TargetId = attacker.InstanceId },
});
// Attacker was killed by the target's counterattack.
AbilitySystem.FireTrigger(state, new TriggerOccurrence
{
Kind = TriggerEventKind.UnitSentToDiscard,
ActorId = actorId, // victim's player
UnitType = attacker.CardType,
Data = new TriggerEventData { TargetId = attacker.InstanceId, SourceId = target.InstanceId },
});
}
}
if (target.CurrentHealth <= 0)
@@ -0,0 +1,12 @@
{
"profiles": {
"SOR.Website": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"applicationUrl": "https://localhost:52569;http://localhost:52570"
}
}
}
+1004
View File
File diff suppressed because it is too large Load Diff