guladam / deck_builder_tutorial

A roguelike deckbuilder tutorial project made in Godot 4.
MIT License
207 stars 30 forks source link

Confusing Staff is activated when a card a drawn with "trickster" #22

Closed LePadawan closed 3 months ago

LePadawan commented 3 months ago

Hi again,

I don't know if this is supposed to be that way but if you have the Confusing Staff, it is activated again every time a card a drawn with "trickster".

I found a simple fix but I don't know if it's the cleanest solution...

In player_handler.gd, I changed the following like this : Basically, draw_cards won't call player_hand_drawn signal now but draw_cards_start_of_turn will!

func draw_cards(amount: int) -> void:
    var tween := create_tween()
    for i in range(amount):
        tween.tween_callback(draw_card)
        tween.tween_interval(HAND_DRAW_INTERVAL)

func draw_cards_start_of_turn(amount: int) -> void:
    var tween := create_tween()
    for i in range(amount):
        tween.tween_callback(draw_card)
        tween.tween_interval(HAND_DRAW_INTERVAL)

    tween.finished.connect(
        func(): Events.player_hand_drawn.emit()
    )

and changed draw_cards to draw_cards_start_of_turn in _on_statuses_applied.

Hope that helps!

PS: another way to fix is to add a bool is_start_of_turn in the draw_cards function and to only emit the signal if the bool is true...

guladam commented 3 months ago

Hey, thanks for submitting!

I fixed it slightly differently:

Your solution works too!