From 54d38527f2fa97ca2234cfd458a8d8d38d67a4fb Mon Sep 17 00:00:00 2001 From: "Eevee (Evelyn Woods)" Date: Thu, 4 Feb 2021 21:09:01 -0700 Subject: [PATCH] Disallow taking yellow teleporters if the level only started with one (fixes #30) --- js/game.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/js/game.js b/js/game.js index 511e57f..26f89f3 100644 --- a/js/game.js +++ b/js/game.js @@ -464,6 +464,9 @@ export class Level extends LevelInterface { let n = 0; let connectables = []; this.remaining_players = 0; + // If there's exactly one yellow teleporter when the level loads, it cannot be picked up + let yellow_teleporter_count = 0; + this.allow_taking_yellow_teleporters = false; // Speedup for flame jets, which aren't actors but do a thing every tic // TODO this won't notice if a new tile with an on_tic is created, but that's impossible // atm... or, at least, it's hacked to still work with flame_jet_off @@ -504,6 +507,13 @@ export class Level extends LevelInterface { if (tile.type.connects_to) { connectables.push(tile); } + + if (tile.type.name === 'teleport_yellow' && ! this.allow_taking_yellow_teleporters) { + yellow_teleporter_count += 1; + if (yellow_teleporter_count > 1) { + this.allow_taking_yellow_teleporters = true; + } + } } } } @@ -1780,9 +1790,10 @@ export class Level extends LevelInterface { } if (! success) { - if (actor.type.has_inventory && teleporter.type.name === 'teleport_yellow') { + if (actor.type.has_inventory && teleporter.type.name === 'teleport_yellow' && + this.allow_taking_yellow_teleporters) + { // Super duper special yellow teleporter behavior: you pick it the fuck up - // FIXME not if there's only one in the level? this.make_slide(actor, null); this.attempt_take(actor, teleporter); if (actor === this.player) {