변수명 재정의

This commit is contained in:
2024-03-11 17:05:00 +00:00
parent 28b78e0872
commit d40995e1d9
15 changed files with 63 additions and 59 deletions
+8 -8
View File
@@ -65,22 +65,22 @@ export class GameEngine {
while (true) {
//장수턴 부터 처리
const upcomingGeneral = this.rsc.popGeneralTurntimeQueue();
const upcomingGeneral = this.rsc.popGeneralTurnTimeQueue();
if (!upcomingGeneral) {
break;
}
const generalTurntime = upcomingGeneral.raw.turntime;
if (generalTurntime > now) {
const generalTurnTime = upcomingGeneral.raw.turnTime;
if (generalTurnTime > now) {
break;
}
//TODO: 턴 수행해야지!
upcomingGeneral.updateTurntime();
this.rsc.insertGeneralTurntimeQueue(upcomingGeneral, true);
upcomingGeneral.updateTurnTime();
this.rsc.insertGeneralTurnTimeQueue(upcomingGeneral, true);
this.rsc.gameEnv().update((env) => {
env.lastExecuted = generalTurntime;
env.lastExecuted = generalTurnTime;
})
processedGeneralCount++;
}
@@ -147,11 +147,11 @@ export class GameEngine {
//가장 빠른 장수
do {
const now = new Date();
const upcomingGeneral = this.rsc.peekGeneralTurntimeQueue();
const upcomingGeneral = this.rsc.peekGeneralTurnTimeQueue();
if (!upcomingGeneral) {
break;
}
const upcomingTurn = upcomingGeneral.raw.turntime;
const upcomingTurn = upcomingGeneral.raw.turnTime;
const waitGeneralTurnMs = upcomingTurn.getTime() - now.getTime();
if (waitGeneralTurnMs > 0) {
+11 -11
View File
@@ -4,7 +4,7 @@ import type { CityID, GeneralID, NationID, SquadID } from "@sammo/game_logic/src
import type { IGeneralEntity } from "@sammo/game_logic/src/Entity/GeneralEntity.js";
import type { ICityEntity, ValidEntityType } from "@sammo/game_logic/src/Entity/index.js";
import type { INationEntity } from "@sammo/game_logic/src/Entity/NationEntity.js";
import type { IReservedTurn } from "@sammo/game_logic/src/Entity/ReservedTurn.js";
import type { ReservedTurn } from "@sammo/game_logic/src/defs.js";
import type { ISquadEntity } from "@sammo/game_logic/src/Entity/SquadEntity.js";
import type { GameEnv } from "@sammo/game_logic/src/GameEnv.js";
import { General } from "@sammo/game_logic/src/General.js";
@@ -30,8 +30,8 @@ export class ResourceController implements IResourceController{
private _squad: Map<number, Squad> = new Map();
private _general: Map<number, General> = new Map();
//내부적으로 turntime asc, id asc로 동작하는 PriorityQueue
private _generalByTurntime = new Denque<General>();
//내부적으로 turnTime asc, id asc로 동작하는 PriorityQueue
private _generalByTurnTime = new Denque<General>();
@@ -60,16 +60,16 @@ export class ResourceController implements IResourceController{
throw new NotYetImplemented();
}
peekGeneralTurntimeQueue(): General | undefined {
return this._generalByTurntime.peekFront();
peekGeneralTurnTimeQueue(): General | undefined {
return this._generalByTurnTime.peekFront();
}
popGeneralTurntimeQueue(): General | undefined {
return this._generalByTurntime.shift();
popGeneralTurnTimeQueue(): General | undefined {
return this._generalByTurnTime.shift();
}
insertGeneralTurntimeQueue(general: General, maybeTail: boolean): void {
insertItemAtArrayLike(this._generalByTurntime, general, (a, b)=>a.compareTurntime(b), maybeTail);
insertGeneralTurnTimeQueue(general: General, maybeTail: boolean): void {
insertItemAtArrayLike(this._generalByTurnTime, general, (a, b)=>a.compareTurnTime(b), maybeTail);
}
gameEnv(): GameEnv {
@@ -150,11 +150,11 @@ export class ResourceController implements IResourceController{
//---- DB 접근 ---
getReservedTurn(general: General): Promise<IReservedTurn> {
getReservedTurn(general: General): Promise<ReservedTurn> {
throw new NotYetImplemented();
}
nationReservedTurn(general: General): Promise<IReservedTurn | undefined> {
nationReservedTurn(general: General): Promise<ReservedTurn | undefined> {
throw new NotYetImplemented();
}