From 5416167192a2cd4dcb2b4134cc7d2f427ff7d900 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Tue, 1 Sep 2020 07:40:52 -0600 Subject: [PATCH] Disallow cloning when the target tile is blocked --- js/tiletypes.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/js/tiletypes.js b/js/tiletypes.js index 65e1354..a34110a 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -289,13 +289,23 @@ const TILE_TYPES = { let current_tiles = Array.from(cell); for (let tile of current_tiles) { if (tile !== me && tile.type.is_actor) { + // Copy this stuff in case the movement changes it + let type = tile.type; + let direction = tile.direction; + + // Unstick and try to move the actor; if it's blocked, + // abort the clone tile.stuck = false; - // TODO precise behavior? is this added immediately and can move later that same turn or what? - level.actors.push(tile); - // FIXME rearrange to make this possible lol - // FIXME go through level for this, and everything else of course - // FIXME add this underneath, just above the cloner - cell._add(new tile.constructor(tile.type, tile.x, tile.y, tile.direction)); + if (level.attempt_step(tile, direction)) { + level.actors.push(tile); + // FIXME rearrange to make this possible lol + // FIXME go through level for this, and everything else of course + // FIXME add this underneath, just above the cloner + cell._add(new tile.constructor(type, me.x, me.y, direction)); + } + else { + tile.stuck = true; + } } } },