Implement yellow teleport pickup behavior
This commit is contained in:
parent
3c43b8d7cd
commit
0cd1ea342d
31
js/game.js
31
js/game.js
@ -143,6 +143,14 @@ export class Cell extends Array {
|
||||
return ret;
|
||||
}
|
||||
|
||||
get_terrain() {
|
||||
for (let tile of this) {
|
||||
if (tile.type.draw_layer === 0)
|
||||
return tile;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
get_actor() {
|
||||
for (let tile of this) {
|
||||
if (tile.type.is_actor)
|
||||
@ -1183,6 +1191,13 @@ export class Level {
|
||||
this.set_actor_direction(actor, original_direction);
|
||||
}
|
||||
}
|
||||
|
||||
if (! success && actor.type.has_inventory && teleporter.type.name === 'teleport_yellow') {
|
||||
// Super duper special yellow teleporter behavior: you pick it the fuck up
|
||||
// FIXME not if there's only one in the level?
|
||||
this.give_actor(actor, 'teleport_yellow');
|
||||
this.transmute_tile(teleporter, 'floor');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1207,10 +1222,22 @@ export class Level {
|
||||
|
||||
// Drop the oldest item, i.e. the first one
|
||||
if (actor.toolbelt && (force || ! actor.cell.get_item())) {
|
||||
let name = actor.toolbelt.shift();
|
||||
this.pending_undo.push(() => actor.toolbelt.unshift(name));
|
||||
let name = actor.toolbelt[0];
|
||||
if (name === 'teleport_yellow') {
|
||||
// We can only be dropped on regular floor
|
||||
let terrain = actor.cell.get_terrain();
|
||||
if (terrain.type.name !== 'floor')
|
||||
return;
|
||||
|
||||
this.transmute_tile(terrain, 'teleport_yellow');
|
||||
}
|
||||
else {
|
||||
this.add_tile(new Tile(TILE_TYPES[name]), actor.cell);
|
||||
}
|
||||
|
||||
actor.toolbelt.shift();
|
||||
this.pending_undo.push(() => actor.toolbelt.unshift(name));
|
||||
}
|
||||
}
|
||||
|
||||
// Update the state of all wired tiles in the game.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user