Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect handling of Pokemon names containing é #515

Open
RainingChain opened this issue Jan 13, 2023 · 2 comments
Open

Incorrect handling of Pokemon names containing é #515

RainingChain opened this issue Jan 13, 2023 · 2 comments

Comments

@RainingChain
Copy link

The official english name for Pokemon #669 is Flabébé. However, when trying to create a new Smogon.Pokemon instance with that name, it fails.

Current behaviour:

new Smogon.Pokemon(6, 'Flabébé',{}); 
// Uncaught TypeError: Cannot read properties of undefined (reading 'hp')

Expected behaviour:

new Smogon.Pokemon(6, 'Flabébé',{}); 
// Pokemon {species: {…}, gen: Generation, name: 'Flabebe', types: Array(1), isDynamaxed: false, …}

The issue is with the function utils.toID

function toID(text) {
    return ('' + text).toLowerCase().replace(/[^a-z0-9]+/g, '');
}

Internally, the id for Flabébé is flabebe.
However, toID('Flabébé') returns flabb.

Ideally, we would modify the function toID for:

function toID(text) {
    return ('' + text).toLowerCase().replace(/é/g, 'e').replace(/[^a-z0-9]+/g, '');
}
@monsanto
Copy link
Member

monsanto commented Jan 13, 2023

Yes although Smogon's data is now derived from PS' data in the past there were some differences, and not all of the kinks have been smoothed. The conversion has the following exceptions (from the PS data import code)

name = name.replace(/\u2019/g, "'"); // Farfetch'd ...
if (name === 'Necrozma-Dawn-Wings') {
    name = 'Necrozma-Dawn Wings';
  } else if (name === 'Necrozma-Dusk-Mane') {
    name = 'Necrozma-Dusk Mane';
  } else if (name === 'Flabébé') {
    name = 'Flabebe';
  } else if (name === 'Meowstic') {
    name = 'Meowstic-M';
  } else if (name === 'Vise Grip') {
    // Can't handle this rename yet, will break old links
    name = 'Vice Grip';
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@monsanto @RainingChain and others