[Balance] Remove candy friendship loss from fainting (#4953)

* Remove candy friendship loss from fainting

* Apply Moka suggestions

Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>

* Fix starterAmount using friendship instead of adjusted amount

---------

Co-authored-by: NightKev <34855794+DayKev@users.noreply.github.com>
Co-authored-by: Moka <54149968+MokaStitcher@users.noreply.github.com>
This commit is contained in:
AJ Fontaine 2024-12-01 11:21:40 -05:00 committed by GitHub
parent cef2f2adf7
commit 9ce4d5eeca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -4271,28 +4271,29 @@ export class PlayerPokemon extends Pokemon {
}); });
} }
addFriendship(friendship: integer): void { addFriendship(friendship: number): void {
const starterSpeciesId = this.species.getRootSpeciesId(); if (friendship > 0) {
const fusionStarterSpeciesId = this.isFusion() && this.fusionSpecies ? this.fusionSpecies.getRootSpeciesId() : 0; const starterSpeciesId = this.species.getRootSpeciesId();
const starterData = [ const fusionStarterSpeciesId = this.isFusion() && this.fusionSpecies ? this.fusionSpecies.getRootSpeciesId() : 0;
this.scene.gameData.starterData[starterSpeciesId], const starterData = [
fusionStarterSpeciesId ? this.scene.gameData.starterData[fusionStarterSpeciesId] : null this.scene.gameData.starterData[starterSpeciesId],
].filter(d => !!d); fusionStarterSpeciesId ? this.scene.gameData.starterData[fusionStarterSpeciesId] : null
const amount = new Utils.IntegerHolder(friendship); ].filter(d => !!d);
let candyFriendshipMultiplier = CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER; const amount = new Utils.NumberHolder(friendship);
if (this.scene.eventManager.isEventActive()) {
candyFriendshipMultiplier *= this.scene.eventManager.getFriendshipMultiplier();
}
const starterAmount = new Utils.IntegerHolder(Math.floor(friendship * (this.scene.gameMode.isClassic && friendship > 0 ? candyFriendshipMultiplier : 1) / (fusionStarterSpeciesId ? 2 : 1)));
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); let candyFriendshipMultiplier = CLASSIC_CANDY_FRIENDSHIP_MULTIPLIER;
if (this.scene.eventManager.isEventActive()) {
candyFriendshipMultiplier *= this.scene.eventManager.getFriendshipMultiplier();
}
const starterAmount = new Utils.NumberHolder(Math.floor(amount.value * (this.scene.gameMode.isClassic ? candyFriendshipMultiplier : 1) / (fusionStarterSpeciesId ? 2 : 1)));
// Add friendship to this PlayerPokemon
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.forEach((sd: StarterDataEntry, i: integer) => { // Add to candy progress for this mon's starter species and its fused species (if it has one)
starterData.forEach((sd: StarterDataEntry, i: number) => {
const speciesId = !i ? starterSpeciesId : fusionStarterSpeciesId as Species; const speciesId = !i ? starterSpeciesId : fusionStarterSpeciesId as Species;
sd.friendship = (sd.friendship || 0) + starterAmount.value; sd.friendship = (sd.friendship || 0) + starterAmount.value;
if (sd.friendship >= getStarterValueFriendshipCap(speciesStarterCosts[speciesId])) { if (sd.friendship >= getStarterValueFriendshipCap(speciesStarterCosts[speciesId])) {
@ -4301,10 +4302,8 @@ export class PlayerPokemon extends Pokemon {
} }
}); });
} else { } else {
this.friendship = Math.max(this.friendship + amount.value, 0); // Lose friendship upon fainting
for (const sd of starterData) { this.friendship = Math.max(this.friendship + friendship, 0);
sd.friendship = Math.max((sd.friendship || 0) + starterAmount.value, 0);
}
} }
} }
/** /**