diff --git a/src/core/CardTemplate.gd b/src/core/CardTemplate.gd index a1f460c0..6e5e34b0 100644 --- a/src/core/CardTemplate.gd +++ b/src/core/CardTemplate.gd @@ -873,12 +873,14 @@ func set_is_faceup( # We need this check, as this node might not be ready # Yet when a viewport focus dupe is instancing buttons.set_button_visible("View", false) - card_back.stop_card_back_animation() + if is_instance_valid(card_back): + card_back.stop_card_back_animation() else: _flip_card(_card_front_container, _card_back_container,instant) buttons.set_button_visible("View", true) # if get_parent() == cfc.NMAP.board: - card_back.start_card_back_animation() + if is_instance_valid(card_back): + card_back.start_card_back_animation() # When we flip, we also want to adjust the dupe card # in the focus viewport if state != CardState.VIEWED_IN_PILE\ @@ -1377,6 +1379,10 @@ func move_to(targetHost: Node, _placement_slot.occupying_card = null _placement_slot = null raise() + elif parentHost == targetHost and index != get_my_card_index(): + parentHost.move_child(self, + parentHost.translate_card_index_to_node_index(index)) + print_debug(get_my_card_index()) elif "CardPopUpSlot" in parentHost.name: set_state(CardState.IN_POPUP) common_post_move_scripts(targetHost.name, parentHost.name, tags) diff --git a/src/core/OverridableUtils.gd b/src/core/OverridableUtils.gd index 0d394945..a5cf7b99 100644 --- a/src/core/OverridableUtils.gd +++ b/src/core/OverridableUtils.gd @@ -43,7 +43,7 @@ func select_card( # This way we can override the card select scene with a custom one var selection = card_select_scene.instance() parent_node.add_child(selection) - selection.initiate_selection(card_list,selection_count,selection_type,selection_optional) + selection.call_deferred("initiate_selection", card_list,selection_count,selection_type,selection_optional) # We have to wait until the player has finished selecting their cards yield(selection,"confirmed") if selection.is_cancelled: diff --git a/src/core/ScriptingEngine.gd b/src/core/ScriptingEngine.gd index 39aa242a..4689e482 100644 --- a/src/core/ScriptingEngine.gd +++ b/src/core/ScriptingEngine.gd @@ -525,6 +525,9 @@ func spawn_card_to_container(script: ScriptTask) -> void: if filtered_cards.size() < selection_amount: selection_amount == filtered_cards.size() CFUtils.shuffle_array(filtered_cards) + if filtered_cards.size() == 0: + printerr("WARN: Cannot find any cards to spawn with the selected filter for script:\n" + str(script.script_definition)) + return if selection_amount < 0: return if selection_amount == 1: diff --git a/src/core/SelectionWindow.gd b/src/core/SelectionWindow.gd index 7798a6df..4c484b44 100644 --- a/src/core/SelectionWindow.gd +++ b/src/core/SelectionWindow.gd @@ -57,6 +57,8 @@ func initiate_selection( _selection_count := 0, _selection_type := 'min', _selection_optional := false) -> void: + if OS.has_feature("debug") and not get_tree().get_root().has_node('Gut'): + print("DEBUG INFO:SelectionWindow: Initiated Selection") # We don't allow the player to close the popup with the close button # as that will not send the mandatory signal to unpause the game get_close_button().visible = false @@ -85,7 +87,11 @@ func initiate_selection( selected_cards = card_array emit_signal("confirmed") return - # We change the window title to be descriptive + # When we have 0 cards to select from, we consider the selection cancelled + elif card_array.size() == 0: + is_cancelled = true + emit_signal("confirmed") + return match selection_type: "min": window_title = "Select at least " + str(selection_count) + " cards." @@ -113,7 +119,6 @@ func initiate_selection( dupe_selection.remove_from_group("cards") dupe_selection.canonical_name = card.canonical_name dupe_selection.properties = card.properties.duplicate() - dupe_selection.is_faceup = true card_sample = dupe_selection var card_grid_obj = grid_card_object_scene.instance() _card_grid.add_child(card_grid_obj) @@ -123,6 +128,10 @@ func initiate_selection( card_grid_obj.setup(dupe_selection) _extra_dupe_ready(dupe_selection, card) _card_dupe_map[card] = dupe_selection +# yield(dupe_selection, "ready") +# yield(get_tree().create_timer(0.3), "timeout") + dupe_selection.set_is_faceup(card.is_faceup,true) + dupe_selection.set_is_faceup(true,true) # We connect each card grid's gui input into a call which will handle # The selections card_grid_obj.connect("gui_input", self, "on_selection_gui_input", [dupe_selection, card]) @@ -148,6 +157,8 @@ func initiate_selection( 0, 1, 0.5, Tween.TRANS_SINE, Tween.EASE_IN) _tween.start() + if OS.has_feature("debug") and not get_tree().get_root().has_node('Gut'): + print("DEBUG INFO:SelectionWindow: Started Card Display with a %s card selection" % [_card_grid.get_child_count()]) # Overridable function for games to extend processing of dupe card diff --git a/src/core/SelectionWindow.tscn b/src/core/SelectionWindow.tscn index 21b7311e..249e7ac8 100644 --- a/src/core/SelectionWindow.tscn +++ b/src/core/SelectionWindow.tscn @@ -2,7 +2,7 @@ [ext_resource path="res://src/core/SelectionWindow.gd" type="Script" id=1] -[node name="SelectionWindow" type="AcceptDialog"] +[node name="SelectionWindow" type="AcceptDialog" groups=["selection_windows"]] modulate = Color( 1, 1, 1, 0 ) anchor_right = 1.0 anchor_bottom = 1.0