Icone a pixel per gli oggetti dell'inventario: squama, libro e chiave

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017egeN2amL84ErjfgQFtEDn
This commit is contained in:
2026-10-23 17:59:52 +02:00
co-authored by Claude Opus 5.5
parent 034b1b62e7
commit 891cb2bbb1
8 changed files with 28 additions and 6 deletions
+12 -3
View File
@@ -177,12 +177,21 @@ function updateInventory() {
inventoryKey = key;
const box = $('inventory');
box.replaceChildren(...game.state.inventory.map(id => {
const b = document.createElement('button'), item = story.items[id], dot = document.createElement('i');
const b = document.createElement('button'), item = story.items[id];
b.type = 'button';
b.dataset.item = id;
b.setAttribute('aria-pressed', String(command.item === id));
dot.style.background = item.icon?.fill ?? '#ccc';
b.append(dot, item.name);
// L'icona a pixel dell'oggetto (assets/icons); senza, un pallino del suo colore.
let icon;
if (item.icon?.src) {
icon = document.createElement('img');
icon.src = item.icon.src;
icon.alt = '';
} else {
icon = document.createElement('i');
icon.style.background = item.icon?.fill ?? '#ccc';
}
b.append(icon, item.name);
let timer = null, long = false;
b.addEventListener('pointerdown', () => { long = false; timer = setTimeout(() => { long = true; command.clickItem(id, { look: true }); }, LONG_PRESS); });
b.addEventListener('pointerup', () => clearTimeout(timer));
+3 -3
View File
@@ -38,7 +38,7 @@ export const story = {
items: {
squama: {
name: 'squama',
icon: { fill: '#4fae5e', shape: 'scale' },
icon: { src: 'assets/icons/squama.svg', fill: '#4fae5e' },
actions: {
look: [{ say: 'Una squama verde, grande come una moneta da due euro. Puzza di cantina.' }],
use: [{ say: 'Potrei usarla come plettro. Ma prima scopro di chi è.' }],
@@ -47,7 +47,7 @@ export const story = {
// Lo scherzo del libro (idea di Andrea, 2026-10-23): «La storia infinita» ha una pagina sola.
libro: {
name: 'libro',
icon: { fill: '#c46a3a', shape: 'book' },
icon: { src: 'assets/icons/libro.svg', fill: '#c46a3a' },
droppable: true, // non serve alla storia: si può buttare
actions: {
drop: [{ say: 'Una pagina sola, e pure con la fine. Lo lascio qui per il prossimo lettore.' }, { drop: 'libro' }],
@@ -63,7 +63,7 @@ export const story = {
// La chiave dell'oratorio: la dà San Pietro a chi risolve il suo indovinello. Indispensabile: non si butta.
chiave_oratorio: {
name: 'chiave dell\'oratorio',
icon: { fill: '#d9b54a', shape: 'key' },
icon: { src: 'assets/icons/chiave.svg', fill: '#d9b54a' },
actions: {
look: [{ say: 'Una chiave grossa e antica. Quella dell\'oratorio, parola di San Pietro.' }],
},