Starter friendship for candies is split between spliced species
This commit is contained in:
parent
67431fb83b
commit
b30ab6136e
|
@ -37,7 +37,7 @@ import PartyUiHandler, { PartyOption, PartyUiMode } from '../ui/party-ui-handler
|
||||||
import SoundFade from 'phaser3-rex-plugins/plugins/soundfade';
|
import SoundFade from 'phaser3-rex-plugins/plugins/soundfade';
|
||||||
import { LevelMoves } from '../data/pokemon-level-moves';
|
import { LevelMoves } from '../data/pokemon-level-moves';
|
||||||
import { DamageAchv, achvs } from '../system/achv';
|
import { DamageAchv, achvs } from '../system/achv';
|
||||||
import { DexAttr, StarterMoveset } from '../system/game-data';
|
import { DexAttr, StarterDataEntry, StarterMoveset } from '../system/game-data';
|
||||||
import { QuantizerCelebi, argbFromRgba, rgbaFromArgb } from '@material/material-color-utilities';
|
import { QuantizerCelebi, argbFromRgba, rgbaFromArgb } from '@material/material-color-utilities';
|
||||||
import { Nature, getNatureStatMultiplier } from '../data/nature';
|
import { Nature, getNatureStatMultiplier } from '../data/nature';
|
||||||
import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from '../data/pokemon-forms';
|
import { SpeciesFormChange, SpeciesFormChangeActiveTrigger, SpeciesFormChangeMoveLearnedTrigger, SpeciesFormChangePostMoveTrigger, SpeciesFormChangeStatusEffectTrigger } from '../data/pokemon-forms';
|
||||||
|
@ -2370,9 +2370,13 @@ export class PlayerPokemon extends Pokemon {
|
||||||
|
|
||||||
addFriendship(friendship: integer): void {
|
addFriendship(friendship: integer): void {
|
||||||
const starterSpeciesId = this.species.getRootSpeciesId();
|
const starterSpeciesId = this.species.getRootSpeciesId();
|
||||||
const starterData = this.scene.gameData.starterData[starterSpeciesId];
|
const fusionStarterSpeciesId = this.isFusion() ? this.fusionSpecies.getRootSpeciesId() : 0;
|
||||||
|
const starterData = [
|
||||||
|
this.scene.gameData.starterData[starterSpeciesId],
|
||||||
|
fusionStarterSpeciesId ? this.scene.gameData.starterData[fusionStarterSpeciesId] : null
|
||||||
|
].filter(d => d);
|
||||||
const amount = new Utils.IntegerHolder(friendship);
|
const amount = new Utils.IntegerHolder(friendship);
|
||||||
const starterAmount = new Utils.IntegerHolder(friendship * (this.scene.gameMode.isClassic ? 2 : 1));
|
const starterAmount = new Utils.IntegerHolder(Math.floor(friendship * (this.scene.gameMode.isClassic ? 2 : 1) / (fusionStarterSpeciesId ? 2 : 1)));
|
||||||
if (amount.value > 0) {
|
if (amount.value > 0) {
|
||||||
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, amount);
|
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, amount);
|
||||||
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, starterAmount);
|
this.scene.applyModifier(PokemonFriendshipBoosterModifier, true, this, starterAmount);
|
||||||
|
@ -2380,14 +2384,18 @@ export class PlayerPokemon extends Pokemon {
|
||||||
this.friendship = Math.min(this.friendship + amount.value, 255);
|
this.friendship = Math.min(this.friendship + amount.value, 255);
|
||||||
if (this.friendship === 255)
|
if (this.friendship === 255)
|
||||||
this.scene.validateAchv(achvs.MAX_FRIENDSHIP);
|
this.scene.validateAchv(achvs.MAX_FRIENDSHIP);
|
||||||
starterData.friendship = (starterData.friendship || 0) + starterAmount.value;
|
starterData.forEach((sd: StarterDataEntry, i: integer) => {
|
||||||
if (starterData.friendship >= getStarterValueFriendshipCap(speciesStarters[starterSpeciesId])) {
|
const speciesId = !i ? starterSpeciesId : fusionStarterSpeciesId as Species;
|
||||||
this.scene.gameData.addStarterCandy(getPokemonSpecies(starterSpeciesId), 1);
|
sd.friendship = (sd.friendship || 0) + starterAmount.value;
|
||||||
starterData.friendship = 0;
|
if (sd.friendship >= getStarterValueFriendshipCap(speciesStarters[speciesId])) {
|
||||||
}
|
this.scene.gameData.addStarterCandy(getPokemonSpecies(speciesId), 1);
|
||||||
|
sd.friendship = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
this.friendship = Math.max(this.friendship + amount.value, 0);
|
this.friendship = Math.max(this.friendship + amount.value, 0);
|
||||||
starterData.friendship = Math.max((starterData.friendship || 0) + starterAmount.value, 0);
|
for (let sd of starterData)
|
||||||
|
sd.friendship = Math.max((sd.friendship || 0) + starterAmount.value, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue