guladam / deck_builder_tutorial

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

Issue happened if multiple player and/or enemy have status like exposed. #27

Closed CutUpTheEastWind closed 1 month ago

CutUpTheEastWind commented 1 month ago

I give player and enemies 10 duration of exposed in func _ready, if the enemy is tier_0 bats, there would be 3 thing with 10 duration exposed on the battlefiled. For each turn start, player's and enemies', all duration would -1 for each exposed status on the battlefiled, that means it would be -3 for 3 times in a turn. What cause that must be some mistake on signal, I didn't find a good way to solve it.

CutUpTheEastWind commented 1 month ago

I just find this thing only happened in test. I think reason is the exposed status created in func _ready is the same status attach on different character, that cause it change at same time and repeat for each status on the battlefield. It also happened if I make a new card that apply exposed on every enemy with the same code as big slam, I make this card apply 3 duration exposed and it disappear in 1 turn. To fix it, the func apply_effects and func execute should be changed to create the status for each target, but not attach the same status on different targets.

CutUpTheEastWind commented 1 month ago

I fix this bug by duplicate a exposed status for each target to execute, which is the updated apply_effects code:

func apply_effects(targets: Array[Node], modifiers: ModifierHandler):

for target in targets:
    var execute_target: Node = target
    var execute_targets: Array[Node] = []
    execute_targets.append(execute_target)
    var status_effect := StatusEffect.new()
    var exposed := EXPOSED_STATUS.duplicate()
    exposed.duration = exposed_duration
    status_effect.status = exposed
    status_effect.execute(execute_targets)
CutUpTheEastWind commented 1 month ago

I just find it was fixed in a better way, check https://github.com/guladam/deck_builder_tutorial/issues/25

guladam commented 1 month ago

Hey, sorry for only checking in but you are 100% correct it's the same issue as #25. Thanks for investigating and sorry for the delayed answer!