변수명 재정의
This commit is contained in:
@@ -34,7 +34,7 @@ export function createGeneral(invoker: QueueType, arg: {
|
||||
pic: string
|
||||
character: string
|
||||
|
||||
turntimeZone?: number,
|
||||
turnTimeZone?: number,
|
||||
warSpecial?: string,
|
||||
city?: CityID,
|
||||
bonusStat?: [number, number, number],
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CityID, CityLevel, CityName, CityOfficerLevel, CityState, FrontStatus, NationID, FractionalRange, RegionID, RemainMonth } from "../defs.js";
|
||||
import type { CityID, CityLevel, CityName, CityOfficerLevel, CityState, FrontStatus, NationID, FractionalRange, RegionID, IntMonth } from "../defs.js";
|
||||
|
||||
|
||||
export interface ICityEntity{
|
||||
@@ -73,8 +73,8 @@ export interface ICityEntity{
|
||||
|
||||
state: CityState;
|
||||
//전투 잔여 개월
|
||||
remainWarMonth: RemainMonth;
|
||||
remainWarMonth: IntMonth;
|
||||
|
||||
//국가별 수비병 사살 수
|
||||
conflict: Record<NationID, number>;
|
||||
cityDamageRatio: Record<NationID, number>;
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { NationID } from "@/defs.js";
|
||||
import type { GeneralID, GeneralName, NationID } from "@/defs.js";
|
||||
|
||||
export interface IDiplomaticLetter {
|
||||
_id: string;
|
||||
@@ -11,13 +11,13 @@ export interface IDiplomaticLetter {
|
||||
state: 'proposed' | 'accepted' | 'rejected' | 'canceled' | 'replaced';
|
||||
|
||||
srcSigner: {
|
||||
generalID: string;
|
||||
generalName: string;
|
||||
generalID: GeneralID;
|
||||
generalName: GeneralName;
|
||||
icon: string;
|
||||
};
|
||||
destSigner: {
|
||||
generalID: string;
|
||||
generalName: string;
|
||||
generalID: GeneralID;
|
||||
generalName: GeneralName;
|
||||
icon: string;
|
||||
};
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export interface IGameEnvEntity {
|
||||
|
||||
secondsPerTurn: number;
|
||||
|
||||
refreshedKillTurn: number;
|
||||
numberOfIdleTurnTillDeath: number;
|
||||
|
||||
isFictionMode: boolean;
|
||||
unitedGameState: UnitedGameState;
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import type { CityID, DiplomaticPermission, GeneralID, GeneralName, ItemID, ItemKeyType, NationID, NpcType, OfficerLevel, PersonalityType, SpecialityDomesticType, SpecialityWarType, SquadID, UserID, UserName } from "../defs.js";
|
||||
import type { CityID, DiplomaticPermission, FractionalRange, GeneralID, GeneralName, IntMonth, IntYear, ItemID, ItemKeyType, NationID, NpcType, OfficerLevel, PersonalityType, SpecialityDomesticType, SpecialityWarType, SquadID, URILike, UserID, UserName } from "../defs.js";
|
||||
|
||||
export interface IGeneralEntity {
|
||||
id: GeneralID;
|
||||
ownerID?: UserID;
|
||||
npcType: NpcType;
|
||||
affinity?: number;
|
||||
icon?: string;
|
||||
icon?: URILike;
|
||||
name: GeneralName;
|
||||
ownerName?: UserName;
|
||||
nationID: NationID;
|
||||
@@ -19,7 +19,7 @@ export interface IGeneralEntity {
|
||||
intel: number;
|
||||
intelExp: number;
|
||||
|
||||
injury: number;
|
||||
injury: FractionalRange;
|
||||
|
||||
experience: number;
|
||||
dedication: number;
|
||||
@@ -42,14 +42,14 @@ export interface IGeneralEntity {
|
||||
option: Record<string, unknown>,
|
||||
}>;
|
||||
|
||||
turntime: Date;
|
||||
turnTime: Date;
|
||||
|
||||
killturn: number;
|
||||
idleTurn: IntMonth;
|
||||
|
||||
age: number;
|
||||
startAge: number;
|
||||
age: IntYear;
|
||||
startAge: IntYear;
|
||||
|
||||
nationBelong: number;
|
||||
nationJoinedRelYear: IntYear;
|
||||
|
||||
betray: number;
|
||||
|
||||
|
||||
@@ -14,14 +14,14 @@ export interface IGeneralRankEntity {
|
||||
battleLoseCnt: number;
|
||||
|
||||
//누적 병력 사망 수
|
||||
crewDeathCnt: number;
|
||||
allDeathCnt: number;
|
||||
//누적 병력 사살 수
|
||||
crewKillCnt: number;
|
||||
allKillCnt: number;
|
||||
|
||||
//누적 대인 병력 사망 수
|
||||
crewDeathCntByGeneral: number;
|
||||
armyDeathCnt: number;
|
||||
//누적 대인 병력 사살 수
|
||||
crewKillCntByGeneral: number;
|
||||
armyKillCnt: number;
|
||||
|
||||
//점령 수
|
||||
occupyCnt: number;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { CityID, ColorType, IntYearMonth, NationCmdType, NationID, NationLevel, NationName, NationType, FractionalRange, RemainMonth, ReservedTurn, StaffLevel, StrategicCmdType } from "../defs.js";
|
||||
import type { CityID, ColorType, IntYearMonth, NationCmdType, NationID, NationLevel, NationName, NationType, FractionalRange, IntMonth, ReservedTurn, StaffLevel, StrategicCmdType } from "../defs.js";
|
||||
|
||||
export interface INationEntity{
|
||||
id: NationID;
|
||||
@@ -40,7 +40,7 @@ export interface INationEntity{
|
||||
power: number;
|
||||
|
||||
//첩보 제한
|
||||
spyLimit: Map<CityID, RemainMonth>;
|
||||
spyLimit: Map<CityID, IntMonth>;
|
||||
|
||||
//커맨드별 옵션
|
||||
commandOption: Map<NationCmdType, Map<string, unknown>>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { GeneralID, GeneralName, ItemID, ItemKeyType, NationID, NpcType, OfficerLevel, PersonalityType, ServerID, SpecialityDomesticType, SpecialityWarType, UserID } from "@/defs.js";
|
||||
import type { GeneralID, GeneralName, ItemID, ItemKeyType, NationID, NpcType, OfficerLevel, PersonalityType, ServerID, SpecialityDomesticType, SpecialityWarType, URILike, UserID } from "@/defs.js";
|
||||
import type { INationEntity } from "../NationEntity.js";
|
||||
|
||||
export interface IOldNation {
|
||||
@@ -20,7 +20,7 @@ export interface IOldNation {
|
||||
ownerName?: string;
|
||||
|
||||
npcType?: NpcType;
|
||||
icon?: string;
|
||||
icon?: URILike;
|
||||
|
||||
officerLevel: OfficerLevel;
|
||||
officerCityID?: number;
|
||||
|
||||
@@ -12,7 +12,7 @@ import { addSeconds } from "date-fns";
|
||||
|
||||
export class General extends LazyEntityUpdater<IGeneralEntity> {
|
||||
protected readonly _indirectNames: (keyof IGeneralEntity)[] = [
|
||||
"id", "nationID", "squadID", "nationID", "turntime"
|
||||
"id", "nationID", "squadID", "nationID", "turnTime"
|
||||
];
|
||||
protected readonly _entityType = "General";
|
||||
protected readonly _raw: IGeneralEntity;
|
||||
@@ -142,24 +142,24 @@ export class General extends LazyEntityUpdater<IGeneralEntity> {
|
||||
else{
|
||||
raw.officerLevel = OfficerLevel.normal;
|
||||
}
|
||||
raw.nationBelong = 0;
|
||||
raw.nationJoinedRelYear = 0;
|
||||
});
|
||||
}
|
||||
|
||||
public updateTurntime(){
|
||||
public updateTurnTime(){
|
||||
const secondsPerTurn = this.rsc.gameEnv().raw.secondsPerTurn;
|
||||
|
||||
this.forceUpdate((raw) => {
|
||||
raw.turntime = addSeconds(raw.turntime, secondsPerTurn);
|
||||
raw.turnTime = addSeconds(raw.turnTime, secondsPerTurn);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public compareTurntime(other: General): number {
|
||||
if(this._raw.turntime < other._raw.turntime){
|
||||
public compareTurnTime(other: General): number {
|
||||
if(this._raw.turnTime < other._raw.turnTime){
|
||||
return -1;
|
||||
}
|
||||
if(this._raw.turntime > other._raw.turntime){
|
||||
if(this._raw.turnTime > other._raw.turnTime){
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,14 +3,14 @@ import type { WarUnitTriggerCaller } from "./TriggerCaller/WarUnitTriggerCaller.
|
||||
import type { GeneralTriggerCaller } from "./TriggerCaller/GeneralTriggerCaller.js";
|
||||
import type { General } from "./General.js";
|
||||
import type { WarUnit } from "./WarUnit.js";
|
||||
import type { ArbitraryActionType, CalcIncomeType, CalcStatName, CalcStatRangeName, CalcStrategicVarType, StrategicTurnType } from "./defs.js";
|
||||
import type { ArbitraryActionType, CalcIncomeType, CalcStatName, CalcStatRangeName, CalcStrategicVarType, StrategicCmdType } from "./defs.js";
|
||||
|
||||
//TODO: turnType, varType이 string이면 안됨. enum에 가까워야함!
|
||||
type onCalcDomesticFunc = (turnType: string, varType: string, value: number, aux?: unknown[]) => number;
|
||||
|
||||
type onCalcStatFunc = (general: General, statName: CalcStatName, value: number, aux?: unknown[]) => number;
|
||||
type onCalcStatRangeFunc = (general: General, statName: CalcStatRangeName, value: [number, number], aux?: unknown[]) => [number, number];
|
||||
type onCalcStrategicFunc = (turnType: StrategicTurnType, varType: CalcStrategicVarType, value: number) => number;
|
||||
type onCalcStrategicFunc = (turnType: StrategicCmdType, varType: CalcStrategicVarType, value: number) => number;
|
||||
type onCalcIncomeFunc = (type: CalcIncomeType, value: number) => number;
|
||||
|
||||
type getWarPowerMultiplierFunc = (unit: WarUnit) => [number, number];
|
||||
|
||||
@@ -18,9 +18,9 @@ export interface IResourceController {
|
||||
squad(id: SquadID, nation: NationID): Squad | undefined;
|
||||
general(id: GeneralID): General | undefined;
|
||||
|
||||
peekGeneralTurntimeQueue(): General | undefined;
|
||||
popGeneralTurntimeQueue(): General | undefined;
|
||||
insertGeneralTurntimeQueue(general: General, maybeTail: boolean): void;
|
||||
peekGeneralTurnTimeQueue(): General | undefined;
|
||||
popGeneralTurnTimeQueue(): General | undefined;
|
||||
insertGeneralTurnTimeQueue(general: General, maybeTail: boolean): void;
|
||||
|
||||
gameEnv(): GameEnv;
|
||||
|
||||
|
||||
@@ -251,6 +251,10 @@ export interface ReservedTurn {
|
||||
//특수 숫자 정의
|
||||
//연 * 12 + 월
|
||||
export type IntYearMonth = number & { zz_t?: "YearMonth" };
|
||||
export type RemainMonth = number & { zz_t?: "RemainMonth" };
|
||||
export type IntMonth = number & { zz_t?: "IntMonth" };
|
||||
export type IntYear = number & { zz_t?: "IntYear" };
|
||||
//1.0을 기준으로한 number 타입
|
||||
export type FractionalRange = number & { zz_t?: "FractionalRange" };
|
||||
export type FractionalRange = number & { zz_t?: "FractionalRange" };
|
||||
|
||||
//특수 문자열 정의
|
||||
export type URILike = string & { zz_t?: "URILike" };
|
||||
@@ -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) {
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user