Check if unit is alive after effects #63
Comments
|
I took a look at this issue, but I imagine that if an effect that damages the unit is created, it would call the unit.takeDamage which already verifies if the unit died. Am I missing something here? Or maybe I misunderstood the issue. |
|
I think this will be clearer if I explain how the turns are played by the units in the floor:
Example:
Now, what this issue is about is putting a similar check in place for the effects. The effects are executed here, during Example:
Open questions:
|
|
Thanks for that response, it really cleared things up. The |
|
Hey @PB020, I encourage you to open a PR if you want to try a fix for this! We can discuss the code there with better instruments. Here are some comments regarding what you already posted though: this.effects.forEach(effect => effect.passTurn());
if (this.isAlive()) {There you're only checking once, after all effects have been executed. In order to check after each effect, the check needs to be done inside the else {
this.log(`You have $(this.health) out of $(this.maxHealth). You are dead.`);
}This code is redundant and should be removed. If an effect kills the unit, this will be logged by the effect already. |
|
You can use |
|
@IceDune Sure! Let me know if you have any questions. |
|
It's been a while since the last comment on this, so I opened #250 - hope it works as expected. If there is any case I missed let me know. |


A negative effect could potentially kill a unit. We need to check if the unit is still alive after executing the effects and return early if the unit died. Example: a "poisoned" effect (it doesn't exist, at least yet) that damages the unit turn by turn.
The text was updated successfully, but these errors were encountered: