/* ============ upgrades.js — mejoras permanentes entre runs ============ * Se compran con Pokémonedas en el menú. `per` es lo que da cada nivel. */ G.Upgrades = (() => { const LIST = [ { id: 'hp', icon: 'heart', name: 'Vitalidad', unit: '+8 vida', max: 10, base: 60, grow: 1.35 }, { id: 'atk', icon: 'fist', name: 'Fuerza', unit: '+4% daño', max: 10, base: 80, grow: 1.38 }, { id: 'spd', icon: 'boot', name: 'Zancada', unit: '+3% velocidad', max: 8, base: 70, grow: 1.4 }, { id: 'cd', icon: 'clock', name: 'Reflejos', unit: '-3% recarga', max: 8, base: 90, grow: 1.42 }, { id: 'def', icon: 'shield', name: 'Coraza', unit: '+2% defensa', max: 8, base: 80, grow: 1.4 }, { id: 'regen', icon: 'sprout', name: 'Síntesis', unit: '+0.2 vida/s', max: 5, base: 120, grow: 1.5 }, { id: 'magnet', icon: 'magnet', name: 'Imán', unit: '+12% recogida', max: 6, base: 50, grow: 1.4 }, { id: 'xp', icon: 'book', name: 'Sabiduría', unit: '+5% experiencia', max: 8, base: 100, grow: 1.42 }, { id: 'coins', icon: 'coin', name: 'Fortuna', unit: '+8% Pokémonedas', max: 8, base: 120, grow: 1.45 }, { id: 'moves', icon: 'cards', name: 'Repertorio', unit: 'Empiezas con 2 movimientos', max: 1, base: 1500, grow: 1 }, { id: 'crit', icon: 'star', name: 'Golpe Crítico', unit: '+3% de críticos (x1,5 de daño)', max: 10, base: 90, grow: 1.4 }, { id: 'reroll', icon: 'up', name: 'Cambio de cartas', unit: '+1 cambio de cartas de nivel por run', max: 5, base: 150, grow: 1.6 }, { id: 'ban', icon: 'ban', name: 'Veto', unit: 'Bloquea 1 movimiento: no te sale en las cartas', max: 3, base: 300, grow: 1.9 } ]; const BY = {}; for (const u of LIST) BY[u.id] = u; function cost(id, lvl) { const u = BY[id]; return Math.round(u.base * Math.pow(u.grow, lvl) / 10) * 10; } /** Niveles comprados -> modificadores para G.Player. */ function perks(levels = {}) { // Nunca por encima del máximo (una partida editada a mano no da más poder). const L = id => Math.max(0, Math.min(BY[id].max, Math.floor(+levels[id] || 0))); return { hp: L('hp') * 8, atkMul: 1 + L('atk') * 0.04, spdMul: 1 + L('spd') * 0.03, cdMul: 1 - L('cd') * 0.03, dmgReduce: L('def') * 0.02, regen: L('regen') * 0.2, magnetMul: 1 + L('magnet') * 0.12, xpMul: 1 + L('xp') * 0.05, coinMul: 1 + L('coins') * 0.08, startMoves: 1 + L('moves'), crit: L('crit') * 0.03, rerolls: L('reroll'), bans: L('ban') }; } return { LIST, BY, cost, perks }; })();