From f37c89b69bc49820d1d05fc15d95c5ac7f3dfa9b Mon Sep 17 00:00:00 2001 From: Sylvain Pollet-Villard Date: Sat, 15 Apr 2023 08:09:25 +0200 Subject: [PATCH] fix synergy count when same family has stones (#529) --- app/models/colyseus-models/synergies.ts | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/app/models/colyseus-models/synergies.ts b/app/models/colyseus-models/synergies.ts index 1a9be18b3d..e4bc535fab 100644 --- a/app/models/colyseus-models/synergies.ts +++ b/app/models/colyseus-models/synergies.ts @@ -16,7 +16,6 @@ export default class Synergies } update(board: MapSchema) { - const pokemonNames = new Array() this.setToZero() board.forEach((pkm: Pokemon) => { @@ -67,20 +66,21 @@ export default class Synergies } }) + const typesPerFamily = new Map>() board.forEach((pkm: Pokemon) => { - const family = PkmFamily[pkm.name] - if (!pokemonNames.includes(family) && pkm.positionY != 0) { - pokemonNames.push(family) - pkm.types.forEach((type) => { - const t = this.get(type) - if (t) { - this.set(type, t + 1) - } else { - this.set(type, 1) - } - }) + if (pkm.positionY != 0) { + const family = PkmFamily[pkm.name] + if(!typesPerFamily.has(family)) typesPerFamily.set(family, new Set()) + const types: Set = typesPerFamily.get(family)! + pkm.types.forEach(type => types.add(type)) } }) + + typesPerFamily.forEach((types) => { + types.forEach(type => { + this.set(type, (this.get(type) ?? 0) + 1) + }) + }) } setToZero() {