mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-03 23:36:43 +02:00
32 lines
921 B
JavaScript
32 lines
921 B
JavaScript
module.exports = class Pokemon {
|
|
constructor(data) {
|
|
this.id = data.id;
|
|
this.name = data.names.filter(entry => entry.language.name === 'en')[0].name;
|
|
this.entries = data.flavor_text_entries
|
|
.filter(entry => entry.language.name === 'en')
|
|
.map(entry => entry.flavor_text.replace(/\n|\f|\r/g, ' '));
|
|
this.names = data.names;
|
|
this.genus = `The ${data.genera.filter(entry => entry.language.name === 'en')[0].genus}`;
|
|
}
|
|
|
|
get displayID() {
|
|
return this.id.toString().padStart(3, '0');
|
|
}
|
|
|
|
get slug() {
|
|
return encodeURIComponent(this.name.toLowerCase().replace(/ /g, '-').replace(/[^a-zA-Z0-9-]/g, ''));
|
|
}
|
|
|
|
get spriteImageURL() {
|
|
return `https://www.serebii.net/sunmoon/pokemon/${this.displayID}.png`;
|
|
}
|
|
|
|
get boxImageURL() {
|
|
return `https://www.serebii.net/pokedex-sm/icon/${this.displayID}.png`;
|
|
}
|
|
|
|
get serebiiURL() {
|
|
return `https://www.serebii.net/pokedex-sm/${this.displayID}.shtml`;
|
|
}
|
|
};
|