This pull request has a partial implementation to fix issue #50. Upon death, the unit in question is correctly removed from the game world. However, there are two cases where this fails:
Enemy attacks player, and enemy dies in counter-attack. If there are any other enemies on the map, the enemy turn will end. This is probably because the main loop in main.js doesn't recognize there are more enemies?
The same thing happens on the other end. If a player attacks an enemy and dies in the counter-attack, if there are more players, then the player turn will end.
I opened this pull request in the hopes that @chessmasterhong could see how these edge cases can be fixed?
Another way I contemplated fixing this is that if that unit is dead, put a dead flag on them. Allow any units to be able to move on top of a dead unit and occupy their space. This works in all cases, a player can then move on that space and things will work fine. At least, I think so because it seems that dead enemies are removed once the turn ends. I'm not sure yet, but we'd preferably want to do the first implementation.
This pull request has a partial implementation to fix issue #50. Upon death, the unit in question is correctly removed from the game world. However, there are two cases where this fails:
main.js
doesn't recognize there are more enemies?I opened this pull request in the hopes that @chessmasterhong could see how these edge cases can be fixed?
Another way I contemplated fixing this is that if that unit is dead, put a
dead
flag on them. Allow any units to be able to move on top of a dead unit and occupy their space. This works in all cases, a player can then move on that space and things will work fine. At least, I think so because it seems that dead enemies are removed once the turn ends. I'm not sure yet, but we'd preferably want to do the first implementation.