Le bibite si bevono con un clic; un oggetto cliccato due volte si usa da solo

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-24 00:58:53 +02:00
co-authored by Claude Opus 5.5
parent 2d32e552f8
commit 7ee27c28cd
3 changed files with 27 additions and 1 deletions
+8 -1
View File
@@ -19,6 +19,7 @@ export class Command {
// Testo della riga sotto la scena, con l'eventuale bersaglio sotto il puntatore.
sentence(target = null) {
const g = this.game, name = target && g.targetName(target);
if (this.item && target === this.item && this.verb === 'use') return `${VERB_LABELS.use} ${g.itemName(this.item)}`;
if (this.item) return `${VERB_LABELS[this.verb]} ${g.itemName(this.item)} ${this.verb === 'give' ? 'a' : 'con'}${name ? ' ' + name : '…'}`;
if (this.verb) return `${VERB_LABELS[this.verb]}${name ? ' ' + name : '…'}`;
if (!target) return '';
@@ -48,11 +49,17 @@ export class Command {
if (g.skip()) return 'skip';
if (g.dialogue || g.busy) return null;
if (look) { this.reset(); return g.act('look', id) && 'act'; }
// Di nuovo sullo stesso oggetto: lo si usa da solo (bere la Coca, mangiare il ghiacciolo).
if (this.item) {
const ok = this.item !== id && g.act('use', id, this.item);
const ok = this.item === id ? this.verb === 'use' && g.act('use', id) : g.act('use', id, this.item);
this.reset();
return ok ? 'act' : null;
}
// Gli oggetti che si usano solo da soli (`alone`, le bibite) non chiedono «con cosa».
if ((!this.verb || this.verb === 'use') && g.story.items[id]?.alone) {
this.reset();
return g.act('use', id) && 'act';
}
if (!this.verb || this.verb === 'use' || this.verb === 'give') {
this.verb ??= 'use';
this.item = id;