fix: card burner loads cards and singes them with correct highlight

This commit is contained in:
tiger tiger tiger 2026-01-18 19:37:11 +01:00
parent ba20ce5180
commit 6e3be3b78b
4 changed files with 59 additions and 47 deletions

View File

@ -19,39 +19,52 @@ var focused: bool = false:
@onready var cursor: CandleCursor = %CandleCursor @onready var cursor: CandleCursor = %CandleCursor
@onready var ancors: Array[Control] = [%Ancor1, %Ancor2, %Ancor3, %Ancor4] @onready var ancors: Array[Control] = [%Ancor1, %Ancor2, %Ancor3, %Ancor4]
signal card_burned
func _ready(): func _ready():
# Note: burn_cards is now called directly by the transition system, not via register_scene_actor
%SkipButton.pressed.connect(card_burned.emit) %SkipButton.pressed.connect(card_burned.emit)
func burn_cards(_id: int, _repeat: bool = false) -> void:
# Get all card names from the board (excluding stickies which start with "p") ## Main play coroutine - simple linear flow for burning a card
func play() -> void:
print_debug("CardBurner: Starting card burning sequence")
# 1. Get all card names from the board (excluding stickies which start with "p")
var card_names: Array[StringName] = [] var card_names: Array[StringName] = []
for item_name in State.save_game.board_positions.keys(): for item_name in State.save_game.board_positions.keys():
if not item_name.begins_with("p"): if not item_name.begins_with("p"):
card_names.append(item_name) card_names.append(item_name)
# Get card instances and shuffle them print_debug("CardBurner: Found %d cards to choose from" % card_names.size())
# 2. Get card instances and shuffle them
var random_cards: Array = HardCards.get_cards_by_name_array(card_names)["cards"] var random_cards: Array = HardCards.get_cards_by_name_array(card_names)["cards"]
random_cards.shuffle() random_cards.shuffle()
for ancor:Control in ancors: # 3. Populate the 4 anchor slots with random cards
if random_cards.size() > 0: for ancor: Control in ancors:
ancor.get_child(0).queue_free() var new_card: Card = random_cards.pop_front()
var new_child: Card = random_cards.pop_front() ancor.add_child(new_card)
ancor.add_child(new_child) new_card.owner = self
new_child.owner = self new_card.has_burned.connect(card_burned.emit)
new_child.has_burned.connect(card_burned.emit) print_debug("CardBurner: Added card '%s' to anchor" % new_card.name)
# 4. Wait for player to burn a card (or skip)
print_debug("CardBurner: Waiting for player to burn a card...")
await card_burned await card_burned
# 5. Play vanish animation and wait for completion
print_debug("CardBurner: Card burned, playing vanish animation")
$AnimationPlayer.play("vanish") $AnimationPlayer.play("vanish")
await $AnimationPlayer.animation_finished await $AnimationPlayer.animation_finished
signal card_burned print_debug("CardBurner: Sequence complete")
func handle_hover(to_handle: Area2D): func handle_hover(card: Draggable):
if to_handle is Card: if not card is Card: return
if to_handle.burn_state == Card.burned.NOT: card.highlighted = card.mouse_over
to_handle.burn_state = Card.burned.SINGED card.burn_state = Card.burned.SINGED if card.mouse_over else Card.burned.NOT
func handle_mouse_button(event: InputEventMouseButton, card: Card): func handle_mouse_button(event: InputEventMouseButton, card: Card):
if event.button_index == MOUSE_BUTTON_MASK_LEFT and event.is_pressed() and not event.is_echo(): if event.button_index == MOUSE_BUTTON_MASK_LEFT and event.is_pressed() and not event.is_echo():

View File

