Add leftovers item

pull/1/head
Flashfyre 2023-04-20 20:15:16 -04:00
parent 60ac4e096c
commit bfa95a372e
3 changed files with 39 additions and 4 deletions

View File

@ -5,7 +5,7 @@ import { allMoves, applyMoveAttrs, BypassSleepAttr, ChargeAttr, ConditionalMoveA
import { Mode } from './ui/ui';
import { Command } from "./ui/command-ui-handler";
import { Stat } from "./data/pokemon-stat";
import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HealingBoosterModifier, HitHealModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, TempBattleStatBoosterModifier } from "./modifier/modifier";
import { BerryModifier, ExpBalanceModifier, ExpBoosterModifier, ExpShareModifier, ExtraModifierModifier, HealingBoosterModifier, HitHealModifier, PokemonExpBoosterModifier, PokemonHeldItemModifier, TempBattleStatBoosterModifier, TurnHealModifier } from "./modifier/modifier";
import PartyUiHandler, { PartyOption, PartyUiMode } from "./ui/party-ui-handler";
import { doPokeballBounceAnim, getPokeballAtlasKey, getPokeballCatchMultiplier, getPokeballTintColor, PokeballType } from "./data/pokeball";
import { CommonAnim, CommonBattleAnim, MoveAnim, initMoveAnim, loadMoveAnimAssets } from "./data/battle-anims";
@ -601,6 +601,8 @@ export class TurnEndPhase extends BattlePhase {
if (hasUsableBerry)
this.scene.pushPhase(new BerryPhase(this.scene, pokemon.isPlayer()));
this.scene.applyModifiers(TurnHealModifier, pokemon.isPlayer(), pokemon);
pokemon.battleSummonData.turnCount++;
};

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),

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;