Closed niek-alexander closed 3 months ago
I found A solution! First I added a group to the CardDropArea called CardDropArea 😝. Then I added that node to the card_released script with the following code which, at least for targeting attacks (im at episode 5/8 btw, but this bug was also in the full build on github here) which seems good!
My final question is, is this a good solution? or can it be improved? The thing is that it is a remedy but the problem still kinda exists.
`extends CardState
var played: bool var card_drop_area: Node = null
func _ready() -> void: card_drop_area = get_tree().get_first_node_in_group("CardDropArea")
func enter() -> void: played = false if not card_ui.targets.is_empty(): if card_ui.card.is_single_targeted() and (card_drop_area in card_ui.targets): print("bug caught!") return played = true
print("play card for target(s):", card_ui.targets)
...`
Thanks for submitting this, I'll look into it and get back to you
I have investigated it, it is a pretty weird issue. Sometimes I could reproduce it, sometimes I couldn't. Probably the easiest way to fix this is to provide a safeguard in the released state's enter() method, like so:
if card_ui.targets.is_empty():
return
var single_targeted := card_ui.card.is_single_targeted()
var first_target_is_enemy := card_ui.targets[0] is Enemy
if single_targeted and not first_target_is_enemy:
return
I have committed the fix here but keep in mind that this is the final project: https://github.com/guladam/deck_builder_tutorial/commit/ce11da2ecd182cd1402b3c1da0902245c6df3659
Thanks for pointing this out, nice catch!
Thanks for the response, awesome!!
If you drop a card, such as a basic strike one pixel below the CardDropArea , aka, where the targeting line will be created, a strike will attack that CardDropArea instead of returning to the hand.
I am not an experienced programmer, but I would add a check that makes sure that the CardDropArea can never be added to the list of targets. Would this be a sufficient solution?
edit:
I dont think the solution of not adding it to the targets works. Now I just want to know where the problem lies 😓