LoggerEngine을 이어붙이기

This commit is contained in:
2024-03-12 16:57:02 +00:00
parent cdfaac773a
commit 533400b1b9
3 changed files with 15 additions and 2 deletions
+5 -1
View File
@@ -5,7 +5,7 @@ import { entriesWithType } from "@sammo/util/converter";
import db from "./connectDB.js";
import type { Mongoose } from "mongoose";
import type { ActionPack, GameEngineMsg } from "./GameEngineDefs.js";
import { ActionRequestList, type QueueType } from "@sammo/game_logic";
import { ActionRequestList, GameLoggerEngine, type QueueType } from "@sammo/game_logic";
export interface ActionRequest {
name: keyof ActionPack;
args: Parameters<ActionPack[keyof ActionPack]>[1];
@@ -45,12 +45,14 @@ export class GameEngine {
} as const satisfies Record<QueueType, Denque<ActionRequestContainer>>;
private rsc: ResourceController
private loggerEngine: GameLoggerEngine;
private constructor(
db: Mongoose,
private postStatus: (msg: GameEngineMsg) => void,
) {
this.rsc = new ResourceController(db);
this.loggerEngine = GameLoggerEngine.initInstance(this.rsc);
}
private continueRun = true;
@@ -88,6 +90,7 @@ export class GameEngine {
if (processedGeneralCount > 0) {
await this.prevSaveWaiter;
const lastExecuted = this.rsc.gameEnv().raw.lastExecuted;
this.loggerEngine.flushAll();
this.prevSaveWaiter = this.rsc.saveAll().then(() => {
this.postStatus({
type: 'update',
@@ -132,6 +135,7 @@ export class GameEngine {
if (processEventCount > 0) {
await this.prevSaveWaiter;
this.prevSaveWaiter = null;
this.loggerEngine.flushAll();
await this.rsc.saveAll();
for (const response of responseQueue) {
response();