Fix teeth not moving on levels without a time limit
This commit is contained in:
parent
4d44441983
commit
51a554286a
17
js/main.js
17
js/main.js
@ -326,8 +326,8 @@ class Level {
|
|||||||
if (! actor.cell)
|
if (! actor.cell)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Decrement the cooldown here, but only check it later because
|
// Decrement the cooldown here, but don't check it quite yet,
|
||||||
// stepping on cells in the next block might reset it
|
// because stepping on cells in the next block might reset it
|
||||||
if (actor.movement_cooldown > 0) {
|
if (actor.movement_cooldown > 0) {
|
||||||
this._set_prop(actor, 'movement_cooldown', actor.movement_cooldown - 1);
|
this._set_prop(actor, 'movement_cooldown', actor.movement_cooldown - 1);
|
||||||
}
|
}
|
||||||
@ -490,21 +490,26 @@ class Level {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.time_remaining !== null) {
|
// Pass time
|
||||||
let tic_counter = this.tic_counter;
|
let tic_counter = this.tic_counter;
|
||||||
let time_remaining = this.time_remaining;
|
let time_remaining = this.time_remaining;
|
||||||
|
this.tic_counter++;
|
||||||
|
if (this.time_remaining !== null && this.tic_counter % 20 === 0) {
|
||||||
|
// 20 tics means one second! Tic that time down
|
||||||
this.pending_undo.push(() => {
|
this.pending_undo.push(() => {
|
||||||
this.tic_counter = tic_counter;
|
this.tic_counter = tic_counter;
|
||||||
this.time_remaining = time_remaining;
|
this.time_remaining = time_remaining;
|
||||||
});
|
});
|
||||||
|
|
||||||
this.tic_counter++;
|
|
||||||
if (this.tic_counter % 20 === 0) {
|
|
||||||
this.time_remaining -= 1;
|
this.time_remaining -= 1;
|
||||||
if (this.time_remaining <= 0) {
|
if (this.time_remaining <= 0) {
|
||||||
this.fail("Time's up!");
|
this.fail("Time's up!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
this.pending_undo.push(() => {
|
||||||
|
this.tic_counter = tic_counter;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip out any destroyed actors from the acting order
|
// Strip out any destroyed actors from the acting order
|
||||||
@ -765,6 +770,8 @@ class Level {
|
|||||||
|
|
||||||
_set_prop(obj, key, val) {
|
_set_prop(obj, key, val) {
|
||||||
let old_val = obj[key];
|
let old_val = obj[key];
|
||||||
|
if (val === old_val)
|
||||||
|
return;
|
||||||
this.pending_undo.push(() => obj[key] = old_val);
|
this.pending_undo.push(() => obj[key] = old_val);
|
||||||
obj[key] = val;
|
obj[key] = val;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user