From 1236cb948dcc53e0d142d654c2b53052948806ec Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Wed, 8 Nov 2023 22:30:22 -0500 Subject: [PATCH] Add shared movesets for spliced Pokemon --- src/data/move.ts | 4 ++-- src/data/pokemon-species.ts | 4 ++-- src/pokemon.ts | 32 +++++++++++++++++++++++++------- src/ui/party-ui-handler.ts | 6 ++++++ 4 files changed, 35 insertions(+), 11 deletions(-) diff --git a/src/data/move.ts b/src/data/move.ts index 0ec2af072..5ad9466bf 100644 --- a/src/data/move.ts +++ b/src/data/move.ts @@ -3476,10 +3476,10 @@ export function initMoves() { new AttackMove(Moves.STORED_POWER, "Stored Power (N)", Type.PSYCHIC, MoveCategory.SPECIAL, 20, 100, 10, 41, "Power increases when user's stats have been raised.", -1, 0, 5), new SelfStatusMove(Moves.QUICK_GUARD, "Quick Guard (N)", Type.FIGHTING, -1, 15, -1, "Protects the user's team from high-priority moves.", -1, 3, 5) .target(MoveTarget.USER_SIDE), - new StatusMove(Moves.ALLY_SWITCH, "Ally Switch (N)", Type.PSYCHIC, -1, 15, -1, "User switches with opposite teammate.", -1, 0, 5) + new StatusMove(Moves.ALLY_SWITCH, "Ally Switch (N)", Type.PSYCHIC, -1, 15, -1, "User switches with opposite teammate.", -1, 2, 5) .ignoresProtect() .target(MoveTarget.USER), // TODO - new AttackMove(Moves.SCALD, "Scald", Type.WATER, MoveCategory.SPECIAL, 80, 100, 15, -1, "May burn opponent.", 30, 1, 5) + new AttackMove(Moves.SCALD, "Scald", Type.WATER, MoveCategory.SPECIAL, 80, 100, 15, -1, "May burn opponent.", 30, 0, 5) .attr(StatusEffectAttr, StatusEffect.BURN), new SelfStatusMove(Moves.SHELL_SMASH, "Shell Smash", Type.NORMAL, -1, 15, -1, "Sharply raises user's Attack, Special Attack and Speed but lowers Defense and Special Defense.", -1, 0, 5) .attr(StatChangeAttr, [ BattleStat.ATK, BattleStat.SPATK ], 2, true) diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 33f259004..43c345f59 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -77,8 +77,8 @@ export abstract class PokemonSpeciesForm { getLevelMoves(): LevelMoves { if (pokemonSpeciesFormLevelMoves.hasOwnProperty(this.speciesId) && pokemonSpeciesFormLevelMoves[this.speciesId].hasOwnProperty(this.formIndex)) - return pokemonSpeciesFormLevelMoves[this.speciesId][this.formIndex]; - return pokemonSpeciesLevelMoves[this.speciesId]; + return pokemonSpeciesFormLevelMoves[this.speciesId][this.formIndex].slice(0); + return pokemonSpeciesLevelMoves[this.speciesId].slice(0); } isObtainable() { diff --git a/src/pokemon.ts b/src/pokemon.ts index 0803b53de..7587ab748 100644 --- a/src/pokemon.ts +++ b/src/pokemon.ts @@ -29,7 +29,7 @@ import { Mode } from './ui/ui'; import PartyUiHandler, { PartyOption, PartyUiMode } from './ui/party-ui-handler'; import SoundFade from 'phaser3-rex-plugins/plugins/soundfade'; import { GameMode } from './game-mode'; -import { pokemonFormLevelMoves } from './data/pokemon-level-moves'; +import { LevelMoves, pokemonFormLevelMoves } from './data/pokemon-level-moves'; export enum FieldPosition { CENTER, @@ -539,10 +539,27 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { getLevelMoves(startingLevel?: integer): Moves[] { const ret: Moves[] = []; - const levelMoves = this.getSpeciesForm().getLevelMoves(); - if (levelMoves) { - if (!startingLevel) + let levelMoves = this.getSpeciesForm().getLevelMoves(); + if (!startingLevel) startingLevel = this.level; + if (this.fusionSpecies) { + const fusionLevelMoves = this.getFusionSpeciesForm().getLevelMoves(); + const newLevelMoves: LevelMoves = []; + for (let l = startingLevel; l <= this.level; l++) { + while (levelMoves.length && levelMoves[0][0] === l) { + const levelMove = levelMoves.shift(); + if (!newLevelMoves.find(lm => lm[1] === levelMove[1])) + newLevelMoves.push(levelMove); + } + while (fusionLevelMoves.length && fusionLevelMoves[0][0] === l) { + const fusionLevelMove = fusionLevelMoves.shift(); + if (!newLevelMoves.find(lm => lm[1] === fusionLevelMove[1])) + newLevelMoves.push(fusionLevelMove); + } + } + levelMoves = newLevelMoves; + } + if (levelMoves) { for (let lm of levelMoves) { const level = lm[0]; if (level < startingLevel) @@ -1160,7 +1177,6 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { // Failsafe this.scene.time.delayedCall(Utils.fixedInt(3000), () => { - console.log(faintCryTimer) if (!faintCryTimer || !this.scene) return; if (cry?.isPlaying) @@ -1357,11 +1373,11 @@ export class PlayerPokemon extends Pokemon { const moveId = parseInt(tm) as Moves; for (let p of tmSpecies[tm]) { if (Array.isArray(p)) { - if (p[0] === this.species.speciesId) { + if (p[0] === this.species.speciesId || (this.fusionSpecies && p[0] === this.fusionSpecies.speciesId)) { this.compatibleTms.push(moveId); break; } - } else if (p === this.species.speciesId) { + } else if (p === this.species.speciesId || (this.fusionSpecies && p === this.fusionSpecies.speciesId)) { this.compatibleTms.push(moveId); break; } @@ -1440,6 +1456,7 @@ export class PlayerPokemon extends Pokemon { } this.calculateStats(); + this.generateCompatibleTms(); this.updateInfo(true).then(() => { const fusedPartyMemberIndex = this.scene.getParty().indexOf(pokemon); const fusedPartyMemberHeldModifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier @@ -1466,6 +1483,7 @@ export class PlayerPokemon extends Pokemon { this.fusionGender = 0; this.calculateStats(); + this.generateCompatibleTms(); this.updateInfo(true).then(() => resolve()); }); } diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index 729cebc29..33ac429fc 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -566,6 +566,7 @@ export default class PartyUiHandler extends MessageUiHandler { for (let o = optionStartIndex; o < optionEndIndex; o++) { const option = this.options[this.options.length - (o + 1)]; + let altText = false; let optionName: string; if ((this.partyUiMode !== PartyUiMode.REMEMBER_MOVE_MODIFIER && (this.partyUiMode !== PartyUiMode.MODIFIER_TRANSFER || this.transferMode)) || option === PartyOption.CANCEL) { switch (option) { @@ -586,6 +587,7 @@ export default class PartyUiHandler extends MessageUiHandler { else if (this.partyUiMode === PartyUiMode.REMEMBER_MOVE_MODIFIER) { const move = learnableLevelMoves[option]; optionName = allMoves[move].name; + altText = !!pokemon.getSpeciesForm().getLevelMoves().find(plm => plm[1] === move); } else { const itemModifier = itemModifiers[option]; optionName = itemModifier.type.name; @@ -595,6 +597,10 @@ export default class PartyUiHandler extends MessageUiHandler { const yCoord = -6 - 16 * o; const optionText = addTextObject(this.scene, -79 - (wideOptions ? 50 : 0), yCoord - 16, optionName, TextStyle.WINDOW); + if (altText) { + optionText.setColor('#40c8f8'); + optionText.setShadowColor('#006090') + } optionText.setOrigin(0, 0); this.optionsContainer.add(optionText);