Attempt to make this Fusion names work

(cherry picked from commit bc574ac87d)
This commit is contained in:
Amatsune 2024-06-23 23:42:52 +08:00 committed by mercurius-00
parent 78c3906088
commit 4a154a7613
11 changed files with 39006 additions and 62 deletions

View File

@ -51,71 +51,18 @@ export function getPokemonSpeciesForm(species: Species, formIndex: integer): Pok
}
export function getFusedSpeciesName(speciesAName: string, speciesBName: string): string {
const fragAPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\']+)(.*?)$/i;
const fragBPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\'])(.*?)$/i;
// Get the fusion affixes for the species
const speciesAFusionAffixes = fusionAffixes[speciesAName];
const speciesBFusionAffixes = fusionAffixes[speciesBName];
const [ speciesAPrefixMatch, speciesBPrefixMatch ] = [ speciesAName, speciesBName ].map(n => /^(?:[^ ]+) /.exec(n));
const [ speciesAPrefix, speciesBPrefix ] = [ speciesAPrefixMatch, speciesBPrefixMatch ].map(m => m ? m[0] : "");
// Get the fusion prefix and suffix for each species
const speciesAPrefix = speciesAFusionAffixes.fusionPrefix;
const speciesBSuffix = speciesBFusionAffixes.fusionSuffix;
if (speciesAPrefix) {
speciesAName = speciesAName.slice(speciesAPrefix.length);
}
if (speciesBPrefix) {
speciesBName = speciesBName.slice(speciesBPrefix.length);
}
// Construct the fused species name
const fusedSpeciesName = `${speciesAPrefix}${speciesBSuffix}`;
const [ speciesASuffixMatch, speciesBSuffixMatch ] = [ speciesAName, speciesBName ].map(n => / (?:[^ ]+)$/.exec(n));
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}`;
return fusedSpeciesName;
}
export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;

View File

@ -9,6 +9,15 @@ export interface SimpleTranslationEntries {
[key: string]: string
}
export interface FusionTranslationEntries {
[key: string]: FusionTranslationEntry,
}
export interface FusionTranslationEntry {
fusionPrefix: string,
fusionSuffix: string,
}
export interface MoveTranslationEntry {
name: string,
effect: string

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff