adding checks so card board will only combine compatible cards

This commit is contained in:
betalars 2023-07-18 15:53:15 +02:00
parent ced806fa97
commit a99433c73c
1 changed files with 21 additions and 16 deletions

View File

@ -75,7 +75,7 @@ func _process(delta):
# we should maybe consider moving this to _input() for consistency
if Input.is_action_just_pressed("ui_cancel"):
populate_board(["c_Joy","p_effort","c_backlash","c_body","c_hit","p_reward","p_worried_mother","p_cross_friend"])
populate_board(["c_Joy","p_effort","c_backlash","c_body","c_void","p_reward","p_worried_mother","p_cross_friend"])
# Will be used later to spawn Cards and Post-Its and remember them in the dictionary
@ -186,6 +186,7 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
"post-it": # 2 = PostIt
if input.is_pressed():
to_handle.reparent(dropzone)
to_handle.on_board = true
to_handle.set_owner(self) # needs to be here otherwise the owner disappears
area_dict["post_its_in_list"].erase(to_handle)
area_dict["dropzone_content"].push_back(to_handle)
@ -209,22 +210,25 @@ func handle_mouse_button(to_handle: Area2D, input: InputEvent):
# Logic for attaching a postit to a card. Also reset postit positions if the card cannot be attached
func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
if card.has_postit_attached():
if active_context == ui_context.ASSIGN_POST_IT:
_return_postit_to_panels(postit) # don't attach if card has already a post-it attached
return
if postit.is_in_group(card.name):
postit.reparent(card)
postit.set_owner(self)
postit.position = card.get_child(3).position
if update_dict:
area_dict["post_its_in_list"].erase(postit)
area_dict["dropzone_content"].push_back(postit)
reorder_areas("dropzone_content")
reorder_areas("cards")
reorder_areas("post_its_in_list")
if card.has_postit_attached():
if active_context == ui_context.ASSIGN_POST_IT:
_return_postit_to_panels(postit) # don't attach if card has already a post-it attached
return
postit.reparent(card)
postit.on_board = false
postit.set_owner(self)
postit.position = card.get_child(3).position
if update_dict:
area_dict["post_its_in_list"].erase(postit)
area_dict["dropzone_content"].push_back(postit)
reorder_areas("dropzone_content")
reorder_areas("cards")
reorder_areas("post_its_in_list")
# Mark area that was hovered over as currently selected
@ -375,6 +379,7 @@ func _return_postit_to_panels(post_it: Area2D):
for panel in area_dict["post_it_panels"]:
if panel.get_child_count() == 1:
area_dict["dropzone_content"].erase(post_it)
post_it.on_board = false
area_dict["post_its_in_list"].push_back(post_it)
post_it.tween_transform_to(panel.get_child(0).position)
post_it.rotation = post_it.base_rotation