mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-09-23 15:03:24 +02:00
Fix terrain & weather max duration flyout
This commit is contained in:
parent
e25db16326
commit
868a5d6157
@ -22,10 +22,12 @@ export interface SerializedTerrain {
|
||||
export class Terrain {
|
||||
public terrainType: TerrainType;
|
||||
public turnsLeft: number;
|
||||
public maxDuration: number;
|
||||
|
||||
constructor(terrainType: TerrainType, turnsLeft?: number) {
|
||||
constructor(terrainType: TerrainType, turnsLeft?: number, maxDuration?: number) {
|
||||
this.terrainType = terrainType;
|
||||
this.turnsLeft = turnsLeft || 0;
|
||||
this.maxDuration = maxDuration || turnsLeft || 0;
|
||||
}
|
||||
|
||||
lapse(): boolean {
|
||||
|
@ -19,10 +19,12 @@ export interface SerializedWeather {
|
||||
export class Weather {
|
||||
public weatherType: WeatherType;
|
||||
public turnsLeft: number;
|
||||
public maxDuration: number;
|
||||
|
||||
constructor(weatherType: WeatherType, turnsLeft?: number) {
|
||||
constructor(weatherType: WeatherType, turnsLeft?: number, maxDuration?: number) {
|
||||
this.weatherType = weatherType;
|
||||
this.turnsLeft = !this.isImmutable() ? turnsLeft || 0 : 0;
|
||||
this.maxDuration = !this.isImmutable() ? maxDuration || turnsLeft || 0 : 0;
|
||||
}
|
||||
|
||||
lapse(): boolean {
|
||||
|
@ -20,10 +20,13 @@ export enum ArenaEventType {
|
||||
export class ArenaEvent extends Event {
|
||||
/** The total duration of the {@linkcode ArenaEventType} */
|
||||
public duration: number;
|
||||
constructor(eventType: ArenaEventType, duration: number) {
|
||||
/** The maximum duration of the {@linkcode ArenaEventType} */
|
||||
public maxDuration: number;
|
||||
constructor(eventType: ArenaEventType, duration: number, maxDuration: number) {
|
||||
super(eventType);
|
||||
|
||||
this.duration = duration;
|
||||
this.maxDuration = maxDuration || duration;
|
||||
}
|
||||
}
|
||||
/** Container class for {@linkcode ArenaEventType.WEATHER_CHANGED} events */
|
||||
@ -32,8 +35,8 @@ export class WeatherChangedEvent extends ArenaEvent {
|
||||
public oldWeatherType: WeatherType;
|
||||
/** The {@linkcode WeatherType} being set */
|
||||
public newWeatherType: WeatherType;
|
||||
constructor(oldWeatherType: WeatherType, newWeatherType: WeatherType, duration: number) {
|
||||
super(ArenaEventType.WEATHER_CHANGED, duration);
|
||||
constructor(oldWeatherType: WeatherType, newWeatherType: WeatherType, duration: number, maxDuration: number) {
|
||||
super(ArenaEventType.WEATHER_CHANGED, duration, maxDuration);
|
||||
|
||||
this.oldWeatherType = oldWeatherType;
|
||||
this.newWeatherType = newWeatherType;
|
||||
@ -45,8 +48,8 @@ export class TerrainChangedEvent extends ArenaEvent {
|
||||
public oldTerrainType: TerrainType;
|
||||
/** The {@linkcode TerrainType} being set */
|
||||
public newTerrainType: TerrainType;
|
||||
constructor(oldTerrainType: TerrainType, newTerrainType: TerrainType, duration: number) {
|
||||
super(ArenaEventType.TERRAIN_CHANGED, duration);
|
||||
constructor(oldTerrainType: TerrainType, newTerrainType: TerrainType, duration: number, maxDuration: number) {
|
||||
super(ArenaEventType.TERRAIN_CHANGED, duration, maxDuration);
|
||||
|
||||
this.oldTerrainType = oldTerrainType;
|
||||
this.newTerrainType = newTerrainType;
|
||||
|
@ -344,9 +344,14 @@ export class Arena {
|
||||
globalScene.applyModifier(FieldEffectModifier, user.isPlayer(), user, weatherDuration);
|
||||
}
|
||||
|
||||
this.weather = weather ? new Weather(weather, weatherDuration.value) : null;
|
||||
this.weather = weather ? new Weather(weather, weatherDuration.value, weatherDuration.value) : null;
|
||||
this.eventTarget.dispatchEvent(
|
||||
new WeatherChangedEvent(oldWeatherType, this.weather?.weatherType!, this.weather?.turnsLeft!),
|
||||
new WeatherChangedEvent(
|
||||
oldWeatherType,
|
||||
this.weather?.weatherType!,
|
||||
this.weather?.turnsLeft!,
|
||||
this.weather?.turnsLeft!,
|
||||
),
|
||||
); // TODO: is this bang correct?
|
||||
|
||||
if (this.weather) {
|
||||
@ -425,10 +430,15 @@ export class Arena {
|
||||
globalScene.applyModifier(FieldEffectModifier, user.isPlayer(), user, terrainDuration);
|
||||
}
|
||||
|
||||
this.terrain = terrain ? new Terrain(terrain, terrainDuration.value) : null;
|
||||
this.terrain = terrain ? new Terrain(terrain, terrainDuration.value, terrainDuration.value) : null;
|
||||
|
||||
this.eventTarget.dispatchEvent(
|
||||
new TerrainChangedEvent(oldTerrainType, this.terrain?.terrainType!, this.terrain?.turnsLeft!),
|
||||
new TerrainChangedEvent(
|
||||
oldTerrainType,
|
||||
this.terrain?.terrainType!,
|
||||
this.terrain?.turnsLeft!,
|
||||
this.terrain?.turnsLeft!,
|
||||
),
|
||||
); // TODO: are those bangs correct?
|
||||
|
||||
if (this.terrain) {
|
||||
|
@ -47,8 +47,12 @@ export class ArenaData {
|
||||
}
|
||||
|
||||
this.biome = source.biome;
|
||||
this.weather = source.weather ? new Weather(source.weather.weatherType, source.weather.turnsLeft) : null;
|
||||
this.terrain = source.terrain ? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft) : null;
|
||||
this.weather = source.weather
|
||||
? new Weather(source.weather.weatherType, source.weather.turnsLeft, source.weather.maxDuration)
|
||||
: null;
|
||||
this.terrain = source.terrain
|
||||
? new Terrain(source.terrain.terrainType, source.terrain.turnsLeft, source.terrain.maxDuration)
|
||||
: null;
|
||||
this.positionalTags = source.positionalTags ?? [];
|
||||
}
|
||||
}
|
||||
|
@ -1021,6 +1021,7 @@ export class GameData {
|
||||
WeatherType.NONE,
|
||||
globalScene.arena.weather?.weatherType!,
|
||||
globalScene.arena.weather?.turnsLeft!,
|
||||
globalScene.arena.weather?.maxDuration!,
|
||||
),
|
||||
); // TODO: is this bang correct?
|
||||
|
||||
@ -1030,6 +1031,7 @@ export class GameData {
|
||||
TerrainType.NONE,
|
||||
globalScene.arena.terrain?.terrainType!,
|
||||
globalScene.arena.terrain?.turnsLeft!,
|
||||
globalScene.arena.terrain?.maxDuration!,
|
||||
),
|
||||
); // TODO: is this bang correct?
|
||||
|
||||
|
@ -353,7 +353,7 @@ export class ArenaFlyout extends Phaser.GameObjects.Container {
|
||||
),
|
||||
effectType:
|
||||
fieldEffectChangedEvent instanceof WeatherChangedEvent ? ArenaEffectType.WEATHER : ArenaEffectType.TERRAIN,
|
||||
maxDuration: fieldEffectChangedEvent.duration,
|
||||
maxDuration: fieldEffectChangedEvent.maxDuration,
|
||||
duration: fieldEffectChangedEvent.duration,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user