mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-02-24 04:57:34 +00:00
* Create Getters, Setters, and Types * Work on `pokemon.ts` * Adjust Types, Refactor `White Herb` Modifier * Migrate `TempBattleStat` Usage * Refactor `PokemonBaseStatModifier` Slightly * Remove `BattleStat`, Use "Stat Stages" & New Names * Address Phase `integers` * Finalize `BattleStat` Removal * Address Minor Manual NITs * Apply Own Review Suggestions * Fix Syntax Error * Add Docs * Overhaul X Items * Implement Guard and Power Split with Unit Tests * Add Several Unit Tests and Fixes * Implement Speed Swap with Unit Tests * Fix Keys in Summary Menu * Fix Starf Berry Raising EVA and ACC * Fix Contrary & Simple, Verify with Unit Tests * Implement Power & Guard Swap with Unit Tests * Add Move Effect Message to Speed Swap * Add Move Effect Message to Power & Guard Split * Add Localization Entries * Adjust Last X Item Unit Test * Overhaul X Items Unit Tests * Finish Missing Docs * Revamp Crit-Based Unit Tests & Dire Hit * Address Initial NITs * Apply NIT Batch Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> * Fix Moody Test * Address Multiple Messages for `ProtectStatAbAttr` * Change `ignoreOverride` to `bypassSummonData` * Adjust Italian Localization Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com> * Fix Moody --------- Co-authored-by: flx-sta <50131232+flx-sta@users.noreply.github.com> Co-authored-by: Niccolò <123510358+NicusPulcis@users.noreply.github.com>
114 lines
3.2 KiB
TypeScript
114 lines
3.2 KiB
TypeScript
import * as Utils from "../utils";
|
|
import { TextStyle, getBBCodeFrag } from "../ui/text";
|
|
import { Nature } from "#enums/nature";
|
|
import { UiTheme } from "#enums/ui-theme";
|
|
import i18next from "i18next";
|
|
import { Stat, EFFECTIVE_STATS, getShortenedStatKey } from "#app/enums/stat";
|
|
|
|
export { Nature };
|
|
|
|
export function getNatureName(nature: Nature, includeStatEffects: boolean = false, forStarterSelect: boolean = false, ignoreBBCode: boolean = false, uiTheme: UiTheme = UiTheme.DEFAULT): string {
|
|
let ret = Utils.toReadableString(Nature[nature]);
|
|
//Translating nature
|
|
if (i18next.exists("nature:" + ret)) {
|
|
ret = i18next.t("nature:" + ret as any);
|
|
}
|
|
if (includeStatEffects) {
|
|
let increasedStat: Stat | null = null;
|
|
let decreasedStat: Stat | null = null;
|
|
for (const stat of EFFECTIVE_STATS) {
|
|
const multiplier = getNatureStatMultiplier(nature, stat);
|
|
if (multiplier > 1) {
|
|
increasedStat = stat;
|
|
} else if (multiplier < 1) {
|
|
decreasedStat = stat;
|
|
}
|
|
}
|
|
const textStyle = forStarterSelect ? TextStyle.SUMMARY_ALT : TextStyle.WINDOW;
|
|
const getTextFrag = !ignoreBBCode ? (text: string, style: TextStyle) => getBBCodeFrag(text, style, uiTheme) : (text: string, style: TextStyle) => text;
|
|
if (increasedStat && decreasedStat) {
|
|
ret = `${getTextFrag(`${ret}${!forStarterSelect ? "\n" : " "}(`, textStyle)}${getTextFrag(`+${i18next.t(getShortenedStatKey(increasedStat))}`, TextStyle.SUMMARY_PINK)}${getTextFrag("/", textStyle)}${getTextFrag(`-${i18next.t(getShortenedStatKey(decreasedStat))}`, TextStyle.SUMMARY_BLUE)}${getTextFrag(")", textStyle)}`;
|
|
} else {
|
|
ret = getTextFrag(`${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;
|
|
}
|