@ -6,12 +6,12 @@
[ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="4_x6cxt"] [ext_resource type="Script" uid="uid://bbs1u7ojno7xo" path="res://addons/input_prompts/action_prompt/action_prompt.gd" id="4_x6cxt"]
[ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="5_ckmi5"] [ext_resource type="PackedScene" uid="uid://dy5rd437h5hsw" path="res://logic-scenes/board/card.tscn" id="5_ckmi5"]
[sub_resource type="InputEventKey" id="InputEventKey_x6cxt"] [sub_resource type="InputEventKey" id="InputEventKey_ckmi5"]
device = -1 device = -1
physical_keycode = 88 physical_keycode = 88
unicode = 120 unicode = 120
[sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_23lqb"] [sub_resource type="InputEventJoypadButton" id="InputEventJoypadButton_x6cxt"]
device = -1 device = -1
button_index = 2 button_index = 2
pressed = true pressed = true
@ -176,7 +176,7 @@ stretch_mode = 5
script = ExtResource("4_x6cxt") script = ExtResource("4_x6cxt")
action = "skip" action = "skip"
icon = 0 icon = 0
events = Array[InputEvent]([null, SubResource("InputEventKey_x6cxt"), SubResource("InputEventJoypadButton_23lqb")]) events = Array[InputEvent]([null, SubResource("InputEventKey_ckmi5"), SubResource("InputEventJoypadButton_x6cxt")])
metadata/_custom_type_script = "uid://bbs1u7ojno7xo" metadata/_custom_type_script = "uid://bbs1u7ojno7xo"
[node name="SkipButton" type="Button" parent="Control/HSplitContainer"] [node name="SkipButton" type="Button" parent="Control/HSplitContainer"]
@ -200,53 +200,41 @@ libraries = {
} }
[node name="Card1" parent="." instance=ExtResource("5_ckmi5")] [node name="Card1" parent="." instance=ExtResource("5_ckmi5")]
picked_random = null
wiggle_strength = null wiggle_strength = null
wiggle_speed = null wiggle_speed = null
scale_bump = null scale_bump = null
bounce_speed = null bounce_speed = null
highlighted = null
is_dragable = null is_dragable = null
diameter = null diameter = null
burn_progress = null burn_progress = null
burn_state = null burn_state = null
direction = null
[node name="Card2" parent="." instance=ExtResource("5_ckmi5")] [node name="Card2" parent="." instance=ExtResource("5_ckmi5")]
picked_random = null
wiggle_strength = null wiggle_strength = null
wiggle_speed = null wiggle_speed = null
scale_bump = null scale_bump = null
bounce_speed = null bounce_speed = null
highlighted = null
is_dragable = null is_dragable = null
diameter = null diameter = null
burn_progress = null burn_progress = null
burn_state = null burn_state = null
direction = null
[node name="Card3" parent="." instance=ExtResource("5_ckmi5")] [node name="Card3" parent="." instance=ExtResource("5_ckmi5")]
picked_random = null
wiggle_strength = null wiggle_strength = null
wiggle_speed = null wiggle_speed = null
scale_bump = null scale_bump = null
bounce_speed = null bounce_speed = null
highlighted = null
is_dragable = null is_dragable = null
diameter = null diameter = null
burn_progress = null burn_progress = null
burn_state = null burn_state = null
direction = null
[node name="Card4" parent="." instance=ExtResource("5_ckmi5")] [node name="Card4" parent="." instance=ExtResource("5_ckmi5")]
picked_random = null
wiggle_strength = null wiggle_strength = null
wiggle_speed = null wiggle_speed = null
scale_bump = null scale_bump = null
bounce_speed = null bounce_speed = null
highlighted = null
is_dragable = null is_dragable = null
diameter = null diameter = null
burn_progress = null burn_progress = null
burn_state = null burn_state = null
direction = null

View File

@ -126,6 +126,7 @@ func play_story() -> void:
Scenes.player_enable.emit(true) Scenes.player_enable.emit(true)
expand() expand()
func play_board() -> void: func play_board() -> void:
canvas_layer.show() canvas_layer.show()
@ -139,26 +140,33 @@ func play_board() -> void:
expand() expand()
func play_burner() -> void:
canvas_layer.show()
# Play the board (handles mouse visibility and waits for close)
await interaction_ui.play()
# Hide the CanvasLayer when done
canvas_layer.hide()
func interact() -> void: func interact() -> void:
Scenes.player_enable.emit(false) Scenes.player_enable.emit(false)
shown = false shown = false
await collapse() await collapse()
collected = true
# collapse other interactables BEFORE showing canvas # collapse other interactables BEFORE showing canvas
get_tree().call_group("interactables", "collapse") get_tree().call_group("interactables", "collapse")
# Show the CanvasLayer so the story is visible full-screen
canvas_layer.show()
if interaction_ui is StoryPlayable: if interaction_ui is StoryPlayable:
await play_story() await play_story()
if interaction_ui is CardBoard: if interaction_ui is CardBoard:
await play_board() await play_board()
canvas_layer.hide() if interaction_ui is CardBurner:
collected = true await play_burner()
Scenes.player_enable.emit(true)
## Updates caption label based on the instantiated interaction_ui ## Updates caption label based on the instantiated interaction_ui
@ -166,8 +174,10 @@ func _update_caption() -> void:
if interaction_ui is StoryPlayable: if interaction_ui is StoryPlayable:
var story := interaction_ui as StoryPlayable var story := interaction_ui as StoryPlayable
caption.text = I18n.get_story_caption(story.scene_id) caption.text = I18n.get_story_caption(story.scene_id)
elif interaction_ui is CardBoard: if interaction_ui is CardBoard:
caption.text = TranslationServer.translate("Mind Board") caption.text = TranslationServer.translate("Mind Board")
if interaction_ui is CardBurner:
caption.text = TranslationServer.translate("leave")
## Updates prompt label based on the interaction type and collected state ## Updates prompt label based on the interaction type and collected state
func _update_prompt() -> void: func _update_prompt() -> void:

View File

@ -3,8 +3,9 @@ class_name Playable
## Awaitable that encapsulates the core interaction with this Playable ## Awaitable that encapsulates the core interaction with this Playable
func play() -> void: func play() -> void:
push_warning("Playeable[base].play() not overridden")
await get_tree().process_frame # Dummy wait so this is a coroutine await get_tree().process_frame # Dummy wait so this is a coroutine
func handle_hover(area: Draggable): func handle_hover(_area: Draggable):
prints("Playable[base].handle_hover", area, area.name) #prints("Playable[base].handle_hover", _area, _area.name)
pass pass