From f0f23bd0b25d7f7c1576e73f8300d595e20948bf Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Sat, 7 May 2022 11:36:47 +0200 Subject: Don't allow betray action if only spies are on bodyguards. --- rules.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/rules.js b/rules.js index 8ad6713..6e30820 100644 --- a/rules.js +++ b/rules.js @@ -408,11 +408,16 @@ function active_rules_any_region() { return player_rules_any_region(game.active); } -function active_has_spy() { +function active_can_betray() { let x = active_cylinders(); - for (let i = x; i < x + 10; ++i) - if (game.pieces[i] >= 1 && game.pieces[i] <= 100) - return true; + for (let i = x; i < x + 10; ++i) { + if (game.pieces[i] >= 1 && game.pieces[i] <= 100) { + let c = game.pieces[i]; + let p = find_card_in_court(c); + if (!player_has_bodyguards(p)) + return true; + } + } return false; } @@ -922,7 +927,7 @@ states.actions = { usable = true; } - if (card.betray && player.coins >= 2 && active_has_spy()) { + if (card.betray && player.coins >= 2 && active_can_betray()) { gen_action('betray', c); usable = true; } -- cgit v1.2.3