diff options
author | Tor Andersson <tor@ccxvii.net> | 2021-07-15 12:54:59 +0200 |
---|---|---|
committer | Tor Andersson <tor@ccxvii.net> | 2022-11-16 19:19:39 +0100 |
commit | e95a550388b9a5ff51d95fefac5071693068cdaf (patch) | |
tree | 9e4b7d2e2b602bcddde8cacd3b85300cc28d4118 | |
parent | 710d4f49e3a72e24bfefbaf404762c5649c1e9a4 (diff) | |
download | crusader-rex-e95a550388b9a5ff51d95fefac5071693068cdaf.tar.gz |
crusader: Fix Assassin target bug.
-rw-r--r-- | rules.js | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -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'; }, |