From e95a550388b9a5ff51d95fefac5071693068cdaf Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Thu, 15 Jul 2021 12:54:59 +0200 Subject: crusader: Fix Assassin target bug. --- rules.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'rules.js') diff --git a/rules.js b/rules.js index 16b6078..9e3cc1c 100644 --- a/rules.js +++ b/rules.js @@ -229,6 +229,16 @@ function select_random_block(where) { return list[Math.floor(Math.random() * list.length)]; } +function select_random_enemy_block(where) { + let list = []; + for (let b in BLOCKS) + if (game.location[b] === where && block_owner(b) === enemy(game.active)) + list.push(b); + if (list.length === 0) + return null; + return list[Math.floor(Math.random() * list.length)]; +} + function block_plural(who) { return BLOCKS[who].plural; } @@ -1323,7 +1333,7 @@ states.assassins = { }, block: function (who) { game.where = game.location[who]; - game.who = select_random_block(game.where); + game.who = select_random_enemy_block(game.where); game.location[ASSASSINS] = game.where; game.state = 'assassins_show_1'; }, -- cgit v1.2.3