Change trainer classes

This commit is contained in:
fabske0 2025-08-18 18:08:09 +02:00
parent e7105fad13
commit 0162879ee8
2 changed files with 6 additions and 6 deletions

View File

@ -43,7 +43,7 @@ import type {
} from "#types/trainer-funcs"; } from "#types/trainer-funcs";
import { coerceArray, isNullOrUndefined, randSeedInt, randSeedIntRange, randSeedItem } from "#utils/common"; import { coerceArray, isNullOrUndefined, randSeedInt, randSeedIntRange, randSeedItem } from "#utils/common";
import { getPokemonSpecies } from "#utils/pokemon-utils"; import { getPokemonSpecies } from "#utils/pokemon-utils";
import { toSnakeCase, toTitleCase } from "#utils/strings"; import { toCamelCase, toSnakeCase, toTitleCase } from "#utils/strings";
import i18next from "i18next"; import i18next from "i18next";
/** Minimum BST for Pokemon generated onto the Elite Four's teams */ /** Minimum BST for Pokemon generated onto the Elite Four's teams */
@ -830,9 +830,9 @@ export class TrainerConfig {
initI18n(); initI18n();
} }
// Check if the female version exists in the i18n file // Check if the female version exists in the i18n file
if (i18next.exists(`trainerClasses:${this.name.toLowerCase()}`)) { if (i18next.exists(`trainerClasses:${toCamelCase(this.name)}Female`)) {
// If it does, return // If it does, return
return ret + "_female"; return ret + "Female";
} }
} }
} }

View File

@ -23,7 +23,7 @@ import {
} from "#trainers/trainer-party-template"; } from "#trainers/trainer-party-template";
import { randSeedInt, randSeedItem, randSeedWeightedItem } from "#utils/common"; import { randSeedInt, randSeedItem, randSeedWeightedItem } from "#utils/common";
import { getPokemonSpecies } from "#utils/pokemon-utils"; import { getPokemonSpecies } from "#utils/pokemon-utils";
import { toSnakeCase } from "#utils/strings"; import { toCamelCase, toSnakeCase } from "#utils/strings";
import i18next from "i18next"; import i18next from "i18next";
export class Trainer extends Phaser.GameObjects.Container { export class Trainer extends Phaser.GameObjects.Container {
@ -170,7 +170,7 @@ export class Trainer extends Phaser.GameObjects.Container {
const evilTeamTitles = ["grunt"]; const evilTeamTitles = ["grunt"];
if (this.name === "" && evilTeamTitles.some(t => name.toLocaleLowerCase().includes(t))) { if (this.name === "" && evilTeamTitles.some(t => name.toLocaleLowerCase().includes(t))) {
// This is a evil team grunt so we localize it by only using the "name" as the title // This is a evil team grunt so we localize it by only using the "name" as the title
title = i18next.t(`trainerClasses:${toSnakeCase(name)}`); title = i18next.t(`trainerClasses:${toCamelCase(name)}`);
console.log("Localized grunt name: " + title); console.log("Localized grunt name: " + title);
// Since grunts are not named we can just return the title // Since grunts are not named we can just return the title
return title; return title;
@ -187,7 +187,7 @@ export class Trainer extends Phaser.GameObjects.Container {
} }
// Get the localized trainer class name from the i18n file and set it as the title. // Get the localized trainer class name from the i18n file and set it as the title.
// This is used for trainer class names, not titles like "Elite Four, Champion, etc." // This is used for trainer class names, not titles like "Elite Four, Champion, etc."
title = i18next.t(`trainerClasses:${toSnakeCase(name)}`); title = i18next.t(`trainerClasses:${toCamelCase(name)}`);
} }
// If no specific trainer slot is set. // If no specific trainer slot is set.