mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-07-05 16:02:20 +02:00
Attempt to make this Fusion names work
This commit is contained in:
parent
14f1ba5336
commit
bc574ac87d
3
src/@types/i18next.d.ts
vendored
3
src/@types/i18next.d.ts
vendored
@ -1,4 +1,4 @@
|
|||||||
import { AbilityTranslationEntries, SimpleTranslationEntries, AchievementTranslationEntries, BerryTranslationEntries, DialogueTranslationEntries, ModifierTypeTranslationEntries, MoveTranslationEntries, PokemonInfoTranslationEntries, TranslationEntries } from "#app/interfaces/locales";
|
import { AbilityTranslationEntries, SimpleTranslationEntries, AchievementTranslationEntries, BerryTranslationEntries, DialogueTranslationEntries, ModifierTypeTranslationEntries, MoveTranslationEntries, PokemonInfoTranslationEntries, TranslationEntries, FusionTranslationEntries } from "#app/interfaces/locales";
|
||||||
|
|
||||||
// Module declared to make referencing keys in the localization files type-safe.
|
// Module declared to make referencing keys in the localization files type-safe.
|
||||||
declare module "i18next" {
|
declare module "i18next" {
|
||||||
@ -38,6 +38,7 @@ declare module "i18next" {
|
|||||||
partyUiHandler: SimpleTranslationEntries;
|
partyUiHandler: SimpleTranslationEntries;
|
||||||
pokeball: SimpleTranslationEntries;
|
pokeball: SimpleTranslationEntries;
|
||||||
pokemon: SimpleTranslationEntries;
|
pokemon: SimpleTranslationEntries;
|
||||||
|
fusionAffixes: FusionTranslationEntries;
|
||||||
pokemonInfo: PokemonInfoTranslationEntries;
|
pokemonInfo: PokemonInfoTranslationEntries;
|
||||||
pokemonInfoContainer: SimpleTranslationEntries;
|
pokemonInfoContainer: SimpleTranslationEntries;
|
||||||
saveSlotSelectUiHandler: SimpleTranslationEntries;
|
saveSlotSelectUiHandler: SimpleTranslationEntries;
|
||||||
|
@ -51,71 +51,18 @@ export function getPokemonSpeciesForm(species: Species, formIndex: integer): Pok
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function getFusedSpeciesName(speciesAName: string, speciesBName: string): string {
|
export function getFusedSpeciesName(speciesAName: string, speciesBName: string): string {
|
||||||
const fragAPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\']+)(.*?)$/i;
|
// Get the fusion affixes for the species
|
||||||
const fragBPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\'])(.*?)$/i;
|
const speciesAFusionAffixes = fusionAffixes[speciesAName];
|
||||||
|
const speciesBFusionAffixes = fusionAffixes[speciesBName];
|
||||||
|
|
||||||
const [ speciesAPrefixMatch, speciesBPrefixMatch ] = [ speciesAName, speciesBName ].map(n => /^(?:[^ ]+) /.exec(n));
|
// Get the fusion prefix and suffix for each species
|
||||||
const [ speciesAPrefix, speciesBPrefix ] = [ speciesAPrefixMatch, speciesBPrefixMatch ].map(m => m ? m[0] : "");
|
const speciesAPrefix = speciesAFusionAffixes.fusionPrefix;
|
||||||
|
const speciesBSuffix = speciesBFusionAffixes.fusionSuffix;
|
||||||
|
|
||||||
if (speciesAPrefix) {
|
// Construct the fused species name
|
||||||
speciesAName = speciesAName.slice(speciesAPrefix.length);
|
const fusedSpeciesName = `${speciesAPrefix}${speciesBSuffix}`;
|
||||||
}
|
|
||||||
if (speciesBPrefix) {
|
|
||||||
speciesBName = speciesBName.slice(speciesBPrefix.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
const [ speciesASuffixMatch, speciesBSuffixMatch ] = [ speciesAName, speciesBName ].map(n => / (?:[^ ]+)$/.exec(n));
|
return fusedSpeciesName;
|
||||||
const [ speciesASuffix, speciesBSuffix ] = [ speciesASuffixMatch, speciesBSuffixMatch ].map(m => m ? m[0] : "");
|
|
||||||
|
|
||||||
if (speciesASuffix) {
|
|
||||||
speciesAName = speciesAName.slice(0, -speciesASuffix.length);
|
|
||||||
}
|
|
||||||
if (speciesBSuffix) {
|
|
||||||
speciesBName = speciesBName.slice(0, -speciesBSuffix.length);
|
|
||||||
}
|
|
||||||
|
|
||||||
const splitNameA = speciesAName.split(/ /g);
|
|
||||||
const splitNameB = speciesBName.split(/ /g);
|
|
||||||
|
|
||||||
const fragAMatch = fragAPattern.exec(speciesAName);
|
|
||||||
const fragBMatch = fragBPattern.exec(speciesBName);
|
|
||||||
|
|
||||||
let fragA: string;
|
|
||||||
let fragB: string;
|
|
||||||
|
|
||||||
fragA = splitNameA.length === 1
|
|
||||||
? fragAMatch ? fragAMatch[1] : speciesAName
|
|
||||||
: splitNameA[splitNameA.length - 1];
|
|
||||||
|
|
||||||
if (splitNameB.length === 1) {
|
|
||||||
if (fragBMatch) {
|
|
||||||
const lastCharA = fragA.slice(fragA.length - 1);
|
|
||||||
const prevCharB = fragBMatch[1].slice(fragBMatch.length - 1);
|
|
||||||
fragB = (/[\-']/.test(prevCharB) ? prevCharB : "") + fragBMatch[2] || prevCharB;
|
|
||||||
if (lastCharA === fragB[0]) {
|
|
||||||
if (/[aiu]/.test(lastCharA)) {
|
|
||||||
fragB = fragB.slice(1);
|
|
||||||
} else {
|
|
||||||
const newCharMatch = new RegExp(`[^${lastCharA}]`).exec(fragB);
|
|
||||||
if (newCharMatch?.index > 0) {
|
|
||||||
fragB = fragB.slice(newCharMatch.index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fragB = speciesBName;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
fragB = splitNameB[splitNameB.length - 1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (splitNameA.length > 1) {
|
|
||||||
fragA = `${splitNameA.slice(0, splitNameA.length - 1).join(" ")} ${fragA}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
fragB = `${fragB.slice(0, 1).toLowerCase()}${fragB.slice(1)}`;
|
|
||||||
|
|
||||||
return `${speciesAPrefix || speciesBPrefix}${fragA}${fragB}${speciesBSuffix || speciesASuffix}`;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;
|
export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;
|
||||||
|
@ -9,6 +9,15 @@ export interface SimpleTranslationEntries {
|
|||||||
[key: string]: string
|
[key: string]: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface FusionTranslationEntries {
|
||||||
|
[key: string]: FusionTranslationEntry,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface FusionTranslationEntry {
|
||||||
|
fusionPrefix: string,
|
||||||
|
fusionSuffix: string,
|
||||||
|
}
|
||||||
|
|
||||||
export interface MoveTranslationEntry {
|
export interface MoveTranslationEntry {
|
||||||
name: string,
|
name: string,
|
||||||
effect: string
|
effect: string
|
||||||
|
4332
src/locales/de/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/de/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/en/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/en/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/es/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/es/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/fr/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/fr/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/it/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/it/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/ko/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/ko/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/pt_BR/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/pt_BR/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/zh_CN/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/zh_CN/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
4332
src/locales/zh_TW/pokemon-fusion-affixes.ts
Normal file
4332
src/locales/zh_TW/pokemon-fusion-affixes.ts
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user