summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2024-01-07 20:08:50 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:48 +0100
commitba60397ac0ae4b12d1b731f2b74fab4f1ddbf188 (patch)
treea52ff18b71b582ed678c3b8ac0aae4fb15ad3f48
parent0a018ac9b56df9aca2876064f472ce34bf7557e8 (diff)
downloadtable-battles-ba60397ac0ae4b12d1b731f2b74fab4f1ddbf188.tar.gz
Simultaneous tactical victory results in a draw.
-rw-r--r--rules.js26
1 files changed, 11 insertions, 15 deletions
diff --git a/rules.js b/rules.js
index 0434915..dbca499 100644
--- a/rules.js
+++ b/rules.js
@@ -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
}