mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-01-30 20:57:13 +00:00
Adds New BattleSceneEventTypes (#1372)
* Add BattleSceneEvents * Update battle-scene-events.ts
This commit is contained in:
parent
97d8275417
commit
5c28e1fb11
@ -1,11 +1,31 @@
|
||||
import Move from "./data/move";
|
||||
|
||||
/** Alias for all {@linkcode BattleScene} events */
|
||||
export enum BattleSceneEventType {
|
||||
MOVE_USED = "onMoveUsed"
|
||||
/**
|
||||
* Triggers when a move is successfully used
|
||||
* @see {@linkcode MoveUsedEvent}
|
||||
*/
|
||||
MOVE_USED = "onMoveUsed",
|
||||
/**
|
||||
* Triggers on the first turn of a new battle
|
||||
* @see {@linkcode TurnInitEvent}
|
||||
*/
|
||||
TURN_INIT = "onTurnInit",
|
||||
/**
|
||||
* Triggers after a turn ends in battle
|
||||
* @see {@linkcode TurnEndEvent}
|
||||
*/
|
||||
TURN_END = "onTurnEnd",
|
||||
/**
|
||||
* Triggers when a new {@linkcode Arena} is created during initialization
|
||||
* @see {@linkcode NewArenaEvent}
|
||||
*/
|
||||
NEW_ARENA = "onNewArena",
|
||||
}
|
||||
|
||||
/**
|
||||
* Container class for `onMoveUsed` events
|
||||
* Container class for {@linkcode BattleSceneEventType.MOVE_USED} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class MoveUsedEvent extends Event {
|
||||
@ -23,3 +43,34 @@ export class MoveUsedEvent extends Event {
|
||||
this.ppUsed = ppUsed;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.TURN_INIT} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class TurnInitEvent extends Event {
|
||||
constructor() {
|
||||
super(BattleSceneEventType.TURN_INIT);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.TURN_END} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class TurnEndEvent extends Event {
|
||||
/** The amount of turns in the current battle */
|
||||
public turnCount: number;
|
||||
constructor(turnCount: number) {
|
||||
super(BattleSceneEventType.TURN_END);
|
||||
|
||||
this.turnCount = turnCount;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Container class for {@linkcode BattleSceneEventType.NEW_ARENA} events
|
||||
* @extends Event
|
||||
*/
|
||||
export class NewArenaEvent extends Event {
|
||||
constructor() {
|
||||
super(BattleSceneEventType.NEW_ARENA);
|
||||
}
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ import { Localizable } from "./plugins/i18n";
|
||||
import * as Overrides from "./overrides";
|
||||
import {InputsController} from "./inputs-controller";
|
||||
import {UiInputs} from "./ui-inputs";
|
||||
import { NewArenaEvent } from "./battle-scene-events";
|
||||
|
||||
export const bypassLogin = import.meta.env.VITE_BYPASS_LOGIN === "1";
|
||||
|
||||
@ -995,6 +996,7 @@ export default class BattleScene extends SceneBase {
|
||||
|
||||
newArena(biome: Biome): Arena {
|
||||
this.arena = new Arena(this, biome, Biome[biome].toLowerCase());
|
||||
this.eventTarget.dispatchEvent(new NewArenaEvent());
|
||||
|
||||
this.arenaBg.pipelineData = { terrainColorRatio: this.arena.getBgTerrainColorRatioForBiome() };
|
||||
|
||||
|
@ -61,7 +61,7 @@ import { Abilities } from "./data/enums/abilities";
|
||||
import * as Overrides from "./overrides";
|
||||
import { TextStyle, addTextObject } from "./ui/text";
|
||||
import { Type } from "./data/type";
|
||||
import { MoveUsedEvent } from "./battle-scene-events";
|
||||
import { MoveUsedEvent, TurnEndEvent, TurnInitEvent } from "./battle-scene-events";
|
||||
|
||||
|
||||
export class LoginPhase extends Phase {
|
||||
@ -1719,6 +1719,7 @@ export class TurnInitPhase extends FieldPhase {
|
||||
super.start();
|
||||
|
||||
//this.scene.pushPhase(new MoveAnimTestPhase(this.scene));
|
||||
this.scene.eventTarget.dispatchEvent(new TurnInitEvent());
|
||||
|
||||
this.scene.getField().forEach((pokemon, i) => {
|
||||
if (pokemon?.isActive()) {
|
||||
@ -2252,6 +2253,7 @@ export class TurnEndPhase extends FieldPhase {
|
||||
super.start();
|
||||
|
||||
this.scene.currentBattle.incrementTurn(this.scene);
|
||||
this.scene.eventTarget.dispatchEvent(new TurnEndEvent(this.scene.currentBattle.turn));
|
||||
|
||||
const handlePokemon = (pokemon: Pokemon) => {
|
||||
pokemon.lapseTags(BattlerTagLapseType.TURN_END);
|
||||
|
Loading…
x
Reference in New Issue
Block a user