From bf3c501353e099786353c95dd662461439040ea3 Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Mon, 14 Dec 2020 23:14:31 -0700 Subject: [PATCH] Fix yellow tank behavior to be faux simultaneous --- js/game.js | 14 +++++++++----- js/tiletypes.js | 14 +++++++++++--- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/js/game.js b/js/game.js index e595b39..40b78c9 100644 --- a/js/game.js +++ b/js/game.js @@ -943,11 +943,7 @@ export class Level { direction = actor.cell.redirect_exit(actor, direction); - let dest_cell = this.get_neighboring_cell(actor.cell, direction); - if (dest_cell && - ! actor.cell.blocks_leaving(actor, direction) && - ! dest_cell.blocks_entering(actor, direction, this, actor === this.player ? 'move' : 'trace')) - { + if (this.is_move_allowed(actor, direction, 'trace')) { // We found a good direction! Stop here actor.decision = direction; all_blocked = false; @@ -988,6 +984,14 @@ export class Level { } } + // FIXME make this interact with railroads correctly and use it for players and in attempt_step + is_move_allowed(actor, direction, push_mode) { + let dest_cell = this.get_neighboring_cell(actor.cell, direction); + return (dest_cell && + ! actor.cell.blocks_leaving(actor, direction) && + ! dest_cell.blocks_entering(actor, direction, this, push_mode)); + } + // Try to move the given actor one tile in the given direction and update their cooldown. // Return true if successful. attempt_step(actor, direction) { diff --git a/js/tiletypes.js b/js/tiletypes.js index a505606..36ec134 100644 --- a/js/tiletypes.js +++ b/js/tiletypes.js @@ -1339,14 +1339,22 @@ const TILE_TYPES = { on_arrive(me, level, other) { level.sfx.play_once('button-press', me.cell); - // Move all yellow tanks one tile in the direction of the pressing actor + // Move all yellow tanks one tile in the direction of the pressing actor. But pretend + // it's simultaneous, so one in front will block one behind as usual. + // XXX this feels really weird, i'm wondering if cc2 does some other weird thing like + // not move any actor out of its cell until its first cooldown tick?? + // FIXME not sure this interacts with railroads correctly + let unblocked_tanks = []; for (let i = level.actors.length - 1; i >= 0; i--) { let actor = level.actors[i]; // TODO generify somehow?? - if (actor.type.name === 'tank_yellow') { - level.attempt_out_of_turn_step(actor, other.direction); + if (actor.type.name === 'tank_yellow' && level.is_move_allowed(actor, other.direction, 'trace')) { + unblocked_tanks.push(actor); } } + for (let actor of unblocked_tanks) { + level.attempt_out_of_turn_step(actor, other.direction); + } }, on_depart(me, level, other) { level.sfx.play_once('button-release', me.cell);