mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-08 16:39:26 +02:00
Fixed issues and syntax errors
This commit is contained in:
parent
9a19eac9ee
commit
1819712201
@ -178,9 +178,10 @@ export class GameManager {
|
|||||||
async runToTitle(): Promise<void> {
|
async runToTitle(): Promise<void> {
|
||||||
// Go to login phase and skip past it
|
// Go to login phase and skip past it
|
||||||
await this.phaseInterceptor.to("LoginPhase", false);
|
await this.phaseInterceptor.to("LoginPhase", false);
|
||||||
this.phaseInterceptor.shiftPhase();
|
this.phaseInterceptor.shiftPhase(true);
|
||||||
await this.phaseInterceptor.to("TitlePhase");
|
await this.phaseInterceptor.to("TitlePhase");
|
||||||
|
|
||||||
|
// TODO: This should be moved to a separate initialization method
|
||||||
this.scene.gameSpeed = 5;
|
this.scene.gameSpeed = 5;
|
||||||
this.scene.moveAnimations = false;
|
this.scene.moveAnimations = false;
|
||||||
this.scene.showLevelUpStats = false;
|
this.scene.showLevelUpStats = false;
|
||||||
|
@ -91,8 +91,13 @@ interface InProgressStub {
|
|||||||
|
|
||||||
export class PhaseInterceptor {
|
export class PhaseInterceptor {
|
||||||
public scene: BattleScene;
|
public scene: BattleScene;
|
||||||
public phases: Record<PhaseClass, PhaseStub> = {};
|
// @ts-expect-error: initialized in `initPhases`
|
||||||
|
public phases: Record<PhaseString, PhaseStub> = {};
|
||||||
public log: PhaseString[];
|
public log: PhaseString[];
|
||||||
|
/**
|
||||||
|
* TODO: This should not be an array;
|
||||||
|
* Our linear phase system means only 1 phase is ever started at once (if any)
|
||||||
|
*/
|
||||||
private onHold: PhaseClass[];
|
private onHold: PhaseClass[];
|
||||||
private interval: NodeJS.Timeout;
|
private interval: NodeJS.Timeout;
|
||||||
private promptInterval: NodeJS.Timeout;
|
private promptInterval: NodeJS.Timeout;
|
||||||
@ -225,11 +230,12 @@ export class PhaseInterceptor {
|
|||||||
this.intervalRun = setInterval(async () => {
|
this.intervalRun = setInterval(async () => {
|
||||||
const currentPhase = this.onHold?.length && this.onHold[0];
|
const currentPhase = this.onHold?.length && this.onHold[0];
|
||||||
if (!currentPhase) {
|
if (!currentPhase) {
|
||||||
// No current phase = interrupted by prompt; wait for phase to finish
|
// No current phase means the manager either hasn't started yet
|
||||||
|
// or we were interrupted by prompt; wait for phase to finish
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If current phase is different, do nothing.
|
// If current phase is different, run it and wait for it to finish.
|
||||||
if (currentPhase.name !== targetName) {
|
if (currentPhase.name !== targetName) {
|
||||||
await this.run().catch(e => {
|
await this.run().catch(e => {
|
||||||
clearInterval(this.intervalRun);
|
clearInterval(this.intervalRun);
|
||||||
@ -319,13 +325,7 @@ export class PhaseInterceptor {
|
|||||||
*/
|
*/
|
||||||
startPhase(phase: PhaseClass) {
|
startPhase(phase: PhaseClass) {
|
||||||
this.log.push(phase.name as PhaseString);
|
this.log.push(phase.name as PhaseString);
|
||||||
const instance = this.scene.phaseManager.getCurrentPhase();
|
this.onHold.push(phase);
|
||||||
this.onHold.push({
|
|
||||||
name: phase.name,
|
|
||||||
call: () => {
|
|
||||||
this.phases[phase.name].start.apply(instance);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user