Add natures
This commit is contained in:
1 parent
6dc868272f
commit
8cc1982859
16 files changed
+386
-78
No files matched your search
+14
-1
@@ -1005,6 +1005,18 @@ export class WeightMultiplierAbAttr extends AbAttr {
|
||||
}
|
||||
}
|
||||
|
||||
export class SyncEncounterNatureAbAttr extends AbAttr {
|
||||
constructor() {
|
||||
super(false);
|
||||
}
|
||||
|
||||
apply(pokemon: Pokemon, cancelled: Utils.BooleanHolder, args: any[]): boolean {
|
||||
(args[0] as Pokemon).setNature(pokemon.nature);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function applyAbAttrsInternal<TAttr extends AbAttr>(attrType: { new(...args: any[]): TAttr },
|
||||
pokemon: Pokemon, applyFunc: AbAttrApplyFunc<TAttr>, isAsync?: boolean, showAbilityInstant?: boolean): Promise<void> {
|
||||
return new Promise(resolve => {
|
||||
@@ -1505,7 +1517,8 @@ export function initAbilities() {
|
||||
.attr(TypeImmunityAbAttr, Type.GROUND, (pokemon: Pokemon) => !pokemon.getTag(BattlerTagType.IGNORE_FLYING) && !pokemon.scene.arena.getTag(ArenaTagType.GRAVITY)),
|
||||
new Ability(Abilities.EFFECT_SPORE, "Effect Spore", "Contact with the Pokémon may inflict poison, sleep, or paralysis on its attacker.", 3)
|
||||
.attr(PostDefendContactApplyStatusEffectAbAttr, 10, StatusEffect.POISON, StatusEffect.PARALYSIS, StatusEffect.SLEEP),
|
||||
new Ability(Abilities.SYNCHRONIZE, "Synchronize (N)", "The attacker will receive the same status condition if it inflicts a burn, poison, or paralysis to the Pokémon.", 3),
|
||||
new Ability(Abilities.SYNCHRONIZE, "Synchronize (N)", "The attacker will receive the same status condition if it inflicts a burn, poison, or paralysis to the Pokémon.", 3)
|
||||
.attr(SyncEncounterNatureAbAttr),
|
||||
new Ability(Abilities.CLEAR_BODY, "Clear Body", "Prevents other Pokémon's moves or Abilities from lowering the Pokémon's stats.", 3)
|
||||
.attr(ProtectStatAbAttr),
|
||||
new Ability(Abilities.NATURAL_CURE, "Natural Cure (N)", "All status conditions heal when the Pokémon switches out.", 3),
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
import { Stat, getStatName } from "./pokemon-stat";
|
||||
import * as Utils from "../utils";
|
||||
import { TextStyle, getBBCodeFrag } from "../ui/text";
|
||||
|
||||
export enum Nature {
|
||||
HARDY,
|
||||
LONELY,
|
||||
BRAVE,
|
||||
ADAMANT,
|
||||
NAUGHTY,
|
||||
BOLD,
|
||||
DOCILE,
|
||||
RELAXED,
|
||||
IMPISH,
|
||||
LAX,
|
||||
TIMID,
|
||||
HASTY,
|
||||
SERIOUS,
|
||||
JOLLY,
|
||||
NAIVE,
|
||||
MODEST,
|
||||
MILD,
|
||||
QUIET,
|
||||
BASHFUL,
|
||||
RASH,
|
||||
CALM,
|
||||
GENTLE,
|
||||
SASSY,
|
||||
CAREFUL,
|
||||
QUIRKY
|
||||
}
|
||||
|
||||
export function getNatureName(nature: Nature, includeStatEffects: boolean = false, forStarterSelect: boolean = false): string {
|
||||
let ret = Utils.toReadableString(Nature[nature]);
|
||||
if (includeStatEffects) {
|
||||
const stats = Utils.getEnumValues(Stat).slice(1);
|
||||
let increasedStat: Stat = null;
|
||||
let decreasedStat: Stat = null;
|
||||
for (let stat of stats) {
|
||||
const multiplier = getNatureStatMultiplier(nature, stat);
|
||||
if (multiplier > 1)
|
||||
increasedStat = stat;
|
||||
else
|
||||
decreasedStat = stat;
|
||||
}
|
||||
const textStyle = forStarterSelect ? TextStyle.SUMMARY : TextStyle.WINDOW;
|
||||
if (increasedStat && decreasedStat)
|
||||
ret = `${getBBCodeFrag(`${ret}${!forStarterSelect ? '\n' : ' '}(`, textStyle)}${getBBCodeFrag(`+${getStatName(increasedStat, true)}`, TextStyle.SUMMARY_BLUE)}${getBBCodeFrag('/', textStyle)}${getBBCodeFrag(`-${getStatName(decreasedStat, true)}`, TextStyle.SUMMARY_PINK)}${getBBCodeFrag(')', textStyle)}`;
|
||||
else
|
||||
ret = getBBCodeFrag(`${ret}${!forStarterSelect ? '\n' : ' '}(-)`, textStyle);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
export function getNatureStatMultiplier(nature: Nature, stat: Stat): number {
|
||||
switch (stat) {
|
||||
case Stat.ATK:
|
||||
switch (nature) {
|
||||
case Nature.LONELY:
|
||||
case Nature.BRAVE:
|
||||
case Nature.ADAMANT:
|
||||
case Nature.NAUGHTY:
|
||||
return 1.1;
|
||||
case Nature.BOLD:
|
||||
case Nature.TIMID:
|
||||
case Nature.MODEST:
|
||||
case Nature.CALM:
|
||||
return 0.9;
|
||||
}
|
||||
break;
|
||||
case Stat.DEF:
|
||||
switch (nature) {
|
||||
case Nature.BOLD:
|
||||
case Nature.RELAXED:
|
||||
case Nature.IMPISH:
|
||||
case Nature.LAX:
|
||||
return 1.1;
|
||||
case Nature.LONELY:
|
||||
case Nature.HASTY:
|
||||
case Nature.MILD:
|
||||
case Nature.GENTLE:
|
||||
return 0.9;
|
||||
}
|
||||
break;
|
||||
case Stat.SPATK:
|
||||
switch (nature) {
|
||||
case Nature.MODEST:
|
||||
case Nature.MILD:
|
||||
case Nature.QUIET:
|
||||
case Nature.RASH:
|
||||
return 1.1;
|
||||
case Nature.ADAMANT:
|
||||
case Nature.IMPISH:
|
||||
case Nature.JOLLY:
|
||||
case Nature.CAREFUL:
|
||||
return 0.9;
|
||||
}
|
||||
break;
|
||||
case Stat.SPDEF:
|
||||
switch (nature) {
|
||||
case Nature.CALM:
|
||||
case Nature.GENTLE:
|
||||
case Nature.SASSY:
|
||||
case Nature.CAREFUL:
|
||||
return 1.1;
|
||||
case Nature.NAUGHTY:
|
||||
case Nature.LAX:
|
||||
case Nature.NAIVE:
|
||||
case Nature.RASH:
|
||||
return 0.9;
|
||||
}
|
||||
break;
|
||||
case Stat.SPD:
|
||||
switch (nature) {
|
||||
case Nature.TIMID:
|
||||
case Nature.HASTY:
|
||||
case Nature.JOLLY:
|
||||
case Nature.NAIVE:
|
||||
return 1.1;
|
||||
case Nature.BRAVE:
|
||||
case Nature.RELAXED:
|
||||
case Nature.QUIET:
|
||||
case Nature.SASSY:
|
||||
return 0.9;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -7,26 +7,26 @@ export enum Stat {
|
||||
SPD
|
||||
};
|
||||
|
||||
export function getStatName(stat: Stat) {
|
||||
export function getStatName(stat: Stat, shorten: boolean = false) {
|
||||
let ret: string;
|
||||
switch (stat) {
|
||||
case Stat.HP:
|
||||
ret = 'Max. HP';
|
||||
ret = !shorten ? 'Max. HP' : 'MaxHP';
|
||||
break;
|
||||
case Stat.ATK:
|
||||
ret = 'Attack';
|
||||
ret = !shorten ? 'Attack' : 'Atk';
|
||||
break;
|
||||
case Stat.DEF:
|
||||
ret = 'Defense';
|
||||
ret = !shorten ? 'Defense' : 'Def';
|
||||
break;
|
||||
case Stat.SPATK:
|
||||
ret = 'Sp. Atk';
|
||||
ret = !shorten ? 'Sp. Atk' : 'SpAtk';
|
||||
break;
|
||||
case Stat.SPDEF:
|
||||
ret = 'Sp. Def';
|
||||
ret = !shorten ? 'Sp. Def' : 'SpDef';
|
||||
break;
|
||||
case Stat.SPD:
|
||||
ret = 'Speed';
|
||||
ret = !shorten ? 'Speed' : 'Spd';
|
||||
break;
|
||||
}
|
||||
return ret;
|
||||
|
||||
Reference in new issue
Block a user