Decide who has won a battle, including when everyone loses in the same moment
An explosion kills the last unit of both sides at once, or a player has no soldiers left but still a barracks. A victory check that runs after every single death announces the wrong winner. Here is when to check, what counts as being alive, and how to call a draw.
Why this works
Several things can happen in one moment, so the end of a game must be judged after the whole action is settled, not in the middle of it. Defining who is still alive and when only one team remains makes the answer, including a draw, follow from the final picture.
When not to use it
Wrong for games where winning means a goal, not wiping out the enemy, such as reaching a place or holding a point for a time. Rules with a score or a timer need their own check. For one-on-one duels a plain test of who has health left is enough.
In the full entry
- What to build, step by step
- Starting values and the reason for each
- 4 common mistakes and the fix
- 16 lines of example code with 4 checks that pass
- How your AI shows you that it works
Say this to your AI
Use the Spielerando entry "Decide who has won a battle, including when everyone loses in the same moment" (read_entry win-lose-check-with-draws) in my game. Build it step by step, and show me how you checked that it works.Or skip this and connect the MCP: your AI then finds all of this by itself.Connect the MCP