Skip to content

Commit

Permalink
fix server exceptions (#1694)
Browse files Browse the repository at this point in the history
  • Loading branch information
sylvainpolletvillard authored Apr 30, 2024
1 parent 02aae7a commit f225629
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
4 changes: 2 additions & 2 deletions app/core/evolution-rules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { values } from "../utils/schemas"
type DivergentEvolution = (
pokemon: Pokemon,
player: Player,
...aditionalArgs: any[]
...aditionalArgs: unknown[]
) => Pkm

export abstract class EvolutionRule {
Expand Down Expand Up @@ -169,7 +169,7 @@ export class ItemEvolutionRule extends EvolutionRule {

constructor(
itemsTriggeringEvolution: Item[],
divergentEvolution?: (pokemon: Pokemon, player: Player, item: Item) => Pkm
divergentEvolution?: DivergentEvolution
) {
super(divergentEvolution)
this.itemsTriggeringEvolution = itemsTriggeringEvolution
Expand Down
6 changes: 3 additions & 3 deletions app/core/pokemon-entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1225,15 +1225,15 @@ export class PokemonEntity extends Schema implements IPokemonEntity {
}, 16) // delay to next tick, targeting 60 ticks per second
}

if (this.passive === Passive.CORSOLA) {
if (this.passive === Passive.CORSOLA && this.player) {
const galarCorsola = this.refToBoardPokemon.evolutionRule.evolve(
this.refToBoardPokemon as Pokemon,
this.player!,
this.player,
this.simulation.stageLevel
)
galarCorsola.evolutionRule.tryEvolve(
galarCorsola,
this.player!,
this.player,
this.simulation.stageLevel
)
}
Expand Down
21 changes: 17 additions & 4 deletions app/models/colyseus-models/pokemon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5401,6 +5401,7 @@ function updateCastform(pokemon: Pokemon, weather: Weather, player: Player) {
}

if (pokemon.name === weatherForm) return
if(!player) return

const newPokemon = PokemonFactory.createPokemonFromName(weatherForm, player)
pokemon.items.forEach((item) => {
Expand All @@ -5427,7 +5428,10 @@ export class Castform extends Pokemon {
passive = Passive.CASTFORM
attackSprite = AttackSprite.PSYCHIC_RANGE

beforeSimulationStart({ weather, player }) {
beforeSimulationStart({
weather,
player
}: { weather: Weather; player: Player }) {
updateCastform(this, weather, player)
}
}
Expand All @@ -5450,7 +5454,10 @@ export class CastformSun extends Pokemon {
passive = Passive.CASTFORM
attackSprite = AttackSprite.DRAGON_RANGE

beforeSimulationStart({ weather, player }) {
beforeSimulationStart({
weather,
player
}: { weather: Weather; player: Player }) {
updateCastform(this, weather, player)
}
}
Expand All @@ -5473,7 +5480,10 @@ export class CastformRain extends Pokemon {
passive = Passive.CASTFORM
attackSprite = AttackSprite.WATER_RANGE

beforeSimulationStart({ weather, player }) {
beforeSimulationStart({
weather,
player
}: { weather: Weather; player: Player }) {
updateCastform(this, weather, player)
}
}
Expand All @@ -5496,7 +5506,10 @@ export class CastformHail extends Pokemon {
passive = Passive.CASTFORM
attackSprite = AttackSprite.ICE_RANGE

beforeSimulationStart({ weather, player }) {
beforeSimulationStart({
weather,
player
}: { weather: Weather; player: Player }) {
updateCastform(this, weather, player)
}
}
Expand Down

0 comments on commit f225629

Please sign in to comment.