Skip to content

Commit

Permalink
fix synergy count when same family has stones (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainpolletvillard authored Apr 15, 2023
1 parent 7544656 commit f37c89b
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions app/models/colyseus-models/synergies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export default class Synergies
}

update(board: MapSchema<Pokemon>) {
const pokemonNames = new Array<Pkm>()
this.setToZero()

board.forEach((pkm: Pokemon) => {
Expand Down Expand Up @@ -67,20 +66,21 @@ export default class Synergies
}
})

const typesPerFamily = new Map<Pkm, Set<Synergy>>()
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<Synergy> = 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() {
Expand Down

0 comments on commit f37c89b

Please sign in to comment.