feat: gadget backpack system — save circuits as items
Add Pokemon-style inventory where players save crafted circuits as "gadgets" in a backpack. Gadgets can be used on puzzle doors to solve them by testing their truth table against required outputs. New files: - js/world/inventory.js: gadget data model, backpack UI (list with scroll, action menu, detail panel), keyboard navigation Changes: - Workshop gets "Save as Gadget" button (pink, top-right) - I key opens backpack overlay in world mode - Puzzle doors open backpack to select a gadget to try - HUD shows gadget count instead of old component count - worldState gains gadgets[] array Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
import { worldState, advanceDialog, startDialog } from './worldState.js';
|
||||
import { getMap, getInteraction, getNPC, getExit, isWalkable } from './maps.js';
|
||||
import { toggleDebug } from './worldRenderer.js';
|
||||
import { isBackpackOpen, openBackpack, handleBackpackInput } from './inventory.js';
|
||||
|
||||
const keysDown = new Set();
|
||||
let interactionHandler = null;
|
||||
@@ -25,6 +26,13 @@ function onKeyDown(e) {
|
||||
const key = e.key;
|
||||
keysDown.add(key);
|
||||
|
||||
// Backpack open — route all input there
|
||||
if (isBackpackOpen()) {
|
||||
e.preventDefault();
|
||||
handleBackpackInput(key);
|
||||
return;
|
||||
}
|
||||
|
||||
// During dialog: advance on action keys
|
||||
if (worldState.dialog) {
|
||||
if (key === 'Enter' || key === ' ' || key === 'e' || key === 'E') {
|
||||
@@ -43,6 +51,13 @@ function onKeyDown(e) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Backpack toggle (I)
|
||||
if (key === 'i' || key === 'I') {
|
||||
e.preventDefault();
|
||||
openBackpack(null);
|
||||
return;
|
||||
}
|
||||
|
||||
// Workshop shortcut (TAB)
|
||||
if (key === 'Tab') {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user