Improvements to spliced name generation

This commit is contained in:
Flashfyre 2024-03-06 23:57:11 -05:00
parent 1861823673
commit 7efd8aa834
3 changed files with 22 additions and 5 deletions

View File

@ -28,6 +28,22 @@ export function getFusedSpeciesName(speciesAName: string, speciesBName: string):
const fragAPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\']+)(.*?)$/i;
const fragBPattern = /([a-z]{2}.*?[aeiou(?:y$)\-\'])(.*?)$/i;
const [ speciesAPrefixMatch, speciesBPrefixMatch ] = [ speciesAName, speciesBName ].map(n => /^(?:Mega|(?:G|E)\-Max) /.exec(n));
const [ speciesAPrefix, speciesBPrefix ] = [ speciesAPrefixMatch, speciesBPrefixMatch ].map(m => m ? m[0] : '');
if (speciesAPrefix)
speciesAName = speciesAName.slice(speciesAPrefix.length);
if (speciesBPrefix)
speciesBName = speciesBName.slice(speciesBPrefix.length);
const [ speciesASuffixMatch, speciesBSuffixMatch ] = [ speciesAName, speciesBName ].map(n => / (?:X|Y)$/.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);
@ -58,7 +74,7 @@ export function getFusedSpeciesName(speciesAName: string, speciesBName: string):
fragB = `${fragB.slice(0, 1).toLowerCase()}${fragB.slice(1)}`;
return `${fragA}${fragB}`;
return `${speciesAPrefix || speciesBPrefix}${fragA}${fragB}${speciesBSuffix || speciesASuffix}`;
}
export type PokemonSpeciesFilter = (species: PokemonSpecies) => boolean;
@ -371,6 +387,7 @@ export default class PokemonSpecies extends PokemonSpeciesForm {
const form = this.forms[formIndex];
switch (form.formKey) {
case SpeciesFormKey.MEGA:
case SpeciesFormKey.PRIMAL:
case SpeciesFormKey.ETERNAMAX:
return `${form.formName} ${this.name}`;
case SpeciesFormKey.MEGA_X:

View File

@ -153,7 +153,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
});
this.teraIcon.on('pointerout', () => (this.scene as BattleScene).ui.hideTooltip());
this.splicedIcon.setPositionRelative(this.nameText, nameTextWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), 2);
this.splicedIcon.setPositionRelative(this.nameText, nameTextWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), 2.5);
this.splicedIcon.setVisible(!!pokemon.fusionSpecies);
if (this.splicedIcon.visible) {
this.splicedIcon.on('pointerover', () => (this.scene as BattleScene).ui.showTooltip(null, `${pokemon.species.getName(pokemon.formIndex)}/${pokemon.fusionSpecies.getName(pokemon.fusionFormIndex)}`));
@ -283,7 +283,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
}
if (nameUpdated || teraTypeUpdated)
this.splicedIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), 1);
this.splicedIcon.setPositionRelative(this.nameText, this.nameText.displayWidth + this.genderText.displayWidth + 1 + (this.teraIcon.visible ? this.teraIcon.displayWidth + 1 : 0), 1.5);
if (this.lastStatus !== (pokemon.status?.effect || StatusEffect.NONE)) {
this.lastStatus = pokemon.status?.effect || StatusEffect.NONE;
@ -363,7 +363,7 @@ export default class BattleInfo extends Phaser.GameObjects.Container {
let nameSizeTest = addTextObject(this.scene, 0, 0, displayName, TextStyle.BATTLE_INFO);
nameTextWidth = nameSizeTest.displayWidth;
while (nameTextWidth > (this.player || !this.boss ? 60 : 98) - ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + (pokemon.fusionSpecies ? 6 : 0) + (pokemon.isShiny() ? 8 : 0) + (Math.min(pokemon.level.toString().length, 3) - 3) * 8)) {
while (nameTextWidth > (this.player || !this.boss ? 60 : 98) - ((pokemon.gender !== Gender.GENDERLESS ? 6 : 0) + (pokemon.fusionSpecies ? 8 : 0) + (pokemon.isShiny() ? 8 : 0) + (Math.min(pokemon.level.toString().length, 3) - 3) * 8)) {
displayName = `${displayName.slice(0, displayName.endsWith('.') ? -2 : -1).trimEnd()}.`;
nameSizeTest.setText(displayName);
nameTextWidth = nameSizeTest.displayWidth;

View File

@ -816,7 +816,7 @@ class PartySlot extends Phaser.GameObjects.Container {
let nameSizeTest = addTextObject(this.scene, 0, 0, displayName, TextStyle.PARTY);
nameTextWidth = nameSizeTest.displayWidth;
while (nameTextWidth > (this.slotIndex ? 52 : 80)) {
while (nameTextWidth > (this.slotIndex >= battlerCount ? 52 : (76 - (this.pokemon.fusionSpecies ? 8 : 0)))) {
displayName = `${displayName.slice(0, displayName.endsWith('.') ? -2 : -1).trimEnd()}.`;
nameSizeTest.setText(displayName);
nameTextWidth = nameSizeTest.displayWidth;