From 6b9542511fc934bafadc4a75c55f0b44bbf8effa Mon Sep 17 00:00:00 2001 From: Flashfyre Date: Fri, 26 Apr 2024 18:27:00 -0400 Subject: [PATCH] Add fusion luck as a separate field --- src/field/pokemon.ts | 12 +++++++++++- src/modifier/modifier-type.ts | 2 +- src/system/pokemon-data.ts | 4 +++- src/ui/summary-ui-handler.ts | 6 +++--- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/src/field/pokemon.ts b/src/field/pokemon.ts index 89cfa8fac45..7408b86deca 100644 --- a/src/field/pokemon.ts +++ b/src/field/pokemon.ts @@ -85,6 +85,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { public fusionShiny: boolean; public fusionVariant: Variant; public fusionGender: Gender; + public fusionLuck: integer; private summonDataPrimer: PokemonSummonData; @@ -153,6 +154,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.fusionShiny = dataSource.fusionShiny; this.fusionVariant = dataSource.fusionVariant || 0; this.fusionGender = dataSource.fusionGender; + this.fusionLuck = dataSource.fusionLuck; } else { this.id = Utils.randSeedInt(4294967296); this.ivs = ivs || Utils.getIvsFromId(this.id); @@ -192,7 +194,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } } - this.luck = this.isShiny() ? this.variant + this.fusionVariant : 0; + this.luck = (this.shiny ? (this.variant + 1) : 0) + (this.fusionShiny ? this.fusionVariant + 1 : 0); } this.generateName(); @@ -690,6 +692,10 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { return !this.isFusion() ? this.variant : Math.max(this.variant, this.fusionVariant) as Variant; } + getLuck(): integer { + return this.luck + this.fusionLuck; + } + isFusion(): boolean { return !!this.fusionSpecies; } @@ -1052,6 +1058,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { } this.fusionFormIndex = this.scene.getSpeciesFormIndex(this.fusionSpecies, this.fusionGender, this.getNature(), true); + this.fusionLuck = this.luck; this.generateName(); } @@ -1062,6 +1069,7 @@ export default abstract class Pokemon extends Phaser.GameObjects.Container { this.fusionAbilityIndex = 0; this.fusionShiny = false; this.fusionGender = 0; + this.fusionLuck = 0; this.generateName(); this.calculateStats(); @@ -2418,6 +2426,7 @@ export class PlayerPokemon extends Pokemon { newPokemon.fusionShiny = this.fusionShiny; newPokemon.fusionVariant = this.fusionVariant; newPokemon.fusionGender = this.fusionGender; + newPokemon.fusionLuck = this.fusionLuck; this.scene.getParty().push(newPokemon); newPokemon.evolve(newEvolution); const modifiers = this.scene.findModifiers(m => m instanceof PokemonHeldItemModifier @@ -2477,6 +2486,7 @@ export class PlayerPokemon extends Pokemon { this.fusionShiny = pokemon.shiny; this.fusionVariant = pokemon.fusionVariant; this.fusionGender = pokemon.gender; + this.fusionLuck = pokemon.luck; this.scene.validateAchv(achvs.SPLICE); this.scene.gameData.gameStats.pokemonFused++; diff --git a/src/modifier/modifier-type.ts b/src/modifier/modifier-type.ts index a4b369d409a..6237e8b5a50 100644 --- a/src/modifier/modifier-type.ts +++ b/src/modifier/modifier-type.ts @@ -1518,7 +1518,7 @@ export class ModifierTypeOption { } export function getPartyLuckValue(party: Pokemon[]): integer { - return Phaser.Math.Clamp(party.map(p => p.isFainted() ? 0 : p.luck) + return Phaser.Math.Clamp(party.map(p => p.isFainted() ? 0 : p.getLuck()) .reduce((total: integer, value: integer) => total += value, 0), 0, 14); } diff --git a/src/system/pokemon-data.ts b/src/system/pokemon-data.ts index 2fc4cac2b55..b9589020e9b 100644 --- a/src/system/pokemon-data.ts +++ b/src/system/pokemon-data.ts @@ -46,6 +46,7 @@ export default class PokemonData { public fusionShiny: boolean; public fusionVariant: Variant; public fusionGender: Gender; + public fusionLuck: integer; public boss: boolean; @@ -76,7 +77,7 @@ export default class PokemonData { this.friendship = source.friendship !== undefined ? source.friendship : getPokemonSpecies(this.species).baseFriendship; this.metLevel = source.metLevel || 5; this.metBiome = source.metBiome !== undefined ? source.metBiome : -1; - this.luck = source.luck !== undefined ? source.luck : (source.shiny ? (source.variant + 1) : 0) + (source.fusionShiny ? source.fusionVariant + 1 : 0); + this.luck = source.luck !== undefined ? source.luck : (source.shiny ? (source.variant + 1) : 0); if (!forHistory) this.pauseEvolutions = !!source.pauseEvolutions; this.pokerus = !!source.pokerus; @@ -87,6 +88,7 @@ export default class PokemonData { this.fusionShiny = source.fusionShiny; this.fusionVariant = source.fusionVariant; this.fusionGender = source.fusionGender; + this.fusionLuck = source.fusionLuck !== undefined ? source.fusionLuck : (source.fusionShiny ? source.fusionVariant + 1 : 0); if (!forHistory) this.boss = (source instanceof EnemyPokemon && !!source.bossSegments) || (!this.player && !!source.boss); diff --git a/src/ui/summary-ui-handler.ts b/src/ui/summary-ui-handler.ts index c06b16df430..bf5a12b3f7d 100644 --- a/src/ui/summary-ui-handler.ts +++ b/src/ui/summary-ui-handler.ts @@ -604,14 +604,14 @@ export default class SummaryUiHandler extends UiHandler { if (this.pokemon.isTerastallized()) profileContainer.add(getTypeIcon(types.length, this.pokemon.getTeraType(), true)); - if (this.pokemon.luck) { + if (this.pokemon.getLuck()) { const luckLabelText = addTextObject(this.scene, 141, 28, 'Luck:', TextStyle.SUMMARY_ALT); luckLabelText.setOrigin(0, 0); profileContainer.add(luckLabelText); - const luckText = addTextObject(this.scene, 141 + luckLabelText.displayWidth + 2, 28, this.pokemon.luck.toString(), TextStyle.SUMMARY); + const luckText = addTextObject(this.scene, 141 + luckLabelText.displayWidth + 2, 28, this.pokemon.getLuck().toString(), TextStyle.SUMMARY); luckText.setOrigin(0, 0); - luckText.setTint(getVariantTint((Math.min(this.pokemon.luck - 1, 2)) as Variant)); + luckText.setTint(getVariantTint((Math.min(this.pokemon.getLuck() - 1, 2)) as Variant)); profileContainer.add(luckText); }