jingyuyao / tactical-adventure

A turn based strategy game inspired by Fire Emblem and Advance Wars
MIT License
1 stars 0 forks source link

Lose condition should be checked first after a battle #192

Closed jingyuyao closed 6 years ago

jingyuyao commented 6 years ago

Currently, if a player ship tied to a lose condition dies during a battle that kills a enemy ship that is part of the win condition, the level will be completed but the save file will be corrupted. This happens because we run the script for dead ships in (random) sequence so if we processed the dead enemy ship before the dead player ship the script will emit a LevelWon event.

We need to either make sure the dead player ships are processed first OR processed all dead ships and queue up the events to fire "together".

Also, the triggered LevelWon event will bypass dead player ship removal so the saved will contain a player ship with zero HP (which violates the contract for the world).

jingyuyao commented 6 years ago

Based on initial investigation, this bug can be fixed by: