/** * `item.ring` — el anillo de Emma 💍 que suelta la Araña Gigante. * Al recogerlo escribe `cave.ring` y `emma.ring`, muestra la tarjeta de recompensa y ofrece entregarlo: * viaja al portal de la Ciudad Emoji (queda capturado si aún no lo estaba) y Emma llega a recibirlo. */ import type { Game } from '../../core/game'; import type { Entity } from '../../core/entity'; import type { Props } from '../../core/types'; import { emojiMesh } from '../../render'; import { Pickup } from './pickup'; export class RingItem extends Pickup { constructor(props: Props) { super(props, 0.36); this.hover = 0.8; this.collectR = 0.95; this.magnet = 1.8; this.spin = 2.1; this.holder.add(emojiMesh('💍', 1.0, { glow: true, glowIntensity: 0.55, gloss: 1 })); } onAdded(): void { const st = this.game.state; if (st.has('emma.ring') || (!this.persistId && st.has('cave.ring'))) { this.kill(); return; } super.onAdded(); } protected onCollect(): void { const g = this.game; g.state.set('cave.ring', true); g.state.set('emma.ring', true); g.state.set('item.emma-ring', true); g.state.save(); g.vfx.ring(this.x, this.y + this.hover, 0xffe066, 2.4); g.vfx.burst('sparkle', this.x, this.y + this.hover, { count: 22, scale: 1.4, color: 0xffe066 }); g.vfx.burst('confetti', this.x, this.y + this.hover + 0.4, { count: 22 }); g.audio.sfx('gem'); g.audio.sfx('victory', { volume: 0.55 }); g.vfx.floatText('¡El anillo de Emma!', this.x, this.y + this.hover + 0.9, '#ffe066'); void (async () => { await g.ui.reward({ kind: 'item', emoji: '💍', name: 'El anillo de Emma', desc: 'Tiene una araña grabada. Habrá que devolvérselo a Emma en la ciudad.', color: '#ffc928', }); await offerRingDelivery(g); })(); } } /** Modal «¿Entregar el anillo a Emma?» → portal de la Ciudad Emoji y conversación con Emma. */ export async function offerRingDelivery(g: Game): Promise { if (!g.state.has('emma.ring') || g.state.has('emma.ringReturned') || !g.hasZone('city')) return; const i = await g.ui.choice( { speaker: 'Anillo de Emma', emoji: '💍', text: '¡Emma estará feliz! ¿Quieres entregarle el anillo ahora? El portal 🌀 te llevará a la Ciudad Emoji.' }, ['🌀 Sí, ¡llévame con Emma!', 'Más tarde'], ); if (i !== 0) { g.audio.sfx('ui_back'); g.ui.toast('Cuando quieras, pulsa Hablar en un portal 🌀 y viaja a la Ciudad Emoji', '💍'); return; } if (!g.state.has('tp.city')) g.state.set('tp.city', 'city|Ciudad Emoji'); g.state.save(); const h = g.hero; if (h) { h.inputLocked = true; g.audio.sfx('teleport'); g.vfx.burst('sparkle', h.x, h.y + 1, { count: 24, scale: 1.4, color: 0xc89bff }); } await g.loadZone('city', 'tp-city'); const nh = g.hero; if (!nh) return; g.vfx.burst('sparkle', nh.x, nh.y + 1, { count: 20, scale: 1.3, color: 0xc89bff }); g.audio.sfx('teleport', { pitch: 1.3 }); const emma = g.entities.find((e) => e.type === 'npc.emma' && !e.dead) as (Entity & { talk(): Promise }) | undefined; if (!emma) return; // Emma llega corriendo al portal emma.setPos(nh.x + 1.8, nh.y); g.vfx.burst('heart', emma.x, emma.y + 1.6, { count: 10 }); nh.inputLocked = true; await new Promise((r) => setTimeout(r, 700)); nh.inputLocked = false; await emma.talk(); }