summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Andersson <tor@ccxvii.net>2021-07-15 12:54:59 +0200
committerTor Andersson <tor@ccxvii.net>2022-11-16 19:19:39 +0100
commite95a550388b9a5ff51d95fefac5071693068cdaf (patch)
tree9e4b7d2e2b602bcddde8cacd3b85300cc28d4118
parent710d4f49e3a72e24bfefbaf404762c5649c1e9a4 (diff)
downloadcrusader-rex-e95a550388b9a5ff51d95fefac5071693068cdaf.tar.gz
crusader: Fix Assassin target bug.
-rw-r--r--rules.js12
1 files changed, 11 insertions, 1 deletions
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';
},