summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.js17
1 files changed, 12 insertions, 5 deletions
diff --git a/rules.js b/rules.js
index b872423..fbbec3f 100644
--- a/rules.js
+++ b/rules.js
@@ -829,11 +829,18 @@ function check_victory() {
return goto_game_over("Draw", player_name(1) + " secured a draw!")
}
- 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!")
+ // 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!")
+ }
return false
}