diff options
author | Tor Andersson <tor@ccxvii.net> | 2023-12-31 17:46:58 +0100 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2024-01-08 16:36:48 +0100 |
commit | da2308355d3893ab49651aa1985a6b112ef1640c (patch) | |
tree | f53009b47911f5ccaf78207c4b815edb5d4b3f6f | |
parent | 1b57158d8f8521b7335f4390bb55ca68fe4097e9 (diff) | |
download | table-battles-da2308355d3893ab49651aa1985a6b112ef1640c.tar.gz |
Active player wins if both Tactical Victory conditions are fulfilled.
-rw-r--r-- | rules.js | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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 } |