adding checks so card board will only combine compatible cards
This commit is contained in:
parent
ced806fa97
commit
a99433c73c
|
|
@ -75,7 +75,7 @@ func _process(delta):
|
||||||
|
|
||||||
# we should maybe consider moving this to _input() for consistency
|
# we should maybe consider moving this to _input() for consistency
|
||||||
if Input.is_action_just_pressed("ui_cancel"):
|
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
|
# 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
|
"post-it": # 2 = PostIt
|
||||||
if input.is_pressed():
|
if input.is_pressed():
|
||||||
to_handle.reparent(dropzone)
|
to_handle.reparent(dropzone)
|
||||||
|
to_handle.on_board = true
|
||||||
to_handle.set_owner(self) # needs to be here otherwise the owner disappears
|
to_handle.set_owner(self) # needs to be here otherwise the owner disappears
|
||||||
area_dict["post_its_in_list"].erase(to_handle)
|
area_dict["post_its_in_list"].erase(to_handle)
|
||||||
area_dict["dropzone_content"].push_back(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
|
# 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):
|
func attach_postit_to_card(postit: Area2D, card: Area2D, update_dict = false):
|
||||||
|
|
||||||
if card.has_postit_attached():
|
if postit.is_in_group(card.name):
|
||||||
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)
|
if card.has_postit_attached():
|
||||||
postit.set_owner(self)
|
if active_context == ui_context.ASSIGN_POST_IT:
|
||||||
postit.position = card.get_child(3).position
|
_return_postit_to_panels(postit) # don't attach if card has already a post-it attached
|
||||||
|
return
|
||||||
if update_dict:
|
|
||||||
area_dict["post_its_in_list"].erase(postit)
|
postit.reparent(card)
|
||||||
area_dict["dropzone_content"].push_back(postit)
|
postit.on_board = false
|
||||||
|
postit.set_owner(self)
|
||||||
reorder_areas("dropzone_content")
|
postit.position = card.get_child(3).position
|
||||||
reorder_areas("cards")
|
|
||||||
reorder_areas("post_its_in_list")
|
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
|
# 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"]:
|
for panel in area_dict["post_it_panels"]:
|
||||||
if panel.get_child_count() == 1:
|
if panel.get_child_count() == 1:
|
||||||
area_dict["dropzone_content"].erase(post_it)
|
area_dict["dropzone_content"].erase(post_it)
|
||||||
|
post_it.on_board = false
|
||||||
area_dict["post_its_in_list"].push_back(post_it)
|
area_dict["post_its_in_list"].push_back(post_it)
|
||||||
post_it.tween_transform_to(panel.get_child(0).position)
|
post_it.tween_transform_to(panel.get_child(0).position)
|
||||||
post_it.rotation = post_it.base_rotation
|
post_it.rotation = post_it.base_rotation
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue