mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
correctly cap rare candy friendship gain
This commit is contained in:
parent
e25db16326
commit
49d3317359
@ -5672,7 +5672,7 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
* For fusions, candy progress for each species in the fusion is halved.
|
* For fusions, candy progress for each species in the fusion is halved.
|
||||||
*
|
*
|
||||||
* @param friendship - The amount of friendship to add. Negative values will reduce friendship, though not below 0.
|
* @param friendship - The amount of friendship to add. Negative values will reduce friendship, though not below 0.
|
||||||
* @param capped - If true, don't allow the friendship gain to exceed 200. Used to cap friendship gains from rare candies.
|
* @param capped - If true, don't allow the friendship gain to exceed {@linkcode RARE_CANDY_FRIENDSHIP_CAP}. Used to cap friendship gains from rare candies.
|
||||||
*/
|
*/
|
||||||
addFriendship(friendship: number, capped = false): void {
|
addFriendship(friendship: number, capped = false): void {
|
||||||
// Short-circuit friendship loss, which doesn't impact candy friendship
|
// Short-circuit friendship loss, which doesn't impact candy friendship
|
||||||
@ -5693,14 +5693,17 @@ export class PlayerPokemon extends Pokemon {
|
|||||||
friendship = amount.value;
|
friendship = amount.value;
|
||||||
|
|
||||||
const newFriendship = this.friendship + friendship;
|
const newFriendship = this.friendship + friendship;
|
||||||
// If capped is true, only adjust friendship if the new friendship is less than or equal to 200.
|
/** If capped is true, don't allow friendship gain to exceed {@linkcode RARE_CANDY_FRIENDSHIP_CAP} */
|
||||||
if (!capped || newFriendship <= RARE_CANDY_FRIENDSHIP_CAP) {
|
const finalFriendship =
|
||||||
this.friendship = Math.min(newFriendship, 255);
|
capped && newFriendship > RARE_CANDY_FRIENDSHIP_CAP
|
||||||
|
? Math.max(RARE_CANDY_FRIENDSHIP_CAP, this.friendship)
|
||||||
|
: this.friendship + friendship;
|
||||||
|
|
||||||
|
this.friendship = Math.min(finalFriendship, 255);
|
||||||
if (newFriendship >= 255) {
|
if (newFriendship >= 255) {
|
||||||
globalScene.validateAchv(achvs.MAX_FRIENDSHIP);
|
globalScene.validateAchv(achvs.MAX_FRIENDSHIP);
|
||||||
awardRibbonsToSpeciesLine(this.species.speciesId, RibbonData.FRIENDSHIP);
|
awardRibbonsToSpeciesLine(this.species.speciesId, RibbonData.FRIENDSHIP);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let candyFriendshipMultiplier = globalScene.gameMode.isClassic
|
let candyFriendshipMultiplier = globalScene.gameMode.isClassic
|
||||||
? timedEventManager.getClassicFriendshipMultiplier()
|
? timedEventManager.getClassicFriendshipMultiplier()
|
||||||
|
Loading…
Reference in New Issue
Block a user