mirror of
https://github.com/pagefaultgames/pokerogue.git
synced 2025-08-10 17:39:31 +02:00
Added logging blacklist for ActivatePriorityQueuePhase
This commit is contained in:
parent
62aea1ad8d
commit
8e729d9955
@ -6,12 +6,18 @@ import { UiMode } from "#enums/ui-mode";
|
||||
// biome-ignore-start lint/correctness/noUnusedImports: TSDoc imports
|
||||
import type { GameManager } from "#test/test-utils/game-manager";
|
||||
import type { PromptHandler } from "#test/test-utils/helpers/prompt-handler";
|
||||
import { setTimeout } from "timers/promises";
|
||||
// biome-ignore-end lint/correctness/noUnusedImports: TSDoc imports
|
||||
import { format } from "util";
|
||||
import chalk from "chalk";
|
||||
import { vi } from "vitest";
|
||||
|
||||
/**
|
||||
* A Set containing phase names that will not be shown in the console when started.
|
||||
*
|
||||
* Used to reduce console noise from very repetitive phases.
|
||||
*/
|
||||
const blacklistedPhaseNames: ReadonlySet<PhaseString> = new Set(["ActivatePriorityQueuePhase"]);
|
||||
|
||||
/**
|
||||
* The interceptor's current state.
|
||||
* Possible values are the following:
|
||||
@ -28,8 +34,8 @@ type StateType = "running" | "interrupted" | "idling";
|
||||
export class PhaseInterceptor {
|
||||
private scene: BattleScene;
|
||||
/**
|
||||
* A log of phases having been executed.
|
||||
* Entries are appended each time {@linkcode run} is called, and can be cleared with {@linkcode clearLogs}.
|
||||
* A log containing all phases having been executed in FIFO order. \
|
||||
* Entries are appended each time {@linkcode run} is called, and can be cleared manually with {@linkcode clearLogs}.
|
||||
*/
|
||||
public log: PhaseString[] = [];
|
||||
/**
|
||||
@ -181,9 +187,10 @@ export class PhaseInterceptor {
|
||||
/**
|
||||
* Deprecated no-op function.
|
||||
*
|
||||
* This was previously used to reset timers created using `setInterval` on test end.
|
||||
* However, since we now use standard async functions to run phases,
|
||||
* this function has become a no-op.
|
||||
* This was previously used to reset timers created using `setInterval` to wait for phase end
|
||||
* and undo various method stubs upon a test ending. \
|
||||
* However, since we now use {@linkcode vi.waitUntil} and {@linkcode vi.spyOn} to perform these tasks
|
||||
* respectively, this function has become no longer needed.
|
||||
* @deprecated This is no longer needed and will be removed in a future PR
|
||||
*/
|
||||
public restoreOg() {}
|
||||
@ -193,23 +200,24 @@ export class PhaseInterceptor {
|
||||
* @param phaseName - The name of the phase to log.
|
||||
*/
|
||||
private logPhase(phaseName: PhaseString) {
|
||||
this.doLog(`Start Phase ${phaseName}`);
|
||||
if (!blacklistedPhaseNames.has(phaseName)) {
|
||||
this.doLog(`Starting Phase: ${phaseName}`);
|
||||
}
|
||||
this.log.push(phaseName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears phase logs
|
||||
* Clear all prior phase logs.
|
||||
*/
|
||||
public clearLogs(): void {
|
||||
this.log = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrapper function to add green coloration to phase logs.
|
||||
* Wrapper function to add coral coloration to phase logs.
|
||||
* @param args - Arguments to original logging function.
|
||||
*/
|
||||
private doLog(...args: unknown[]): void {
|
||||
// Use chalk highlighting instead of normal green due to Node.js not respecting `%c` CSS color setting
|
||||
console.log(chalk.green(...args));
|
||||
console.log(chalk.hex("#ff7f50")(...args));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user