Skip to content

Commit bcc82e6

Browse files
committed
fix: Selection Window will now properly turn cards face-up
1 parent f8e457c commit bcc82e6

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

src/core/CardTemplate.gd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,12 +873,14 @@ func set_is_faceup(
873873
# We need this check, as this node might not be ready
874874
# Yet when a viewport focus dupe is instancing
875875
buttons.set_button_visible("View", false)
876-
card_back.stop_card_back_animation()
876+
if is_instance_valid(card_back):
877+
card_back.stop_card_back_animation()
877878
else:
878879
_flip_card(_card_front_container, _card_back_container,instant)
879880
buttons.set_button_visible("View", true)
880881
# if get_parent() == cfc.NMAP.board:
881-
card_back.start_card_back_animation()
882+
if is_instance_valid(card_back):
883+
card_back.start_card_back_animation()
882884
# When we flip, we also want to adjust the dupe card
883885
# in the focus viewport
884886
if state != CardState.VIEWED_IN_PILE\
@@ -1377,6 +1379,10 @@ func move_to(targetHost: Node,
13771379
_placement_slot.occupying_card = null
13781380
_placement_slot = null
13791381
raise()
1382+
elif parentHost == targetHost and index != get_my_card_index():
1383+
parentHost.move_child(self,
1384+
parentHost.translate_card_index_to_node_index(index))
1385+
print_debug(get_my_card_index())
13801386
elif "CardPopUpSlot" in parentHost.name:
13811387
set_state(CardState.IN_POPUP)
13821388
common_post_move_scripts(targetHost.name, parentHost.name, tags)

src/core/OverridableUtils.gd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func select_card(
4343
# This way we can override the card select scene with a custom one
4444
var selection = card_select_scene.instance()
4545
parent_node.add_child(selection)
46-
selection.initiate_selection(card_list,selection_count,selection_type,selection_optional)
46+
selection.call_deferred("initiate_selection", card_list,selection_count,selection_type,selection_optional)
4747
# We have to wait until the player has finished selecting their cards
4848
yield(selection,"confirmed")
4949
if selection.is_cancelled:

src/core/ScriptingEngine.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,9 @@ func spawn_card_to_container(script: ScriptTask) -> void:
525525
if filtered_cards.size() < selection_amount:
526526
selection_amount == filtered_cards.size()
527527
CFUtils.shuffle_array(filtered_cards)
528+
if filtered_cards.size() == 0:
529+
printerr("WARN: Cannot find any cards to spawn with the selected filter for script:\n" + str(script.script_definition))
530+
return
528531
if selection_amount < 0:
529532
return
530533
if selection_amount == 1:

src/core/SelectionWindow.gd

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ func initiate_selection(
5757
_selection_count := 0,
5858
_selection_type := 'min',
5959
_selection_optional := false) -> void:
60+
if OS.has_feature("debug") and not get_tree().get_root().has_node('Gut'):
61+
print("DEBUG INFO:SelectionWindow: Initiated Selection")
6062
# We don't allow the player to close the popup with the close button
6163
# as that will not send the mandatory signal to unpause the game
6264
get_close_button().visible = false
@@ -85,7 +87,11 @@ func initiate_selection(
8587
selected_cards = card_array
8688
emit_signal("confirmed")
8789
return
88-
# We change the window title to be descriptive
90+
# When we have 0 cards to select from, we consider the selection cancelled
91+
elif card_array.size() == 0:
92+
is_cancelled = true
93+
emit_signal("confirmed")
94+
return
8995
match selection_type:
9096
"min":
9197
window_title = "Select at least " + str(selection_count) + " cards."
@@ -113,7 +119,6 @@ func initiate_selection(
113119
dupe_selection.remove_from_group("cards")
114120
dupe_selection.canonical_name = card.canonical_name
115121
dupe_selection.properties = card.properties.duplicate()
116-
dupe_selection.is_faceup = true
117122
card_sample = dupe_selection
118123
var card_grid_obj = grid_card_object_scene.instance()
119124
_card_grid.add_child(card_grid_obj)
@@ -123,6 +128,10 @@ func initiate_selection(
123128
card_grid_obj.setup(dupe_selection)
124129
_extra_dupe_ready(dupe_selection, card)
125130
_card_dupe_map[card] = dupe_selection
131+
# yield(dupe_selection, "ready")
132+
# yield(get_tree().create_timer(0.3), "timeout")
133+
dupe_selection.set_is_faceup(card.is_faceup,true)
134+
dupe_selection.set_is_faceup(true,true)
126135
# We connect each card grid's gui input into a call which will handle
127136
# The selections
128137
card_grid_obj.connect("gui_input", self, "on_selection_gui_input", [dupe_selection, card])
@@ -148,6 +157,8 @@ func initiate_selection(
148157
0, 1, 0.5,
149158
Tween.TRANS_SINE, Tween.EASE_IN)
150159
_tween.start()
160+
if OS.has_feature("debug") and not get_tree().get_root().has_node('Gut'):
161+
print("DEBUG INFO:SelectionWindow: Started Card Display with a %s card selection" % [_card_grid.get_child_count()])
151162

152163

153164
# Overridable function for games to extend processing of dupe card

src/core/SelectionWindow.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[ext_resource path="res://src/core/SelectionWindow.gd" type="Script" id=1]
44

5-
[node name="SelectionWindow" type="AcceptDialog"]
5+
[node name="SelectionWindow" type="AcceptDialog" groups=["selection_windows"]]
66
modulate = Color( 1, 1, 1, 0 )
77
anchor_right = 1.0
88
anchor_bottom = 1.0

0 commit comments

Comments
 (0)