Disable action buttons when appropriate; add inv overflow; partial CC1 support
This commit is contained in:
parent
e51665b612
commit
c1452e005f
14
js/game.js
14
js/game.js
@ -1187,6 +1187,8 @@ export class Level {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cycle_inventory(actor) {
|
cycle_inventory(actor) {
|
||||||
|
if (this.stored_level.use_cc1_boots)
|
||||||
|
return;
|
||||||
if (actor.movement_cooldown > 0)
|
if (actor.movement_cooldown > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1197,12 +1199,14 @@ export class Level {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
drop_item(actor) {
|
drop_item(actor, force = false) {
|
||||||
|
if (this.stored_level.use_cc1_boots)
|
||||||
|
return;
|
||||||
if (actor.movement_cooldown > 0)
|
if (actor.movement_cooldown > 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Drop the oldest item, i.e. the first one
|
// Drop the oldest item, i.e. the first one
|
||||||
if (actor.toolbelt && ! actor.cell.get_item()) {
|
if (actor.toolbelt && (force || ! actor.cell.get_item())) {
|
||||||
let name = actor.toolbelt.shift();
|
let name = actor.toolbelt.shift();
|
||||||
this.pending_undo.push(() => actor.toolbelt.unshift(name));
|
this.pending_undo.push(() => actor.toolbelt.unshift(name));
|
||||||
this.add_tile(new Tile(TILE_TYPES[name]), actor.cell);
|
this.add_tile(new Tile(TILE_TYPES[name]), actor.cell);
|
||||||
@ -1675,6 +1679,7 @@ export class Level {
|
|||||||
|
|
||||||
// Give an item to an actor, even if it's not supposed to have an inventory
|
// Give an item to an actor, even if it's not supposed to have an inventory
|
||||||
give_actor(actor, name) {
|
give_actor(actor, name) {
|
||||||
|
// TODO support use_cc1_boots here -- silently consume dupes, only do cc1 items
|
||||||
if (! actor.type.is_actor)
|
if (! actor.type.is_actor)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -1693,6 +1698,11 @@ export class Level {
|
|||||||
}
|
}
|
||||||
actor.toolbelt.push(name);
|
actor.toolbelt.push(name);
|
||||||
this.pending_undo.push(() => actor.toolbelt.pop());
|
this.pending_undo.push(() => actor.toolbelt.pop());
|
||||||
|
|
||||||
|
// Nothing can hold more than four items
|
||||||
|
if (actor.toolbelt.length > 4) {
|
||||||
|
this.drop_item(actor, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -961,8 +961,12 @@ class Player extends PrimaryView {
|
|||||||
this.undo_button.disabled = ! this.level.has_undo();
|
this.undo_button.disabled = ! this.level.has_undo();
|
||||||
this.rewind_button.disabled = ! (this.level.has_undo() || this.state === 'rewinding');
|
this.rewind_button.disabled = ! (this.level.has_undo() || this.state === 'rewinding');
|
||||||
|
|
||||||
this.drop_button.disabled = ! (this.state === 'playing' && this.level.player.toolbelt && this.level.player.toolbelt.length > 0);
|
this.drop_button.disabled = ! (
|
||||||
this.cycle_button.disabled = ! (this.state === 'playing' && this.level.player.toolbelt && this.level.player.toolbelt.length > 1);
|
this.state === 'playing' && ! this.level.stored_level.use_cc1_boots &&
|
||||||
|
this.level.player.toolbelt && this.level.player.toolbelt.length > 0);
|
||||||
|
this.cycle_button.disabled = ! (
|
||||||
|
this.state === 'playing' && ! this.level.stored_level.use_cc1_boots &&
|
||||||
|
this.level.player.toolbelt && this.level.player.toolbelt.length > 1);
|
||||||
this.swap_button.disabled = ! (this.state === 'playing' && this.level.players.length > 1);
|
this.swap_button.disabled = ! (this.state === 'playing' && this.level.players.length > 1);
|
||||||
|
|
||||||
// TODO can we do this only if they actually changed?
|
// TODO can we do this only if they actually changed?
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user