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