Refactor source files and add berries
This commit is contained in:
1 parent
6135243641
commit
3546f3b5a7
103 files changed
+2598
-1171
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { MessagePhase, PokemonHealPhase } from "../battle-phases";
|
||||
import { getPokemonMessage } from "../messages";
|
||||
import Pokemon from "../pokemon";
|
||||
import { BattleTagType } from "./battle-tag";
|
||||
import { getStatusEffectHealText } from "./status-effect";
|
||||
|
||||
export enum BerryType {
|
||||
SITRUS,
|
||||
LUM
|
||||
}
|
||||
|
||||
export function getBerryName(berryType: BerryType) {
|
||||
switch (berryType) {
|
||||
case BerryType.SITRUS:
|
||||
return 'SITRUS BERRY';
|
||||
case BerryType.LUM:
|
||||
return 'LUM BERRY';
|
||||
}
|
||||
}
|
||||
|
||||
export function getBerryEffectDescription(berryType: BerryType) {
|
||||
switch (berryType) {
|
||||
case BerryType.SITRUS:
|
||||
return 'Restores 25% HP if HP is below 50%';
|
||||
case BerryType.LUM:
|
||||
return 'Cures any non-volatile status condition and confusion';
|
||||
}
|
||||
}
|
||||
|
||||
export type BerryPredicate = (pokemon: Pokemon) => boolean;
|
||||
|
||||
export function getBerryPredicate(berryType: BerryType): BerryPredicate {
|
||||
switch (berryType) {
|
||||
case BerryType.SITRUS:
|
||||
return (pokemon: Pokemon) => pokemon.getHpRatio() < 0.5;
|
||||
case BerryType.LUM:
|
||||
return (pokemon: Pokemon) => !!pokemon.status || !!pokemon.getTag(BattleTagType.CONFUSED);
|
||||
}
|
||||
}
|
||||
|
||||
export type BerryEffectFunc = (pokemon: Pokemon) => void;
|
||||
|
||||
export function getBerryEffectFunc(berryType: BerryType): BerryEffectFunc {
|
||||
switch (berryType) {
|
||||
case BerryType.SITRUS:
|
||||
return (pokemon: Pokemon) => {
|
||||
pokemon.scene.unshiftPhase(new PokemonHealPhase(pokemon.scene, true, Math.floor(pokemon.getMaxHp() / 4), getPokemonMessage(pokemon, `'s ${getBerryName(berryType)}\nrestored its HP!`), true));
|
||||
};
|
||||
case BerryType.LUM:
|
||||
return (pokemon: Pokemon) => {
|
||||
if (pokemon.status) {
|
||||
pokemon.scene.unshiftPhase(new MessagePhase(pokemon.scene,
|
||||
getPokemonMessage(pokemon, getStatusEffectHealText(pokemon.status.effect))));
|
||||
pokemon.resetStatus();
|
||||
pokemon.updateInfo();
|
||||
} else if (pokemon.getTag(BattleTagType.CONFUSED))
|
||||
pokemon.lapseTag(BattleTagType.CONFUSED);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user