diff options
author | Tor Andersson <tor@ccxvii.net> | 2024-01-07 20:08:50 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:48 +0100 |
commit | ba60397ac0ae4b12d1b731f2b74fab4f1ddbf188 (patch) | |
tree | a52ff18b71b582ed678c3b8ac0aae4fb15ad3f48 | |
parent | 0a018ac9b56df9aca2876064f472ce34bf7557e8 (diff) | |
download | table-battles-ba60397ac0ae4b12d1b731f2b74fab4f1ddbf188.tar.gz |
Simultaneous tactical victory results in a draw.
-rw-r--r-- | rules.js | 26 |
1 files changed, 11 insertions, 15 deletions
@@ -872,26 +872,22 @@ function check_victory() { if (game.morale[1] === 0) return goto_game_over(P1, player_name(1) + " ran out of morale!") - let tv0 = get_tactical_victory_points(0) - let tv1 = get_tactical_victory_points(1) + let tc1 = info.players[0].tactical + let tc2 = info.players[1].tactical + let tv1 = get_tactical_victory_points(0) + let tv2 = get_tactical_victory_points(1) if (game.scenario === S38_FLEURUS) { - if (tv1 >= 22) + if (tv2 >= 22) return goto_game_over("Draw", player_name(1) + " secured a draw!") } - // Active player gets precedence when both TV conditions apply - if (game.active === P1) { - if (info.players[0].tactical > 0 && tv0 >= info.players[0].tactical) - return goto_game_over(P1, player_name(0) + " won a tactical victory!") - if (info.players[1].tactical > 0 && tv1 >= info.players[1].tactical) - return goto_game_over(P2, player_name(1) + " won a tactical victory!") - } else { - if (info.players[1].tactical > 0 && tv1 >= info.players[1].tactical) - return goto_game_over(P2, player_name(1) + " won a tactical victory!") - if (info.players[0].tactical > 0 && tv0 >= info.players[0].tactical) - return goto_game_over(P1, player_name(0) + " won a tactical victory!") - } + if (tc1 > 0 && tc2 > 0 && tv1 >= tc1 && tv2 >= tc2) + return goto_game_over("Draw", player_name(0) + " and " + player_name(1) + " achieved tactical victory at the same time.") + if (tc1 > 0 && tv1 >= tc1) + return goto_game_over(P1, player_name(0) + " won a tactical victory!") + if (tc2 > 0 && tv2 >= tc2) + return goto_game_over(P2, player_name(1) + " won a tactical victory!") return false } |