From b58dc659b2bf495e458b74669fa1e165c38f4141 Mon Sep 17 00:00:00 2001 From: Elvis Wei Date: Sun, 5 Jan 2025 16:01:13 -0600 Subject: [PATCH] maxie groudon --- changelog.md | 2 + src/battle/data/abilities.js | 35 ++++++++++ src/battle/data/effects.js | 6 +- src/battle/data/moves.js | 120 ++++++++++++++++++++++++++++++++++- src/config/pokemonConfig.js | 20 ++++++ src/enums/battleEnums.js | 3 + src/enums/pokemonEnums.js | 1 + 7 files changed, 181 insertions(+), 6 deletions(-) diff --git a/changelog.md b/changelog.md index ca8beea..77d80a0 100644 --- a/changelog.md +++ b/changelog.md @@ -17,6 +17,8 @@ TODO: - Maybe revamp shop for this - New player UX analysis - Make party add/remove easier +- Fix help again +- Attempt to fix memory leak **Stretch** diff --git a/src/battle/data/abilities.js b/src/battle/data/abilities.js index ff6706b..49bf032 100644 --- a/src/battle/data/abilities.js +++ b/src/battle/data/abilities.js @@ -96,6 +96,41 @@ const abilitiesToRegister = Object.freeze({ battle.unregisterListener(properties.listenerId); }, }), + [abilityIdEnum.MAGMA_POWER]: new Ability({ + id: abilityIdEnum.MAGMA_POWER, + name: "Magma Power", + description: + "At the start of battle, if there's only one other Ground or Fire type ally, increase its combat readiness by 35%, and start harsh sunlight.", + abilityAdd({ battle, target }) { + return { + listenerId: battle.registerListenerFunction({ + eventName: battleEventEnum.BATTLE_BEGIN, + callback: () => { + const allyPokemons = target.getPartyPokemon(); + const otherFireGroundAllies = allyPokemons.filter( + (pokemon) => + pokemon !== target && + pokemon && + !pokemon.isFainted && + (pokemon.hasType(pokemonTypes.FIRE) || + pokemon.hasType(pokemonTypes.GROUND)) + ); + if (otherFireGroundAllies.length !== 1) { + return; + } + const [allyPokemon] = otherFireGroundAllies; + battle.addToLog(`${target.name} blesses ${allyPokemon.name}!`); + allyPokemon.boostCombatReadiness(target, 35); + + battle.createWeather(weatherConditions.SUN, target); + }, + }), + }; + }, + abilityRemove({ battle, properties }) { + battle.unregisterListener(properties.listenerId); + }, + }), [abilityIdEnum.REGENERATOR]: new Ability({ id: abilityIdEnum.REGENERATOR, name: "Regenerator", diff --git a/src/battle/data/effects.js b/src/battle/data/effects.js index a52264b..7276ab8 100644 --- a/src/battle/data/effects.js +++ b/src/battle/data/effects.js @@ -133,7 +133,7 @@ const effectsToRegister = Object.freeze({ [effectIdEnum.AQUA_BLESSING]: new Effect({ id: effectIdEnum.AQUA_BLESSING, name: "Aqua Blessing", - description: "The target's stat is increased by 1.5x.", + description: "The target's stat is increased by 2x.", type: effectTypes.BUFF, dispellable: true, /** @@ -145,7 +145,7 @@ const effectsToRegister = Object.freeze({ const statToIncrease = statToBattleStat[stat]; battle.addToLog(`${target.name}'s ${statToIncrease} rose!`); - target[statToIncrease] += Math.floor(baseStatValue * 0.5); + target[statToIncrease] += baseStatValue; return {}; }, effectRemove({ battle, target, initialArgs }) { @@ -154,7 +154,7 @@ const effectsToRegister = Object.freeze({ const statToIncrease = statToBattleStat[stat]; battle.addToLog(`${target.name}'s ${statToIncrease} boost wore off!`); - target[statToIncrease] -= Math.floor(baseStatValue * 0.5); + target[statToIncrease] -= baseStatValue; }, }), }); diff --git a/src/battle/data/moves.js b/src/battle/data/moves.js index 761f891..17a9e49 100644 --- a/src/battle/data/moves.js +++ b/src/battle/data/moves.js @@ -5,6 +5,7 @@ const { targetPatterns, damageTypes, moveTiers, + statusConditions, } = require("../../config/battleConfig"); const { getMove } = require("./moveRegistry"); const { moveIdEnum } = require("../../enums/battleEnums"); @@ -67,9 +68,9 @@ class Move { offTargetDamageMultiplier = 0.8, calculateDamageFunction = undefined, }) { - const damageToDeal = ( - calculateDamageFunction || source.calculateMoveDamage - )({ + const damageFunc = + calculateDamageFunction || ((args) => source.calculateMoveDamage(args)); + const damageToDeal = damageFunc({ move: getMove(this.id), target, primaryTarget, @@ -112,9 +113,91 @@ class Move { }); } } + + // eslint-disable-next-line class-methods-use-this + genericApplySingleStatus({ + source, + target, + // eslint-disable-next-line no-unused-vars + primaryTarget, + // eslint-disable-next-line no-unused-vars + allTargets, + missedTargets = [], + statusId, + options, + probablity = 1, + }) { + if (!missedTargets.includes(target) && Math.random() < probablity) { + return target.applyStatus(statusId, source, options); + } + return false; + } + + /** + * @param {object} param0 + * @param {BattlePokemon} param0.source + * @param {BattlePokemon} param0.primaryTarget + * @param {Array} param0.allTargets + * @param {Array=} param0.missedTargets + * @param {StatusConditionEnum} param0.statusId + * @param {object=} param0.options + * @param {number=} param0.probablity + */ + genericApplyAllStatus({ + source, + primaryTarget, + allTargets, + missedTargets = [], + statusId, + options, + probablity = 1, + }) { + for (const target of allTargets) { + this.genericApplySingleStatus({ + source, + target, + primaryTarget, + allTargets, + missedTargets, + statusId, + options, + probablity, + }); + } + } } const movesToRegister = Object.freeze({ + [moveIdEnum.FIRE_PUNCH]: new Move({ + id: moveIdEnum.FIRE_PUNCH, + name: "Fire Punch", + type: pokemonTypes.FIRE, + power: 75, + accuracy: 100, + cooldown: 2, + targetType: targetTypes.ENEMY, + targetPosition: targetPositions.FRONT, + targetPattern: targetPatterns.SINGLE, + tier: moveTiers.POWER, + damageType: damageTypes.PHYSICAL, + description: + "The target is punched with a fiery fist. It may also leave the target with a burn with a 50% chance.", + execute({ source, primaryTarget, allTargets, missedTargets }) { + this.genericDealAllDamage({ + source, + primaryTarget, + allTargets, + missedTargets, + }); + this.genericApplyAllStatus({ + source, + primaryTarget, + allTargets, + statusId: statusConditions.BURN, + probablity: 0.5, + }); + }, + }), [moveIdEnum.VINE_WHIP]: new Move({ id: moveIdEnum.VINE_WHIP, name: "Vine Whip", @@ -193,6 +276,37 @@ const movesToRegister = Object.freeze({ }); }, }), + [moveIdEnum.MAGMA_IMPACT]: new Move({ + id: moveIdEnum.MAGMA_IMPACT, + name: "Magma Impact", + type: pokemonTypes.FIRE, + power: 45, + accuracy: 90, + cooldown: 5, + targetType: targetTypes.ENEMY, + targetPosition: targetPositions.FRONT, + targetPattern: targetPatterns.ALL, + tier: moveTiers.ULTIMATE, + damageType: damageTypes.PHYSICAL, + description: + "The targets are struck with blades of magma. If hit and the target is not a full HP, deals 1.5x damage.", + execute({ source, primaryTarget, allTargets, missedTargets }) { + this.genericDealAllDamage({ + source, + primaryTarget, + allTargets, + missedTargets, + calculateDamageFunction: (args) => { + const { target } = args; + const baseDamage = source.calculateMoveDamage(args); + if (!missedTargets.includes(target) && target.hp < target.maxHp) { + return Math.floor(baseDamage * 1.5); + } + return baseDamage; + }, + }); + }, + }), }); module.exports = { diff --git a/src/config/pokemonConfig.js b/src/config/pokemonConfig.js index bf3cf98..33f4fbb 100644 --- a/src/config/pokemonConfig.js +++ b/src/config/pokemonConfig.js @@ -7172,6 +7172,26 @@ const pokemonConfigRaw = { rarity: rarities.LEGENDARY, growthRate: growthRates.SLOW, }, + [pokemonIdEnum.MAXIES_GROUDON]: { + name: "Maxie's Groudon", + emoji: "<:magmagroudon:1325287156268404878>", + description: + "A Groudon under the control of Maxie, the leader of Team Magma. It uses its power to expand the land.", + type: [types.GROUND, types.FIRE], + baseStats: [99, 166, 130, 90, 90, 85], + sprite: + "https://raw.githubusercontent.com/ewei068/pokestar/main/media/images/sprites/magma-groudon-resized.gif", + shinySprite: + "https://raw.githubusercontent.com/ewei068/pokestar/main/media/images/sprites/magma-groudon-shiny-resized.gif", + abilities: { + [abilityIdEnum.MAGMA_POWER]: 1, + }, + moveIds: ["m479", "m14", "m523", moveIdEnum.MAGMA_IMPACT], + battleEligible: true, + rarity: rarities.LEGENDARY, + growthRate: growthRates.SLOW, + noGacha: true, + }, 384: { name: "Rayquaza", emoji: "<:384:1132497391535272016>", diff --git a/src/enums/battleEnums.js b/src/enums/battleEnums.js index a05815f..90c6a53 100644 --- a/src/enums/battleEnums.js +++ b/src/enums/battleEnums.js @@ -19,8 +19,10 @@ const effectIdEnum = Object.freeze({ const moveIdEnum = Object.freeze({ TEST_MOVE: "999", TEST_MOVE2: "998", + FIRE_PUNCH: "m7", VINE_WHIP: "m22", AQUA_IMPACT: "m618-1", + MAGMA_IMPACT: "m619-1", }); /** @@ -32,6 +34,7 @@ const abilityIdEnum = Object.freeze({ TEST_ABILITY: "testAbility", REGENERATOR: "144", AQUA_POWER: "2-1", + MAGMA_POWER: "70-1", }); /** @typedef {Enum} BattleEventEnum */ diff --git a/src/enums/pokemonEnums.js b/src/enums/pokemonEnums.js index 6fb08a1..809727d 100644 --- a/src/enums/pokemonEnums.js +++ b/src/enums/pokemonEnums.js @@ -308,6 +308,7 @@ const pokemonIdEnum = Object.freeze({ PALMERS_RAYQUAZA: "20384", WILLOWS_MELMETAL: "20809", ARCHIES_KYOGRE: "382-1", + MAXIES_GROUDON: "383-1", }); module.exports = { pokemonIdEnum };