/** * Eddy 💧 — guardián de la laguna: una gota azul con gafas de buceo. Reto de los nenúfares → * BURBUJAS; luego PISTOLA DE AGUA y la misión de los globos; al final, corazón extra y monedas. * * Flags: escribe `eddy.met`, `eddy.bubbles`, `eddy.watergun`, `eddy.reward`; * lee `lagoon.crossed` (zona lagoon) y `lagoon.balloons` (item.balloon). * Se puede colocar más de un Eddy (p. ej. uno en cada orilla): comparten los flags. */ import type { Game } from '../../core/game'; import type { Props } from '../../core/types'; import { actionLabel } from '../../ui'; import { rand } from '../../core/math'; import { Npc, type Script } from './npc'; export const BALLOONS_NEEDED = 3; export class Eddy extends Npc { private chatter = 0; private bubbleT = rand(1, 3); constructor(props: Props) { super({ id: 'eddy', name: 'Eddy', emoji: '💧', facing: props.facing ?? 1, chibi: { color: 0x2fa8f5, shape: 'drop', expression: 'happy', accessory: 'visor', size: 1, emissive: 0x2fa8f5, emissiveIntensity: 0.06 }, }); } hasNews(): boolean { const f = this.flags; if (!f.has('eddy.met')) return true; if (f.has('lagoon.crossed') && !f.has('eddy.bubbles')) return true; if (f.has('eddy.bubbles') && !f.has('eddy.watergun')) return true; return f.has('eddy.watergun') && !f.has('eddy.reward') && f.num('lagoon.balloons') >= BALLOONS_NEEDED; } protected tick(dt: number): void { this.bubbleT -= dt; if (this.bubbleT <= 0) { this.bubbleT = rand(1.5, 3.5); this.game.vfx.burst('bubble', this.x + this.face * 0.25, this.y + 1.05, { count: 1, scale: 0.45, dirY: 1 }); } } protected script(): Script { const f = this.flags; const g = this.game; const tool = actionLabel(g, 'tool'); const up = actionLabel(g, 'up'); if (!f.has('eddy.met')) { return { lines: [ ...this.say( '¡Glub! Soy Eddy, guardián de la laguna. Mitad gota, mitad socorrista. 💧', 'Los alienígenas pasaron por aquí y ahora el agua está… mojadísima. Más que de costumbre.', 'Esta laguna solo se cruza con burbujas. Y tú, de burbujas, cero. 🫧', 'Te propongo un reto: cruza saltando por los nenúfares hasta la otra orilla sin tocar el agua.', 'Si lo logras, te enseño mi secreto burbujil. ¡Glub, glub, suerte!', ), ], after: () => { f.set('eddy.met', true); g.quests.start('lagoon-cross'); g.state.save(); }, }; } if (!f.has('lagoon.crossed')) { return { lines: this.pick([ ['Nenúfar, salto, nenúfar, salto… ¡y nada de chapuzones! 🪷'], ['Si caes al agua no pasa nada… salvo a mi orgullo de entrenador.'], ['Consejo de gota: mantén pulsado el salto para llegar más lejos.'], ]), }; } if (!f.has('eddy.bubbles')) { return { lines: [ ...this.say( '¡Glub-tástico! Cruzaste sin mojarte ni un pelo. Bueno… no tienes pelo.', 'Te has ganado mi poder: ¡las BURBUJAS! 🫧', `Pulsa [${tool}] y crea una burbuja-plataforma donde la necesites: abismos, lagunas, lo que sea.`, ), this.hero('¡Ya soy un emoji burbujeante!'), ...this.say('Habla conmigo otra vez cuando quieras: tengo otro encarguito. 😏'), ], after: () => { f.set('eddy.bubbles', true); g.hero?.grantTool('bubbles'); g.state.save(); }, }; } if (!f.has('eddy.watergun')) { return { lines: [ ...this.say( 'Unos globos rojos alienígenas flotan sobre mi laguna. ¡Me tapan el sol! 🎈', 'Toma mi PISTOLA DE AGUA. 🔫 Súbete a una burbuja y dispárales desde ahí.', `Con [${tool}] + [${up}], o de pie sobre una burbuja, disparas agua.`, `Revienta los ${BALLOONS_NEEDED} globos y vuelve a contármelo. ¡Habrá premio!`, ), ], after: () => { f.set('eddy.watergun', true); g.hero?.grantTool('watergun'); g.quests.start('lagoon-balloons'); g.state.save(); }, }; } const n = f.num('lagoon.balloons'); if (!f.has('eddy.reward')) { if (n < BALLOONS_NEEDED) { return { lines: this.pick([ [`Llevas ${n} de ${BALLOONS_NEEDED} globos. ¡Pium, pium! 🔫`], [`Recuerda: [${tool}] + [${up}] dispara agua. Encima de una burbuja, solo [${tool}].`, `Llevas ${n} de ${BALLOONS_NEEDED}.`], ]), }; } return { lines: [ ...this.say( '¡POP, POP, POP! ¡Qué música más bonita! 🎶', 'Tu recompensa: un corazón extra ❤️ y un buen puñado de monedas. 🪙', 'Ahora sigue hacia la cueva. Los mineros vigilan la entrada… y la Araña Gigante, el anillo de Emma.', ), this.hero('¡Allá voy!'), ], after: () => this.giveReward(), }; } return { lines: this.pick([ ['La cueva está más allá. ¡Saluda a los mineros de mi parte! ⛏️'], ['Glub. (Es "adiós" en gota.) 💧'], ['Cuando quieras practicar burbujas, mi laguna es tu laguna. 🫧'], ]), }; } private giveReward(): void { const g = this.game; const st = g.state; if (st.has('eddy.reward')) return; st.data.maxHp += 2; st.data.hp = st.data.maxHp; st.addCoins(10); st.set('eddy.reward', true); st.changed(); const h = g.hero; if (h) { g.vfx.burst('heart', h.x, h.y + 0.6, { count: 10, scale: 1.2 }); g.vfx.burst('star', h.x, h.y + 0.8, { count: 12 }); g.vfx.floatText('+1 ❤️ +10 🪙', h.x, h.y + 1.4, '#ffe066'); } g.audio.sfx('heart'); g.audio.sfx('powerup'); void g.ui.reward({ kind: 'item', emoji: '❤️', name: '¡Corazón extra!', desc: 'Tu vida máxima aumenta y se rellena por completo.', color: '#ff5a7a' }); this.rig.play('victory'); st.save(); } private pick(convs: string[][]) { return this.say(...convs[this.chatter++ % convs.length]); } } export function createEddy(_g: Game, _x: number, _y: number, props: Props): Eddy { return new Eddy(props); }