Add Leppa Berry

pull/16/head
Flashfyre 2024-03-19 23:14:06 -04:00
parent 255177857f
commit 921851c1b6
6 changed files with 2399 additions and 2361 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 44 KiB

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 287 B

View File

@ -18,7 +18,8 @@ export enum BerryType {
APICOT, APICOT,
SALAC, SALAC,
LANSAT, LANSAT,
STARF STARF,
LEPPA
} }
export function getBerryName(berryType: BerryType) { export function getBerryName(berryType: BerryType) {
@ -44,6 +45,8 @@ export function getBerryEffectDescription(berryType: BerryType) {
return 'Raises critical hit ratio if HP is below 25%'; return 'Raises critical hit ratio if HP is below 25%';
case BerryType.STARF: case BerryType.STARF:
return 'Sharply raises a random stat if HP is below 25%'; return 'Sharply raises a random stat if HP is below 25%';
case BerryType.LEPPA:
return 'Restores 10 PP to a move if its PP reaches 0';
} }
} }
@ -73,13 +76,19 @@ export function getBerryPredicate(berryType: BerryType): BerryPredicate {
const threshold = new Utils.NumberHolder(0.25); const threshold = new Utils.NumberHolder(0.25);
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold); applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold);
return pokemon.getHpRatio() < 0.25 && !pokemon.getTag(BattlerTagType.CRIT_BOOST); return pokemon.getHpRatio() < 0.25 && !pokemon.getTag(BattlerTagType.CRIT_BOOST);
} };
case BerryType.STARF: case BerryType.STARF:
return (pokemon: Pokemon) => { return (pokemon: Pokemon) => {
const threshold = new Utils.NumberHolder(0.25); const threshold = new Utils.NumberHolder(0.25);
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold); applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold);
return pokemon.getHpRatio() < 0.25; return pokemon.getHpRatio() < 0.25;
} };
case BerryType.LEPPA:
return (pokemon: Pokemon) => {
const threshold = new Utils.NumberHolder(0.25);
applyAbAttrs(ReduceBerryUseThresholdAbAttr, pokemon, null, threshold);
return !!pokemon.getMoveset().find(m => !m.getPpRatio());
};
} }
} }
@ -123,7 +132,13 @@ export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
return (pokemon: Pokemon) => { return (pokemon: Pokemon) => {
const statLevels = new Utils.NumberHolder(2); const statLevels = new Utils.NumberHolder(2);
applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, statLevels); applyAbAttrs(DoubleBerryEffectAbAttr, pokemon, null, statLevels);
return pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ BattleStat.RAND ], statLevels.value)); pokemon.scene.unshiftPhase(new StatChangePhase(pokemon.scene, pokemon.getBattlerIndex(), true, [ BattleStat.RAND ], statLevels.value));
};
case BerryType.LEPPA:
return (pokemon: Pokemon) => {
const ppRestoreMove = pokemon.getMoveset().find(m => !m.getPpRatio());
ppRestoreMove.ppUsed = Math.max(ppRestoreMove.ppUsed - 10, 0);
pokemon.scene.queueMessage(getPokemonMessage(pokemon, ` restored PP to its move ${ppRestoreMove.getName()}\nusing its ${getBerryName(berryType)}!`));
}; };
} }
} }

View File

@ -788,13 +788,15 @@ export const modifierTypes = {
return new BerryModifierType(pregenArgs[0] as BerryType); return new BerryModifierType(pregenArgs[0] as BerryType);
const berryTypes = Utils.getEnumValues(BerryType); const berryTypes = Utils.getEnumValues(BerryType);
let randBerryType: BerryType; let randBerryType: BerryType;
let rand = Utils.randSeedInt(10); let rand = Utils.randSeedInt(12);
if (rand < 2) if (rand < 2)
randBerryType = BerryType.SITRUS; randBerryType = BerryType.SITRUS;
else if (rand < 4) else if (rand < 4)
randBerryType = BerryType.LUM; randBerryType = BerryType.LUM;
else if (rand < 6)
randBerryType = BerryType.LEPPA;
else else
randBerryType = berryTypes[Utils.randSeedInt(berryTypes.length - 2) + 2]; randBerryType = berryTypes[Utils.randSeedInt(berryTypes.length - 3) + 2];
return new BerryModifierType(randBerryType); return new BerryModifierType(randBerryType);
}), }),

View File

@ -1829,7 +1829,7 @@ export class TurnEndPhase extends FieldPhase {
const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ pokemon ]), pokemon.isPlayer()); const hasUsableBerry = !!this.scene.findModifier(m => m instanceof BerryModifier && m.shouldApply([ pokemon ]), pokemon.isPlayer());
if (hasUsableBerry) if (hasUsableBerry)
this.scene.pushPhase(new BerryPhase(this.scene, pokemon.getBattlerIndex())); this.scene.unshiftPhase(new BerryPhase(this.scene, pokemon.getBattlerIndex()));
this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon); this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon);