/** * EL CASTILLO 🏰 — cuatro zonas que se suben devolviendo el tesoro en los cofres de cada sala. * * Aquí el jugador ya tiene TODOS los poderes (el HIELO se lo dio el Rey Frío en la puerta; el COOL se lo * da Emma al devolverle el anillo, viajando por los portales). * * castle-lava 🌋 Mazmorras: río de lava (LLUVIA), pasillo de chorros de vapor (bloques de HIELO para * taparlos) con una torreta al fondo (sus esquirlas las paran los bloques; HIELO o COOL * la detienen), lago de lava con plataformas (el calor revienta las burbujas), * escarabajos (FURIA), nicho tras roca agrietada, repisa alta de burbujas. Cofre 40🪙 + 2💎. * castle-hall 🗿 Salón de armas: torretas cruzadas + portón de antorchas y brasero alto (FUEGO); * arena del Jefe Piedra (auras de FUEGO/HIELO → choque térmico → FURIA). Cofre 60🪙 + 3💎. * castle-tower 🧊 Torre helada: gólems de escarcha (FUEGO), suelo resbaladizo, torretas y un muro con * VENTISCA (revienta burbujas): se trepa con bloques de HIELO + LLUVIA. Cofre 80🪙 + 4💎. * castle-roof 👑 Azotea: el Rey espera… y el Hechicero se revela. Combate final y desenlace. */ import * as THREE from 'three'; import type { Game } from '../../core/game'; import type { ZoneDef, ZoneContext } from '../../core/types'; import type { KitZoneContext } from '../kit/context'; import { invisibleWall } from './shared'; import { installForestKit } from './forestKit'; import { createChibi } from '../../characters/chibi'; import type { ChibiRig } from '../../characters/types'; import { Entity } from '../../core/entity'; import { vfxAmbient } from '../../vfx/index'; export const DEPOSITS = { // Proporcional al tesoro repartido (~200 🪙 en el mundo + ~110 de misiones y Eddy; 27 💎): // los tres cofres piden ~88 % de las monedas → hay que explorar y volver a las zonas (el mapa lleva la cuenta). lower: { coins: 110, diamonds: 7 }, hall: { coins: 80, diamonds: 6 }, tower: { coins: 85, diamonds: 7 }, }; function coinArc(z: ZoneContext, x0: number, x1: number, y: number, h: number, n: number): void { for (let i = 0; i < n; i++) { const u = n === 1 ? 0.5 : i / (n - 1); z.spawn('item.coin', x0 + (x1 - x0) * u, y + Math.sin(u * Math.PI) * h); } } /** Lava con daño y (opcional) costra que la LLUVIA endurece. */ function lavaPool(z: ZoneContext, x0: number, x1: number, surface: number, depth: number, rainFlag?: string): void { const lava = z.water(x0, x1, surface, depth, { lava: true, color: 0xff7a18, deep: 0x6e190c }); z.ground(x0, x1, surface - depth, { style: 'stone', plain: true }); const w = x1 - x0; const hz = z.area('hazard', x0 + w / 2, surface - 0.3, w, 1.2, { visual: false, damage: 1, element: 'fire' }); if (rainFlag) z.spawn('forest.lava', x0 + w / 2, surface, { w, flag: rainFlag, hazard: hz, lava }); } /** Muro de fondo del castillo (sin colisión) con pilastras y estandartes: da sensación de interior. */ function backWall(z: ZoneContext, x0: number, x1: number, y0: number, y1: number): void { const w = x1 - x0; z.block(x0 + w / 2, (y0 + y1) / 2, w, y1 - y0, { style: 'castle', zBack: -5.2, zFront: -3.6, plain: true }).enabled = false; for (let x = x0 + 4; x < x1 - 1; x += 9) { z.block(x, (y0 + y1) / 2, 1.2, y1 - y0, { style: 'castle', zBack: -3.6, zFront: -2.8, plain: true }).enabled = false; } } /** Puerta de sala que exige el cofre lleno (+ jefe si hace falta) con muro encima. */ function roomDoor(z: ZoneContext, x: number, id: string, requires: string, hint = '🎁'): void { z.spawn('puzzle.door', x, 0, { id, requires, w: 1.6, h: 4.6, style: 'castle', hint }); z.block(x, 10.5, 2.4, 11.4, { style: 'castle' }); } // ═══════════════════════════════ 🌋 Mazmorras ═══════════════════════════════ const lavaZone: ZoneDef = { id: 'castle-lava', name: 'Mazmorras del castillo', emoji: '🌋', bounds: { minX: 0, maxX: 150, minY: -6, maxY: 22 }, spawns: { default: { x: 4, y: 0 }, 'from-gate': { x: 4, y: 0 }, 'from-hall': { x: 141, y: 0 }, mid: { x: 66, y: 0 }, lake: { x: 96, y: 0 } }, env: 'castle', music: 'castle', build(z) { const g = z.game; const k = z as KitZoneContext; installForestKit(g); z.backdrop('volcano', { horizon: -1 }); backWall(z, 0, 150, -8, 16); invisibleWall(g, -0.5, 0, 30); invisibleWall(g, 150.5, 0, 30); // A · entrada z.ground(0, 22, 0, { style: 'castle' }); z.exit(1.4, 1.5, 1.8, 3, 'forest', 'from-castle', { door: true, arrow: 'left' }); z.spawn('item.checkpoint', 7, 0, { spawn: 'from-gate' }); z.prop('torch', 10, 0, { z: -1 }); z.prop('torch', 18, 0, { z: -1 }); z.prop('sign', 13, 0, { text: '🌋 Mazmorras', z: 0.4 }); coinArc(z, 14, 20, 1.3, 1.2, 5); // B · río de lava (22..34): demasiado ancho para saltarlo y el calor revienta las burbujas → LLUVIA lavaPool(z, 22, 35, -0.3, 2.6, 'castle.lava.river'); if (g.hasType('enemy.ember')) g.spawn('enemy.ember', 28.5, 0, { hover: 2.4 }); // C · pasillo de vapor (35..64): techo bajo, chorros a intervalos; un bloque de HIELO encima los tapa. // Al fondo, una torreta dispara a lo largo del pasillo: sus esquirlas las paran los bloques. z.ground(35, 66, 0, { style: 'castle' }); z.block(50.5, 7, 31, 4, { style: 'castle' }); for (const [x, off] of [[40, 0], [45.5, 0.8], [51, 1.6], [56.5, 0.4]] as const) { z.spawn('hazard.vent', x, 0, { h: 4.8, period: 2.4, offset: off }); } coinArc(z, 42.5, 54, 1.2, 0.5, 6); z.prop('sign', 37, 0, { text: '🌧️+🥶 = 🧊', z: 0.4 }); if (g.hasType('enemy.turret')) g.spawn('enemy.turret', 63.5, 0, { range: 30, period: 2.2 }); z.spawn('item.checkpoint', 66.5, 0, { spawn: 'mid' }); // D · gran lago de lava (68..94): imposible de saltar y el calor revienta las burbujas. // Hay que activar la LLUVIA y avanzar con ella: la lava se endurece en una costra pisable. z.ground(66, 68, 0, { style: 'castle' }); lavaPool(z, 68, 94, -0.3, 3, 'castle.lava.lake'); z.prop('sign', 66.5, 0, { text: '🌧️ ➡️ 🌋', z: 0.4 }); z.spawn('item.diamond', 81, 1.3, { id: 'castle-lava-gem' }); coinArc(z, 71, 91, 1.4, 1.6, 8); if (g.hasType('enemy.ember')) { g.spawn('enemy.ember', 76, 0, { hover: 2.2, range: 7 }); g.spawn('enemy.ember', 87, 0, { hover: 2.6, range: 7 }); } // E · sala de los escarabajos (94..122) con repisa alta (burbujas) y nicho tras roca (FURIA) z.ground(94, 116, 0, { style: 'castle' }); if (g.hasType('enemy.beetle')) { g.spawn('enemy.beetle', 101, 0, { patrol: [97, 108] }); g.spawn('enemy.beetle', 110, 0, { patrol: [106, 114] }); } z.platform(100.5, 5.2, 1.8, { style: 'stone', float: false }); z.platform(104.5, 10.2, 3, { style: 'stone', float: false }); z.spawn('item.chest', 104.5, 10.2, { id: 'castle-lava-ledge', contains: 'diamond' }); z.spawn('item.checkpoint', 96, 0, { spawn: 'lake' }); // nicho bajo el suelo elevado (116..122): tapado por roca agrietada z.ground(116, 122, 0, { style: 'castle' }); z.block(119.5, 3.75, 5, 1.5, { style: 'castle' }); z.block(121.6, 1.5, 0.8, 3, { style: 'castle' }); z.spawn('forest.rock', 117.4, 0, { w: 1.2, h: 3, flag: 'castle.rock.niche', hp: 2 }); z.spawn('item.diamond', 119.8, 0.9, { id: 'castle-niche-gem' }); z.platform(114, 2.4, 2, { style: 'stone', float: false }); // F · cofre y puerta z.ground(122, 150, 0, { style: 'castle' }); z.spawn('item.checkpoint', 126, 0, { spawn: 'from-hall' }); z.spawn('puzzle.deposit', 131, 0, { id: 'lower', ...DEPOSITS.lower }); roomDoor(z, 138, 'castle-lower', 'castle.deposited.lower'); z.exit(144, 1.5, 1.8, 3, 'castle-hall', 'from-lava', { door: true, arrow: 'right' }); coinArc(z, 124, 128, 1.3, 0.8, 3); z.spawn('item.heart', 98, 0.4); k.scatter('barrel', 2, 20, 0, 3, { z: -1.6 }); }, onEnter(game) { vfxAmbient(game, 'embers', { density: 0.5 }); }, onExit(game) { vfxAmbient(game, null); }, }; // ═══════════════════════════════ 🗿 Salón de armas ═══════════════════════════════ const HALL_ARENA = { x0: 37, x1: 75 }; let hallWalls: Array<{ enabled?: boolean }> = []; let hallBoss: Entity | null = null; const hallZone: ZoneDef = { id: 'castle-hall', name: 'Salón de armas', emoji: '🗿', bounds: { minX: 0, maxX: 142, minY: -4, maxY: 18 }, spawns: { default: { x: 3, y: 0 }, 'from-lava': { x: 3, y: 0 }, arena: { x: 33, y: 0 }, after: { x: 80, y: 0 }, cistern: { x: 113, y: 0 }, 'from-tower': { x: 132, y: 0 } }, env: 'castle', music: 'castle', build(z) { const g = z.game; const k = z as KitZoneContext; installForestKit(g); z.backdrop('castle', { horizon: -1 }); backWall(z, 0, 142, -8, 16); invisibleWall(g, -0.5, 0, 30); invisibleWall(g, 142.5, 0, 30); z.ground(0, 96, 0, { style: 'castle' }); z.ground(110, 142, 0, { style: 'castle' }); z.exit(1.4, 1.5, 1.8, 3, 'castle-lava', 'from-hall', { door: true, arrow: 'left' }); // A · galería de torretas y portón de antorchas (FUEGO; el brasero está alto: salta y lanza) z.block(14, 1.2, 2, 2.4, { style: 'castle' }); if (g.hasType('enemy.turret')) { g.spawn('enemy.turret', 14, 2.4, { range: 18 }); g.spawn('enemy.turret', 27, 0, { range: 16, period: 3 }); } z.spawn('forest.torch', 8, 0, { id: 'hall-a' }); z.spawn('forest.torch', 20, 0, { id: 'hall-b' }); z.platform(24, 3.8, 2, { style: 'stone', float: false }); z.spawn('forest.fireswitch', 24, 3.8, { id: 'hall-high' }); z.spawn('puzzle.door', 31, 0, { id: 'hall-torches', requires: 'forest.torch.hall-a,forest.torch.hall-b,forest.fireswitch.hall-high', w: 1.6, h: 4.6, style: 'castle', hint: '🔥' }); z.block(31, 10.5, 2.4, 11.4, { style: 'castle' }); coinArc(z, 4, 12, 1.3, 1.2, 5); z.spawn('item.checkpoint', 33.5, 0, { spawn: 'arena' }); // B · arena del Jefe Piedra hallWalls = [ g.physics.box(HALL_ARENA.x0, 9, 0.6, 18, { material: 'stone', tag: 'arena-wall' }), g.physics.box(HALL_ARENA.x1, 9, 0.6, 18, { material: 'stone', tag: 'arena-wall' }), ]; for (const w of hallWalls) w.enabled = false; z.prop('torch', 42, 0, { z: -1.4 }); z.prop('torch', 70, 0, { z: -1.4 }); z.platform(48, 3.4, 3, { style: 'stone', float: false }); z.platform(64, 3.4, 3, { style: 'stone', float: false }); hallBoss = null; if (!g.state.has('castle.stone.defeated') && g.hasType('boss.stone')) hallBoss = g.spawn('boss.stone', 66, 0, {}); // C · tras el jefe: repisa secreta (burbujas), escarabajos, cofre y puerta a la torre z.spawn('item.checkpoint', 80, 0, { spawn: 'after' }); if (g.hasType('enemy.beetle')) g.spawn('enemy.beetle', 88, 0, { patrol: [83, 94] }); // C2 · EL ALJIBE (96..110): llueve sin parar por el techo roto y hay un abismo. Las burbujas revientan // con la lluvia: solo se cruza creando BLOQUES DE HIELO con el aliento helado (salta y sopla). z.spawn('weather.rain', 103, 7, { w: 20, h: 16 }); for (const x of [95.4, 110.6]) z.block(x, 12.5, 1.2, 1.2, { style: 'castle' }).enabled = false; z.block(98, 14.6, 4, 1, { style: 'castle' }).enabled = false; z.block(108, 14.6, 4, 1, { style: 'castle' }).enabled = false; z.prop('sign', 94.2, 0, { text: '🌧️ + 🥶 = 🧊🧊🧊', z: 0.4 }); coinArc(z, 99, 107, 2.4, 1.4, 6); z.spawn('item.checkpoint', 113, 0, { spawn: 'cistern' }); z.platform(88, 5.4, 1.8, { style: 'stone', float: false }); z.platform(91.5, 10, 3, { style: 'stone', float: false }); z.spawn('item.chest', 91.5, 10, { id: 'castle-hall-ledge', contains: 'diamond' }); z.spawn('item.diamond', 24, 5.6, { id: 'castle-hall-brazier-gem' }); z.spawn('puzzle.deposit', 118, 0, { id: 'hall', ...DEPOSITS.hall }); roomDoor(z, 126, 'castle-hall-door', 'castle.deposited.hall,castle.stone.defeated'); z.spawn('item.teleporter', 130, 0, { id: 'castle-hall', name: 'Salón de armas' }); z.exit(136, 1.5, 1.8, 3, 'castle-tower', 'from-hall', { door: true, arrow: 'right' }); coinArc(z, 114, 117, 1.3, 0.8, 3); z.spawn('item.heart', 82, 0.4); k.scatter('barrel', 76, 84, 0, 2, { z: -1.6 }); }, update(game) { const h = game.hero; if (!h) return; const boss = hallBoss && !hallBoss.dead && !game.state.has('castle.stone.defeated'); const inside = h.x > HALL_ARENA.x0 + 2 && h.x < HALL_ARENA.x1 - 1; const close = !!boss && inside; for (const w of hallWalls) w.enabled = close; }, onExit(game) { game.ui.bossBar(null); hallBoss = null; }, }; // ═══════════════════════════════ 🧊 Torre helada ═══════════════════════════════ const towerZone: ZoneDef = { id: 'castle-tower', name: 'Torre helada', emoji: '🧊', bounds: { minX: 0, maxX: 60, minY: -2, maxY: 58 }, spawns: { default: { x: 4, y: 0 }, 'from-hall': { x: 4, y: 0 }, mid: { x: 54, y: 13.5 }, top: { x: 28, y: 28 }, 'from-roof': { x: 46, y: 42 } }, env: 'castle', music: 'castle', build(z) { const g = z.game; const k = z as KitZoneContext; z.backdrop('castle', { horizon: -1 }); backWall(z, 0, 60, -2, 58); // muros de la torre z.block(-1, 30, 2, 64, { style: 'castle' }); z.block(61, 30, 2, 64, { style: 'castle' }); z.ground(0, 60, 0, { style: 'ice' }); z.exit(1.6, 1.5, 1.8, 3, 'castle-hall', 'from-tower', { door: true, arrow: 'left' }); z.spawn('item.checkpoint', 5, 0, { spawn: 'from-hall' }); // Planta 0 (y 0..13.5): gólem de escarcha (FUEGO) y escalera de hielo resbaladizo if (g.hasType('enemy.frost')) g.spawn('enemy.frost', 22, 0, { patrol: [12, 30] }); z.platform(12, 3.4, 3, { style: 'ice' }); z.platform(19, 6.2, 3, { style: 'ice' }); z.platform(26, 9.2, 3, { style: 'ice' }); coinArc(z, 10, 27, 4.4, 4, 8); z.block(46, 12.75, 28, 1.5, { style: 'ice' }); // forjado 1 (x 32..60, techo 13.5) // Planta 1 (y 13.5..28): torreta a lo largo del forjado y MURO CON VENTISCA: las burbujas estallan, // hay que trepar creando bloques de HIELO con la LLUVIA activa. if (g.hasType('enemy.turret')) g.spawn('enemy.turret', 58.5, 13.5, { range: 24, period: 2.6 }); z.spawn('item.checkpoint', 54, 13.5, { spawn: 'mid' }); z.platform(40, 18.8, 1.8, { style: 'ice', float: false }); z.platform(44, 23.5, 1.8, { style: 'ice', float: false }); z.spawn('hazard.blizzard', 42, 21, { w: 8, h: 15 }); z.prop('sign', 48, 13.5, { text: '🌧️ + 🥶 ⬆️', z: 0.4 }); z.block(18.5, 27, 39, 2, { style: 'ice' }); // forjado 2 (x -1..38, techo 28) coinArc(z, 40, 44, 20, 1.5, 3); // Planta 2 (y 28..42): gólem y torreta; plataformas hacia el último forjado if (g.hasType('enemy.frost')) g.spawn('enemy.frost', 18, 28, { patrol: [8, 30] }); if (g.hasType('enemy.turret')) g.spawn('enemy.turret', 2, 28, { range: 20, period: 2.8 }); z.spawn('item.checkpoint', 28, 28, { spawn: 'top' }); z.platform(7, 31.6, 3, { style: 'ice' }); z.platform(13, 35, 3, { style: 'ice' }); z.platform(20, 38.4, 3, { style: 'ice' }); z.block(41, 41, 38, 2, { style: 'ice' }); // forjado 3 (x 22..60, techo 42) coinArc(z, 6, 20, 32.6, 4, 7); // repisa secreta (bloques de hielo o burbujas): diamante z.platform(30, 48, 2, { style: 'ice', float: false }); z.spawn('item.diamond', 30, 49, { id: 'castle-tower-gem' }); // Planta 3 (y 42..58): cofre y puerta a la azotea z.spawn('item.diamond', 4, 34, { id: 'castle-tower-wall-gem' }); z.spawn('puzzle.deposit', 48, 42, { id: 'tower', ...DEPOSITS.tower }); z.spawn('item.teleporter', 40, 42, { id: 'castle-tower', name: 'Torre helada' }); z.spawn('puzzle.door', 54, 42, { id: 'castle-tower-door', requires: 'castle.deposited.tower', w: 1.6, h: 4.6, style: 'castle', hint: '🎁' }); z.block(54, 52, 2.4, 15, { style: 'castle' }); z.exit(58, 43.5, 1.8, 3, 'castle-roof', 'from-tower', { door: true, arrow: 'up' }); z.spawn('item.heart', 36, 42.4); k.scatter('crystal', 2, 58, 0, 5, { z: -1.4, color: 0x9fdcff }); }, onEnter(game) { vfxAmbient(game, 'snow', { density: 0.4 }); }, onExit(game) { vfxAmbient(game, null); }, }; // ═══════════════════════════════ 👑 Azotea ═══════════════════════════════ /** El Rey en la azotea (escena): de pie, luego hipnotizado y dormido; al final, liberado. */ class RoofKing extends Entity { readonly rig: ChibiRig; mood: 'wait' | 'spell' | 'asleep' | 'free' = 'wait'; constructor() { super(); this.rig = createChibi({ color: 0xa9daf7, expression: 'smile', outfit: 'king', accessory: 'crown', size: 1.12 }); this.rig.root.position.y = 0.56; this.view.add(this.rig.root); } set(m: RoofKing['mood']): void { this.mood = m; if (m === 'spell') { this.rig.setExpression('evil'); this.rig.setEmissive(0x8f3cff, 0.25); } if (m === 'asleep') { this.rig.setEmissive(0x000000, 0); this.rig.setExpression('sleepy'); this.rig.play('sleep', { loop: true }); } if (m === 'free') { this.rig.setEmissive(0x000000, 0); this.rig.setExpression('happy'); this.rig.play('victory'); } } render(alpha: number, dt: number): void { super.render(alpha, dt); this.rig.update(dt, { vx: 0, vy: 0, onGround: true, facing: -1 }); } onRemoved(): void { this.rig.dispose(); } } let roof: { king: RoofKing | null; wizard: Entity | null; stage: number; walls: Array<{ enabled?: boolean }>; off: (() => void) | null } = { king: null, wizard: null, stage: 0, walls: [], off: null, }; const W = (text: string) => ({ speaker: 'Hechicero', emoji: '🧙‍♂️', text }); const K = (text: string) => ({ speaker: 'Rey Frío', emoji: '🤴', text }); const Y = (text: string) => ({ speaker: 'Tú', emoji: '🙂', text }); const roofZone: ZoneDef = { id: 'castle-roof', name: 'Azotea del castillo', emoji: '👑', bounds: { minX: 0, maxX: 44, minY: -4, maxY: 20 }, spawns: { default: { x: 4, y: 0 }, 'from-tower': { x: 4, y: 0 } }, env: 'castle', music: 'castle', build(z) { const g = z.game; z.backdrop('castle', { horizon: -2 }); z.ground(0, 44, 0, { style: 'castle' }); // almenas for (let x = 1; x < 44; x += 3.2) z.block(x, 0.5, 1.4, 1, { style: 'castle', zBack: -3.4, zFront: -2.2 }).enabled = false; z.block(-1, 6, 2, 16, { style: 'castle' }); z.block(45, 6, 2, 16, { style: 'castle' }); z.exit(1.6, 1.5, 1.8, 3, 'castle-tower', 'from-roof', { door: true, arrow: 'down' }); z.prop('torch', 8, 0, { z: -1.2 }); z.prop('torch', 36, 0, { z: -1.2 }); z.platform(14, 3.6, 3, { style: 'stone', float: false }); z.platform(30, 3.6, 3, { style: 'stone', float: false }); roof = { king: null, wizard: null, stage: 0, walls: [], off: null }; roof.walls = [g.physics.box(9, 9, 0.6, 18, { material: 'stone', tag: 'arena-wall' })]; for (const w of roof.walls) w.enabled = false; const king = new RoofKing(); g.add(king); king.setPos(33, 0); roof.king = king; if (g.state.has('castle.wizard.defeated')) { king.set('free'); roof.stage = 9; } }, onEnter(game) { roof.off?.(); roof.off = game.events.on('boss:defeated', (e) => { if ((e as { id?: string }).id === 'wizard') void ending(game); }); if (game.state.has('castle.wizard.defeated')) { game.ui.setObjective('¡Has liberado el reino! 🏆'); } }, update(game) { const h = game.hero; if (!h || roof.stage !== 0 || !roof.king) return; if (h.x > 12) { roof.stage = 1; void cutscene(game); } }, onExit(game) { roof.off?.(); roof.off = null; game.ui.bossBar(null); }, }; async function cutscene(game: Game): Promise { const king = roof.king!; for (const w of roof.walls) w.enabled = true; await game.ui.dialog([ K('¡Héroe! ¡Has llegado a la azotea! Has devuelto el tesoro del castillo, moneda a moneda… 👑'), K('Ahora todo el oro y los diamantes del mundo emoji están… a salvo. Aquí. Conmigo. Todo.'), Y('¿Majestad? Sus ojos… brillan de color morado. 😟'), ]); king.set('spell'); game.audio.sfx('teleport', { pitch: 0.6 }); game.vfx.burst('poof', 37, 3, { count: 24, scale: 1.6, color: 0x8f3cff }); const wiz = game.hasType('boss.wizard') ? game.spawn('boss.wizard', 37, 0, { cx: 30 }) : null; roof.wizard = wiz; await game.ui.dialog([ W('¡Jo, jo, jo! Gracias por el recado, pequeño emoji. 🧙‍♂️'), W('No hubo ninguna invasión alienígena: me la inventé yo. Hechicé al Rey para que ordenara recoger cada moneda y cada diamante del reino.'), W('Y tú, tan obediente, has traído TODO el tesoro hasta mi torre. ¡Ahora es MÍO!'), K('(El Rey cae dormido, liberado del hechizo…) 😴'), Y('¡Nos ha engañado a todos! Pues ese tesoro vuelve con su gente. ¡En guardia!'), ]); king.set('asleep'); game.ui.toast('Escudo mágico: rómpelo con COOL 😎 o devolviéndole un orbe de un puñetazo 👊', '🧙‍♂️'); game.after(2.5, () => game.ui.toast('Sus hechizos se paran con bloques de hielo: LLUVIA 🌧️ + HIELO 🥶', '🧊')); (wiz as unknown as { begin?: () => void })?.begin?.(); } async function ending(game: Game): Promise { const st = game.state; st.set('castle.wizard.defeated', true); st.set('game.complete', true); st.save(); for (const w of roof.walls) w.enabled = false; roof.stage = 9; await new Promise((r) => game.after(1.2, () => r(undefined))); roof.king?.set('free'); await game.ui.dialog([ K('¿Eh…? ¿Dónde…? ¡Ah! ¡El hechizo se ha roto! Gracias, valiente héroe. 👑'), K('Ese malvado me usó para robar a todo el reino. Pero tú has devuelto el tesoro… y la libertad.'), K('Desde hoy, cada moneda volverá a su dueño. Y en este castillo siempre tendrás una casa.'), Y('¡Misión cumplida! Ahora… ¿alguien ha dicho fiesta? 🎉'), ]); game.audio.music('victory'); game.vfx.burst('confetti', game.hero?.x ?? 22, (game.hero?.y ?? 0) + 2, { count: 60 }); game.ui.banner('¡FIN!', 'Has liberado el reino emoji. ¡Gracias por jugar!', '🏆'); game.ui.setObjective('¡Has liberado el reino! 🏆'); } export const castleZones: ZoneDef[] = [lavaZone, hallZone, towerZone, roofZone]; export function installCastle(_game: Game): void { // Las piezas del castillo (cofres, puertas, jefes) se registran en world/puzzle.ts, world/hazards.ts y // entities/enemies. Este módulo solo aporta las zonas. void THREE; }