diff --git a/Client/origin-client/scenes/game/game_screen.gd b/Client/origin-client/scenes/game/game_screen.gd index f55ab00..4618420 100644 --- a/Client/origin-client/scenes/game/game_screen.gd +++ b/Client/origin-client/scenes/game/game_screen.gd @@ -2869,13 +2869,9 @@ func _select_unit(unit_id: String) -> void: # Attackable enemies (drawn on top). _highlight_tiles(_valid_attack_target_coords(unit), "attack") - # Show ability panel if unit has active abilities. + # Show ability panel (abilities + ArchSpirit actions in one panel). _show_ability_panel(unit_id, unit) - # Own ArchSpirit — offer Sacrifice option via menu. - if unit.get("cardType", "") == "ArchSpirit" and _is_friendly_unit(unit_id): - _show_arch_spirit_menu(unit_id, unit) - func _set_mode(new_mode: Mode) -> void: print("Setting mode: ", new_mode) @@ -3081,57 +3077,93 @@ func _clamp_panel_pos(desired: Vector2, panel: Control) -> Vector2: func _show_ability_panel(unit_id: String, unit: Dictionary) -> void: _hide_ability_panel() - # Null trap: server sends "abilitiesJson": null for units with no abilities. - # dict.get(key, default) returns null when key exists with null value. + + # ── Collect Active abilities ─────────────────────────────────────────────── + var actives : Array = [] var _raw_abil_ap = unit.get("abilitiesJson") var abil_json : String = "" if _raw_abil_ap == null else str(_raw_abil_ap) - if abil_json.is_empty(): return - var parsed = JSON.parse_string(abil_json) - if not parsed is Array: return - # Server may serialise with PascalCase keys — normalise to lowercase. - var abilities : Array = _normalize_keys(parsed) as Array + if not abil_json.is_empty(): + var parsed = JSON.parse_string(abil_json) + if parsed is Array: + var abilities : Array = _normalize_keys(parsed) as Array + for i in abilities.size(): + var ab : Dictionary = abilities[i] as Dictionary + if ab.get("type", "") == "Active": + actives.append({ "index": i, + "name": ab.get("name", "Ability %d" % i), + "desc": ab.get("description", ""), + "def": ab }) - # Collect Active abilities. - var actives : Array = [] - for i in abilities.size(): - var ab : Dictionary = abilities[i] as Dictionary - if ab.get("type", "") == "Active": - actives.append({ "index": i, - "name": ab.get("name", "Ability %d" % i), - "desc": ab.get("description", ""), - "def": ab }) + # ── Collect ArchSpirit actions (Sacrifice / Ascend / Transition) ─────────── + var arch_actions : Array = [] + if unit.get("cardType", "") == "ArchSpirit" and _is_friendly_unit(unit_id): + if not _valid_sacrifice_spirits().is_empty(): + arch_actions.append({ "label": "Sacrifice a Spirit", + "fn": func() -> void: _start_sacrifice_mode() }) + var cur_tier : int = int(unit.get("tier", 1)) + var can_ascend := false + var can_transition := false + for card: Dictionary in Game.get_hand(): + if card.get("cardType", "") != "ArchSpirit": continue + var t : int = int(card.get("tier", 0)) + if t == cur_tier + 1: can_ascend = true + if t == 1: can_transition = true + if can_ascend: + arch_actions.append({ "label": "Ascend", + "fn": func() -> void: _pick_ascend_card() }) + if can_transition: + arch_actions.append({ "label": "Transition", + "fn": func() -> void: _pick_transition_card() }) - if actives.is_empty(): return + if actives.is_empty() and arch_actions.is_empty(): + return - # Build a floating panel positioned to the right of the unit in screen space. + # ── Build panel ──────────────────────────────────────────────────────────── var panel := PanelContainer.new() - var vbox := VBoxContainer.new() + var vbox := VBoxContainer.new() vbox.add_theme_constant_override("separation", 4) vbox.custom_minimum_size = Vector2(160, 0) - var title := Label.new() - title.text = "Abilities" - title.add_theme_font_size_override("font_size", 12) - title.add_theme_color_override("font_color", Color(0.7, 0.8, 1.0)) - vbox.add_child(title) - vbox.add_child(HSeparator.new()) + if not actives.is_empty(): + var title := Label.new() + title.text = "Abilities" + title.add_theme_font_size_override("font_size", 12) + title.add_theme_color_override("font_color", Color(0.7, 0.8, 1.0)) + vbox.add_child(title) + vbox.add_child(HSeparator.new()) + for ab: Dictionary in actives: + var btn := Button.new() + btn.text = ab.get("name", "") + btn.tooltip_text = ab.get("desc", "") + btn.add_theme_font_size_override("font_size", 12) + var idx : int = ab.get("index", 0) + var ab_def : Dictionary = ab.get("def", {}) + btn.pressed.connect(func() -> void: + _ability_unit_id = unit_id + _ability_idx = idx + _ability_def = ab_def.get("actions", []) + _ability_range = ab_def.get("range", {}) + _ability_targets = [] + _ability_cur_action_idx = 0 + _start_ability_targeting()) + vbox.add_child(btn) - for ab: Dictionary in actives: - var btn := Button.new() - btn.text = ab.get("name", "") - btn.tooltip_text = ab.get("desc", "") - btn.add_theme_font_size_override("font_size", 12) - var idx : int = ab.get("index", 0) - var ab_def : Dictionary = ab.get("def", {}) - btn.pressed.connect(func() -> void: - _ability_unit_id = unit_id - _ability_idx = idx - _ability_def = ab_def.get("actions", []) - _ability_range = ab_def.get("range", {}) - _ability_targets = [] - _ability_cur_action_idx = 0 - _start_ability_targeting()) - vbox.add_child(btn) + if not arch_actions.is_empty(): + if not actives.is_empty(): + vbox.add_child(HSeparator.new()) + var arch_title := Label.new() + arch_title.text = "ArchSpirit" + arch_title.add_theme_font_size_override("font_size", 12) + arch_title.add_theme_color_override("font_color", Color(1.0, 0.75, 0.3)) + vbox.add_child(arch_title) + vbox.add_child(HSeparator.new()) + for aa: Dictionary in arch_actions: + var btn := Button.new() + btn.text = aa.get("label", "") + btn.add_theme_font_size_override("font_size", 12) + var fn : Callable = aa.get("fn", Callable()) + btn.pressed.connect(func() -> void: fn.call()) + vbox.add_child(btn) panel.add_child(vbox) _hud.add_child(panel)