refac: rsc -> rc

This commit is contained in:
2024-03-15 16:13:27 +00:00
parent 6a6bdba08b
commit 78bcc95e2e
10 changed files with 46 additions and 46 deletions
+11 -11
View File
@@ -44,15 +44,15 @@ export class GameEngine {
api: new Denque<ActionRequestContainer>(),
} as const satisfies Record<QueueType, Denque<ActionRequestContainer>>;
private rsc: ResourceController
private rc: ResourceController
private loggerEngine: GameLoggerEngine;
private constructor(
db: Mongoose,
private postStatus: (msg: GameEngineMsg) => void,
) {
this.rsc = new ResourceController(db);
this.loggerEngine = GameLoggerEngine.initInstance(this.rsc);
this.rc = new ResourceController(db);
this.loggerEngine = GameLoggerEngine.initInstance(this.rc);
}
private continueRun = true;
@@ -67,7 +67,7 @@ export class GameEngine {
while (true) {
//장수턴 부터 처리
const upcomingGeneral = this.rsc.popGeneralTurnTimeQueue();
const upcomingGeneral = this.rc.popGeneralTurnTimeQueue();
if (!upcomingGeneral) {
break;
}
@@ -80,8 +80,8 @@ export class GameEngine {
//TODO: 턴 수행해야지!
upcomingGeneral.updateTurnTime();
this.rsc.insertGeneralTurnTimeQueue(upcomingGeneral, true);
this.rsc.gameEnv.update((env) => {
this.rc.insertGeneralTurnTimeQueue(upcomingGeneral, true);
this.rc.gameEnv.update((env) => {
env.lastExecuted = generalTurnTime;
})
processedGeneralCount++;
@@ -89,9 +89,9 @@ export class GameEngine {
if (processedGeneralCount > 0) {
await this.prevSaveWaiter;
const lastExecuted = this.rsc.gameEnv.raw.lastExecuted;
const lastExecuted = this.rc.gameEnv.raw.lastExecuted;
this.loggerEngine.flushAll();
this.prevSaveWaiter = this.rsc.saveAll().then(() => {
this.prevSaveWaiter = this.rc.saveAll().then(() => {
this.postStatus({
type: 'update',
lastExecuted: lastExecuted.toISOString()
@@ -136,7 +136,7 @@ export class GameEngine {
await this.prevSaveWaiter;
this.prevSaveWaiter = null;
this.loggerEngine.flushAll();
await this.rsc.saveAll();
await this.rc.saveAll();
for (const response of responseQueue) {
response();
}
@@ -151,7 +151,7 @@ export class GameEngine {
//가장 빠른 장수
do {
const now = new Date();
const upcomingGeneral = this.rsc.peekGeneralTurnTimeQueue();
const upcomingGeneral = this.rc.peekGeneralTurnTimeQueue();
if (!upcomingGeneral) {
break;
}
@@ -244,7 +244,7 @@ export class GameEngine {
const actionArgs = action.args;
try{
const result = ActionRequestList[actionName](invoker, actionArgs as any, this.rsc);
const result = ActionRequestList[actionName](invoker, actionArgs as any, this.rc);
return {
success: true,
value: result