summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2023-12-31 17:46:58 +0100
committerTor Andersson <tor@ccxvii.net>2024-01-08 16:36:48 +0100
commitda2308355d3893ab49651aa1985a6b112ef1640c (patch)
treef53009b47911f5ccaf78207c4b815edb5d4b3f6f
parent1b57158d8f8521b7335f4390bb55ca68fe4097e9 (diff)
downloadtable-battles-da2308355d3893ab49651aa1985a6b112ef1640c.tar.gz
Active player wins if both Tactical Victory conditions are fulfilled.
-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
}