summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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
}