Skip to content

Commit

Permalink
fix eviolite not preventing evolution correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainpolletvillard committed Jul 1, 2024
1 parent 97ddae4 commit dc07887
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions app/core/evolution-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,25 @@ export class CountEvolutionRule extends EvolutionRule {
}

canEvolve(pokemon: Pokemon, player: Player, stageLevel: number): boolean {
if (pokemon.evolution === Pkm.DEFAULT || pokemon.items.has(Item.EVIOLITE))
const copies = values(player.board).filter((p) => p.index === pokemon.index)
if (
pokemon.evolution === Pkm.DEFAULT ||
copies.some((p) => p.items.has(Item.EVIOLITE))
) {
return false
const count = values(player.board).filter(
(pkm) => pkm.index === pokemon.index
).length
return count >= this.numberRequired
}
return copies.length >= this.numberRequired
}

canEvolveIfBuyingOne(pokemon: Pokemon, player: Player): boolean {
if (pokemon.evolution === Pkm.DEFAULT || pokemon.items.has(Item.EVIOLITE))
const copies = values(player.board).filter((p) => p.index === pokemon.index)
if (
pokemon.evolution === Pkm.DEFAULT ||
copies.some((p) => p.items.has(Item.EVIOLITE))
) {
return false
const count = values(player.board).filter(
(pkm) => pkm.index === pokemon.index
).length
return count >= this.numberRequired - 1
}
return copies.length >= this.numberRequired - 1
}

evolve(pokemon: Pokemon, player: Player, stageLevel: number): Pokemon {
Expand Down

0 comments on commit dc07887

Please sign in to comment.