Implement random force floors

This commit is contained in:
Eevee (Evelyn Woods) 2020-09-01 05:26:25 -06:00
parent 7a9bc725d4
commit 9dccb310e0
2 changed files with 20 additions and 1 deletions

View File

@ -234,6 +234,8 @@ class Level {
this.tic_counter = 0; this.tic_counter = 0;
this.hint_shown = null; this.hint_shown = null;
// TODO in lynx/steam, this carries over between levels; in tile world, you can set it manually
this.force_floor_direction = 'north';
let n = 0; let n = 0;
let connectables = []; let connectables = [];
@ -615,12 +617,25 @@ class Level {
} }
} }
// -------------------------------------------------------------------------
// Level alteration methods. EVERYTHING that changes the state of a level,
// including the state of a single tile, should do it through one of these
// for undo/rewind purposes
collect_chip() { collect_chip() {
if (this.chips_remaining > 0) { if (this.chips_remaining > 0) {
this.chips_remaining--; this.chips_remaining--;
} }
} }
// Get the next direction a random force floor will use. They share global
// state and cycle clockwise.
get_force_floor_direction() {
let d = this.force_floor_direction;
this.force_floor_direction = DIRECTIONS[d].right;
return d;
}
// TODO make a set of primitives for actually altering the level that also // TODO make a set of primitives for actually altering the level that also
// record how to undo themselves // record how to undo themselves
make_slide(actor, mode) { make_slide(actor, mode) {

View File

@ -225,7 +225,11 @@ const TILE_TYPES = {
}, },
}, },
force_floor_all: { force_floor_all: {
// TODO cc2 cycles these... // TODO ms: this is random, and an acting wall to monsters (!)
on_arrive(me, level, other) {
other.direction = level.get_force_floor_direction();
level.make_slide(other, 'force');
},
}, },
bomb: { bomb: {
// TODO explode // TODO explode