2025-06-02 23:49:33 +00:00
|
|
|
class_name CardBurner extends CenterContainer
|
|
|
|
|
|
|
|
|
|
var has_stage = false:
|
|
|
|
|
set(focus):
|
|
|
|
|
if not focus == has_stage:
|
|
|
|
|
if focus:
|
|
|
|
|
process_mode = Node.PROCESS_MODE_INHERIT
|
|
|
|
|
self.show()
|
2025-06-03 21:18:34 +00:00
|
|
|
self.mouse_filter = Control.MOUSE_FILTER_PASS
|
2025-06-04 13:39:06 +00:00
|
|
|
Input.mouse_mode = Input.MOUSE_MODE_HIDDEN
|
2025-06-02 23:49:33 +00:00
|
|
|
else:
|
|
|
|
|
self.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
|
|
|
|
self.hide()
|
|
|
|
|
process_mode = Node.PROCESS_MODE_DISABLED
|
|
|
|
|
has_stage = focus
|
|
|
|
|
|
|
|
|
|
func _ready():
|
2025-06-03 21:18:34 +00:00
|
|
|
Scenes.sign_up_for_sequence(burn_cards, Scenes.id.TRANSITION, 1)
|
|
|
|
|
%SkipButton.pressed.connect(card_burned.emit)
|
2025-06-02 23:49:33 +00:00
|
|
|
|
2025-06-03 21:18:34 +00:00
|
|
|
func burn_cards(_id, _repeat):
|
|
|
|
|
var random_card_names: Array = State.active_save_game.board_state["randoms"]
|
2025-06-02 23:49:33 +00:00
|
|
|
|
|
|
|
|
for card_name in random_card_names:
|
2025-06-03 21:18:34 +00:00
|
|
|
if card_name.begins_with("p"):
|
2025-06-02 23:49:33 +00:00
|
|
|
random_card_names.erase(card_name)
|
|
|
|
|
|
2025-06-03 21:18:34 +00:00
|
|
|
var random_cards: Array = HardCards.get_cards_by_name_array(random_card_names)["cards"]
|
|
|
|
|
|
|
|
|
|
random_cards.shuffle()
|
|
|
|
|
|
|
|
|
|
for ancor:Control in [%Ancor1, %Ancor2, %Ancor3, %Ancor4]:
|
|
|
|
|
if random_cards.size() > 0:
|
|
|
|
|
ancor.get_child(0).queue_free()
|
|
|
|
|
var new_child: Card = random_cards.pop_front()
|
|
|
|
|
ancor.add_child(new_child)
|
|
|
|
|
new_child.owner = self
|
|
|
|
|
new_child.has_burned.connect(card_burned.emit)
|
|
|
|
|
|
|
|
|
|
await card_burned
|
|
|
|
|
$AnimationPlayer.play("vanish")
|
|
|
|
|
await $AnimationPlayer.animation_finished
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Scenes.continue_sequence(self)
|
|
|
|
|
|
|
|
|
|
signal card_burned
|
|
|
|
|
|
|
|
|
|
func handle_hover(to_handle: Area2D):
|
|
|
|
|
if to_handle is Card:
|
|
|
|
|
if to_handle.burn_state == Card.burned.NOT:
|
|
|
|
|
to_handle.burn_state = Card.burned.SINGED
|
|
|
|
|
|
|
|
|
|
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():
|
|
|
|
|
card.burn_state = Card.burned.BURNING
|