mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-26 17:29:30 +02:00
Fix trainer title logging
This commit is contained in:
parent
ef8e9904e4
commit
6af3f4ef3f
@ -168,6 +168,112 @@ export default class Trainer extends Phaser.GameObjects.Container {
|
||||
// Return the formatted name, including the title if it is set.
|
||||
return title ? `${title} ${name}` : name;
|
||||
}
|
||||
getNameOnly(trainerSlot: TrainerSlot = TrainerSlot.NONE): string {
|
||||
// Get the base title based on the trainer slot and variant.
|
||||
let name = this.config.getTitle(trainerSlot, this.variant);
|
||||
|
||||
// Determine the title to include based on the configuration and includeTitle flag.
|
||||
let title = true && this.config.title ? this.config.title : null;
|
||||
|
||||
if (this.name === "" && name.toLowerCase().includes("grunt")) {
|
||||
// This is a evil team grunt so we localize it by only using the "name" as the title
|
||||
title = i18next.t(`trainerClasses:${name.toLowerCase().replace(/\s/g, "_")}`);
|
||||
console.log("Localized grunt name: " + title);
|
||||
// Since grunts are not named we can just return the title
|
||||
return title;
|
||||
}
|
||||
|
||||
// If the trainer has a name (not null or undefined).
|
||||
if (this.name) {
|
||||
// If the title should be included.
|
||||
if (true) {
|
||||
// Check if the internationalization (i18n) system is initialized.
|
||||
if (!getIsInitialized()) {
|
||||
// Initialize the i18n system if it is not already initialized.
|
||||
initI18n();
|
||||
}
|
||||
// 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."
|
||||
title = i18next.t(`trainerClasses:${name.toLowerCase().replace(/\s/g, "_")}`);
|
||||
}
|
||||
|
||||
// If no specific trainer slot is set.
|
||||
if (!trainerSlot) {
|
||||
// Use the trainer's name.
|
||||
name = this.name;
|
||||
// If there is a partner name, concatenate it with the trainer's name using "&".
|
||||
if (this.partnerName) {
|
||||
name = `${name} & ${this.partnerName}`;
|
||||
}
|
||||
} else {
|
||||
// Assign the name based on the trainer slot:
|
||||
// Use 'this.name' if 'trainerSlot' is TRAINER.
|
||||
// Otherwise, use 'this.partnerName' if it exists, or 'this.name' if it doesn't.
|
||||
name = trainerSlot === TrainerSlot.TRAINER ? this.name : this.partnerName || this.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.config.titleDouble && this.variant === TrainerVariant.DOUBLE && !this.config.doubleOnly) {
|
||||
title = this.config.titleDouble;
|
||||
name = i18next.t(`trainerNames:${this.config.nameDouble.toLowerCase().replace(/\s/g, "_")}`);
|
||||
}
|
||||
|
||||
// Return the formatted name, including the title if it is set.
|
||||
return name || "";
|
||||
}
|
||||
getTitleOnly(trainerSlot: TrainerSlot = TrainerSlot.NONE): string {
|
||||
// Get the base title based on the trainer slot and variant.
|
||||
let name = this.config.getTitle(trainerSlot, this.variant);
|
||||
|
||||
// Determine the title to include based on the configuration and includeTitle flag.
|
||||
let title = true && this.config.title ? this.config.title : null;
|
||||
|
||||
if (this.name === "" && name.toLowerCase().includes("grunt")) {
|
||||
// This is a evil team grunt so we localize it by only using the "name" as the title
|
||||
title = i18next.t(`trainerClasses:${name.toLowerCase().replace(/\s/g, "_")}`);
|
||||
console.log("Localized grunt name: " + title);
|
||||
// Since grunts are not named we can just return the title
|
||||
return title;
|
||||
}
|
||||
|
||||
// If the trainer has a name (not null or undefined).
|
||||
if (this.name) {
|
||||
// If the title should be included.
|
||||
if (true) {
|
||||
// Check if the internationalization (i18n) system is initialized.
|
||||
if (!getIsInitialized()) {
|
||||
// Initialize the i18n system if it is not already initialized.
|
||||
initI18n();
|
||||
}
|
||||
// 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."
|
||||
title = i18next.t(`trainerClasses:${name.toLowerCase().replace(/\s/g, "_")}`);
|
||||
}
|
||||
|
||||
// If no specific trainer slot is set.
|
||||
if (!trainerSlot) {
|
||||
// Use the trainer's name.
|
||||
name = this.name;
|
||||
// If there is a partner name, concatenate it with the trainer's name using "&".
|
||||
if (this.partnerName) {
|
||||
name = `${name} & ${this.partnerName}`;
|
||||
}
|
||||
} else {
|
||||
// Assign the name based on the trainer slot:
|
||||
// Use 'this.name' if 'trainerSlot' is TRAINER.
|
||||
// Otherwise, use 'this.partnerName' if it exists, or 'this.name' if it doesn't.
|
||||
name = trainerSlot === TrainerSlot.TRAINER ? this.name : this.partnerName || this.name;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.config.titleDouble && this.variant === TrainerVariant.DOUBLE && !this.config.doubleOnly) {
|
||||
title = this.config.titleDouble;
|
||||
name = i18next.t(`trainerNames:${this.config.nameDouble.toLowerCase().replace(/\s/g, "_")}`);
|
||||
}
|
||||
|
||||
// Return the formatted name, including the title if it is set.
|
||||
return title || "";
|
||||
}
|
||||
|
||||
|
||||
isDouble(): boolean {
|
||||
|
@ -1093,24 +1093,10 @@ export interface TrainerData {
|
||||
* @returns The Trainer data.
|
||||
*/
|
||||
export function exportTrainer(trainer: Trainer): TrainerData {
|
||||
if (trainer.config.getTitle(0, trainer.variant) == "Finn") {
|
||||
return {
|
||||
id: trainer.config.trainerType,
|
||||
name: "Finn",
|
||||
type: "Rival"
|
||||
}
|
||||
}
|
||||
if (trainer.config.getTitle(0, trainer.variant) == "Ivy") {
|
||||
return {
|
||||
id: trainer.config.trainerType,
|
||||
name: "Ivy",
|
||||
type: "Rival"
|
||||
}
|
||||
}
|
||||
return {
|
||||
id: trainer.config.trainerType,
|
||||
name: trainer.name,
|
||||
type: trainer.config.getTitle(0, trainer.variant)
|
||||
name: trainer.getNameOnly(),
|
||||
type: trainer.getTitleOnly()
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
@ -682,7 +682,7 @@ export default class FightUiHandler extends UiHandler {
|
||||
if (Math.floor(dmgLow) >= target.hp) {
|
||||
koText = " (KO)"
|
||||
} else if (Math.ceil(dmgHigh) >= target.hp) {
|
||||
var percentChance = (target.hp - dmgLow + 1) / (dmgHigh - dmgLow + 1)
|
||||
var percentChance = 1 - ((target.hp - dmgLow + 1) / (dmgHigh - dmgLow + 1))
|
||||
koText = " (" + Math.round(percentChance * 100) + "% KO)"
|
||||
}
|
||||
if (target.getMoveEffectiveness(user, move) == undefined) {
|
||||
|
Loading…
Reference in New Issue
Block a user