Add leftovers item

This commit is contained in:
Flashfyre committed 2023-04-20 20:15:16 -04:00
1 parent 60ac4e096c
commit bfa95a372e
3 files changed
+39 -4

No files matched your search

+3
View File
@@ -515,6 +515,8 @@ const modifierTypes = {
BERRY_POUCH: new ModifierType('BERRY POUCH', 'Adds a 25% chance that a used berry will not be consumed',
(type, _args) => new Modifiers.PreserveBerryModifier(type)),
LEFTOVERS: new PokemonHeldItemModifierType('LEFTOVERS', 'Heals 1/16 of a POKéMON\'s maximum HP every turn',
(type, args) => new Modifiers.TurnHealModifier(type, (args[0] as Pokemon).id)),
SHELL_BELL: new PokemonHeldItemModifierType('SHELL BELL', 'Heals 1/8 of a POKéMON\'s dealt damage',
(type, args) => new Modifiers.HitHealModifier(type, (args[0] as Pokemon).id)),
@@ -590,6 +592,7 @@ const modifierPool = {
new WeightedModifierType(modifierTypes.ATTACK_TYPE_BOOSTER, 5),
modifierTypes.OVAL_CHARM,
modifierTypes.HEALING_CHARM,
new WeightedModifierType(modifierTypes.LEFTOVERS, 2),
new WeightedModifierType(modifierTypes.SHELL_BELL, 2),
new WeightedModifierType(modifierTypes.EXP_CHARM, 4),
new WeightedModifierType(modifierTypes.LUCKY_EGG, 3),
+33 -3
View File
@@ -340,6 +340,35 @@ export class AttackTypeBoosterModifier extends PokemonHeldItemModifier {
}
}
export class TurnHealModifier extends PokemonHeldItemModifier {
constructor(type: ModifierType, pokemonId: integer) {
super(type, pokemonId);
}
match(modifier: Modifier) {
return modifier instanceof TurnHealModifier;
}
clone() {
return new TurnHealModifier(this.type, this.pokemonId);
}
apply(args: any[]): boolean {
const pokemon = args[0] as Pokemon;
if (pokemon.getHpRatio() < 1) {
const scene = pokemon.scene;
scene.unshiftPhase(new PokemonHealPhase(scene, true, Math.max(Math.floor(pokemon.getMaxHp() / 16) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
}
return true;
}
getMaxStackCount(): number {
return 16;
}
}
export class HitHealModifier extends PokemonHeldItemModifier {
constructor(type: ModifierType, pokemonId: integer) {
super(type, pokemonId);
@@ -358,12 +387,15 @@ export class HitHealModifier extends PokemonHeldItemModifier {
if (pokemon.turnData.damageDealt && pokemon.getHpRatio() < 1) {
const scene = pokemon.scene;
scene.unshiftPhase(new PokemonHealPhase(scene, true, Math.max(Math.floor(pokemon.turnData.damageDealt / 8) * this.stackCount, 1), getPokemonMessage(pokemon, `'s ${this.type.name}\nrestored its HP a little!`), true));
}
return true;
}
getMaxStackCount(): number {
return 16;
}
}
export class BerryModifier extends PokemonHeldItemModifier {
@@ -395,8 +427,6 @@ export class BerryModifier extends PokemonHeldItemModifier {
const preserve = new Utils.BooleanHolder(false);
pokemon.scene.applyModifiers(PreserveBerryModifier, pokemon.isPlayer(), preserve);
console.log(pokemon.isPlayer());
getBerryEffectFunc(this.berryType)(pokemon);
if (!preserve.value)
this.consumed = true;