diff --git a/src/data/pokemon-species.ts b/src/data/pokemon-species.ts index 20d6b5949..aacddcea4 100644 --- a/src/data/pokemon-species.ts +++ b/src/data/pokemon-species.ts @@ -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: diff --git a/src/ui/battle-info.ts b/src/ui/battle-info.ts index d6ebb9f1e..e4cca89a7 100644 --- a/src/ui/battle-info.ts +++ b/src/ui/battle-info.ts @@ -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; diff --git a/src/ui/party-ui-handler.ts b/src/ui/party-ui-handler.ts index b4d87a8ad..d5f1c4f4c 100644 --- a/src/ui/party-ui-handler.ts +++ b/src/ui/party-ui-handler.ts @@ -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;