mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-11 02:42:19 +02:00
Rework and test getTitle
This commit is contained in:
parent
459fb95fbd
commit
3d9b0253ef
69
src/data/trainer-config.test.ts
Normal file
69
src/data/trainer-config.test.ts
Normal file
@ -0,0 +1,69 @@
|
||||
import { expect, describe, it, beforeAll, vi, afterAll, beforeEach } from "vitest";
|
||||
import { TrainerConfig, TrainerSlot } from "./trainer-config";
|
||||
import { TrainerType } from "./enums/trainer-type";
|
||||
import { TrainerVariant } from "#app/field/trainer.js";
|
||||
|
||||
describe("trainer-config", () => {
|
||||
describe("getTitle", () => {
|
||||
let trainerConfig: TrainerConfig;
|
||||
|
||||
beforeAll(() => {
|
||||
// Error when importing biomes / voucher (imported by different files)
|
||||
vi.mock('./biomes', () => ({
|
||||
biomeLinks: {},
|
||||
BiomePoolTier: {},
|
||||
PokemonPools: {},
|
||||
getBiomeName: () => "",
|
||||
BiomeTierTrainerPools: {},
|
||||
biomePokemonPools: {},
|
||||
biomeTrainerPools: {},
|
||||
}));
|
||||
vi.mock('../system/voucher', () => ({
|
||||
vouchers: {},
|
||||
VoucherType: {},
|
||||
getVoucherTypeIcon: () => "",
|
||||
Voucher: {},
|
||||
getVoucherTypeName: () => "",
|
||||
}));
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
trainerConfig = new TrainerConfig(TrainerType.ARTIST, false);
|
||||
});
|
||||
|
||||
it("returns the name double when trainer variant double", () => {
|
||||
trainerConfig.nameDouble = "Lae & Ticia";
|
||||
expect(trainerConfig.getTitle(TrainerSlot.NONE, TrainerVariant.DOUBLE)).toBe("Lae & Ticia");
|
||||
});
|
||||
|
||||
it("returns the trainer type name when no gender selected", () => {
|
||||
expect(trainerConfig.getTitle(TrainerSlot.NONE, TrainerVariant.DEFAULT)).toBe("Artist");
|
||||
});
|
||||
|
||||
it("returns the female name when gender is female", () => {
|
||||
trainerConfig.nameFemale = "Laeticia";
|
||||
trainerConfig.hasGenders = true;
|
||||
expect(trainerConfig.getTitle(TrainerSlot.NONE, TrainerVariant.FEMALE)).toBe("Laeticia");
|
||||
});
|
||||
|
||||
it("returns the female name when trainer variant double and trainer partner", () => {
|
||||
trainerConfig.nameFemale = "Laeticia";
|
||||
trainerConfig.hasGenders = true;
|
||||
expect(trainerConfig.getTitle(TrainerSlot.TRAINER_PARTNER, TrainerVariant.DOUBLE)).toBe("Laeticia");
|
||||
});
|
||||
|
||||
it("returns the trainer type name with the female gender", () => {
|
||||
trainerConfig.hasGenders = true;
|
||||
expect(trainerConfig.getTitle(TrainerSlot.NONE, TrainerVariant.FEMALE)).toBe("Artist♀");
|
||||
});
|
||||
|
||||
it("returns the trainer type name with the male gender", () => {
|
||||
trainerConfig.hasGenders = true;
|
||||
expect(trainerConfig.getTitle(TrainerSlot.NONE, TrainerVariant.DEFAULT)).toBe("Artist♂");
|
||||
});
|
||||
});
|
||||
});
|
@ -429,20 +429,16 @@ export class TrainerConfig {
|
||||
}
|
||||
|
||||
getTitle(trainerSlot: TrainerSlot = TrainerSlot.NONE, variant: TrainerVariant): string {
|
||||
let ret = this.name;
|
||||
|
||||
if (!trainerSlot && variant === TrainerVariant.DOUBLE && this.nameDouble)
|
||||
if (trainerSlot === TrainerSlot.NONE && variant === TrainerVariant.DOUBLE && this.nameDouble)
|
||||
return this.nameDouble;
|
||||
|
||||
if (this.hasGenders) {
|
||||
if (this.nameFemale) {
|
||||
if (variant === TrainerVariant.FEMALE || (variant === TrainerVariant.DOUBLE && trainerSlot === TrainerSlot.TRAINER_PARTNER))
|
||||
return this.nameFemale;
|
||||
} else
|
||||
ret += !variant ? '♂' : '♀';
|
||||
}
|
||||
if (!this.hasGenders)
|
||||
return this.name;
|
||||
|
||||
return ret;
|
||||
if (this.nameFemale && (variant === TrainerVariant.FEMALE || (variant === TrainerVariant.DOUBLE && trainerSlot === TrainerSlot.TRAINER_PARTNER)))
|
||||
return this.nameFemale;
|
||||
|
||||
return `${this.name}${variant === TrainerVariant.DEFAULT ? '♂' : '♀'}`;
|
||||
}
|
||||
|
||||
loadAssets(scene: BattleScene, variant: TrainerVariant): Promise<void> {
|
||||
|
Loading…
Reference in New Issue
Block a user