From c1fe94a630a88c4f7203d54f34985c109030791c Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Sat, 19 Aug 2023 15:32:48 +0200 Subject: translations --- resources/js/classes/Monster.js | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) (limited to 'resources/js/classes/Monster.js') diff --git a/resources/js/classes/Monster.js b/resources/js/classes/Monster.js index 9023f32..5c930f8 100644 --- a/resources/js/classes/Monster.js +++ b/resources/js/classes/Monster.js @@ -70,6 +70,9 @@ class Monster { return DB.monsters[this.slug].moveset; } + /** + * @returns {DB_Evolution[]} + */ get evolutions () { return DB.monsters[this.slug].evolutions; } @@ -102,7 +105,7 @@ class Monster { } get name () { - return slugToName(this.slug); + return translate(this.slug) || slugToName(this.slug); } getLearnableTechniques () { @@ -126,18 +129,36 @@ class Monster { ); } - getPossibleEvolutions () { - // return this.evolutions.filter((evolution) => this.level >= evolution.at_level && (!evolution.item || this.heldItem === evolution.item)); - return this.evolutions.filter((evolution) => evolution.path === 'standard' && this.level >= evolution.at_level); - } + /** + * @param {EvolutionPathType} path + */ + getPossibleEvolutions (path) { + return this.evolutions.filter((evolution) => { + if (evolution.path !== path) { + return false; + } + + if (evolution.path === EvolutionPathType.standard) { + return this.level >= evolution.at_level; + } - canEvolve () { - return this.getPossibleEvolutions().length > 0; + else if (evolution.path === EvolutionPathType.item) { + return true; + } + }); } - evolve () { - const evolution = this.getPossibleEvolutions()[0]; + /** + * @param {EvolutionPathType} path + */ + canEvolve (path) { + return this.getPossibleEvolutions(path).length > 0; + } + /** + * @param {DB_Evolution} evolution + */ + evolve (evolution) { const statsPreEvolve = this.stats; const hpPreEvolve = this.hp; -- cgit v1.2.3