변수명 재정의
This commit is contained in:
@@ -34,7 +34,7 @@ export function createGeneral(invoker: QueueType, arg: {
|
|||||||
pic: string
|
pic: string
|
||||||
character: string
|
character: string
|
||||||
|
|
||||||
turntimeZone?: number,
|
turnTimeZone?: number,
|
||||||
warSpecial?: string,
|
warSpecial?: string,
|
||||||
city?: CityID,
|
city?: CityID,
|
||||||
bonusStat?: [number, number, number],
|
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{
|
export interface ICityEntity{
|
||||||
@@ -73,8 +73,8 @@ export interface ICityEntity{
|
|||||||
|
|
||||||
state: CityState;
|
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 {
|
export interface IDiplomaticLetter {
|
||||||
_id: string;
|
_id: string;
|
||||||
@@ -11,13 +11,13 @@ export interface IDiplomaticLetter {
|
|||||||
state: 'proposed' | 'accepted' | 'rejected' | 'canceled' | 'replaced';
|
state: 'proposed' | 'accepted' | 'rejected' | 'canceled' | 'replaced';
|
||||||
|
|
||||||
srcSigner: {
|
srcSigner: {
|
||||||
generalID: string;
|
generalID: GeneralID;
|
||||||
generalName: string;
|
generalName: GeneralName;
|
||||||
icon: string;
|
icon: string;
|
||||||
};
|
};
|
||||||
destSigner: {
|
destSigner: {
|
||||||
generalID: string;
|
generalID: GeneralID;
|
||||||
generalName: string;
|
generalName: GeneralName;
|
||||||
icon: string;
|
icon: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export interface IGameEnvEntity {
|
|||||||
|
|
||||||
secondsPerTurn: number;
|
secondsPerTurn: number;
|
||||||
|
|
||||||
refreshedKillTurn: number;
|
numberOfIdleTurnTillDeath: number;
|
||||||
|
|
||||||
isFictionMode: boolean;
|
isFictionMode: boolean;
|
||||||
unitedGameState: UnitedGameState;
|
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 {
|
export interface IGeneralEntity {
|
||||||
id: GeneralID;
|
id: GeneralID;
|
||||||
ownerID?: UserID;
|
ownerID?: UserID;
|
||||||
npcType: NpcType;
|
npcType: NpcType;
|
||||||
affinity?: number;
|
affinity?: number;
|
||||||
icon?: string;
|
icon?: URILike;
|
||||||
name: GeneralName;
|
name: GeneralName;
|
||||||
ownerName?: UserName;
|
ownerName?: UserName;
|
||||||
nationID: NationID;
|
nationID: NationID;
|
||||||
@@ -19,7 +19,7 @@ export interface IGeneralEntity {
|
|||||||
intel: number;
|
intel: number;
|
||||||
intelExp: number;
|
intelExp: number;
|
||||||
|
|
||||||
injury: number;
|
injury: FractionalRange;
|
||||||
|
|
||||||
experience: number;
|
experience: number;
|
||||||
dedication: number;
|
dedication: number;
|
||||||
@@ -42,14 +42,14 @@ export interface IGeneralEntity {
|
|||||||
option: Record<string, unknown>,
|
option: Record<string, unknown>,
|
||||||
}>;
|
}>;
|
||||||
|
|
||||||
turntime: Date;
|
turnTime: Date;
|
||||||
|
|
||||||
killturn: number;
|
idleTurn: IntMonth;
|
||||||
|
|
||||||
age: number;
|
age: IntYear;
|
||||||
startAge: number;
|
startAge: IntYear;
|
||||||
|
|
||||||
nationBelong: number;
|
nationJoinedRelYear: IntYear;
|
||||||
|
|
||||||
betray: number;
|
betray: number;
|
||||||
|
|
||||||
|
|||||||
@@ -14,14 +14,14 @@ export interface IGeneralRankEntity {
|
|||||||
battleLoseCnt: number;
|
battleLoseCnt: number;
|
||||||
|
|
||||||
//누적 병력 사망 수
|
//누적 병력 사망 수
|
||||||
crewDeathCnt: number;
|
allDeathCnt: number;
|
||||||
//누적 병력 사살 수
|
//누적 병력 사살 수
|
||||||
crewKillCnt: number;
|
allKillCnt: number;
|
||||||
|
|
||||||
//누적 대인 병력 사망 수
|
//누적 대인 병력 사망 수
|
||||||
crewDeathCntByGeneral: number;
|
armyDeathCnt: number;
|
||||||
//누적 대인 병력 사살 수
|
//누적 대인 병력 사살 수
|
||||||
crewKillCntByGeneral: number;
|
armyKillCnt: number;
|
||||||
|
|
||||||
//점령 수
|
//점령 수
|
||||||
occupyCnt: 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{
|
export interface INationEntity{
|
||||||
id: NationID;
|
id: NationID;
|
||||||
@@ -40,7 +40,7 @@ export interface INationEntity{
|
|||||||
power: number;
|
power: number;
|
||||||
|
|
||||||
//첩보 제한
|
//첩보 제한
|
||||||
spyLimit: Map<CityID, RemainMonth>;
|
spyLimit: Map<CityID, IntMonth>;
|
||||||
|
|
||||||
//커맨드별 옵션
|
//커맨드별 옵션
|
||||||
commandOption: Map<NationCmdType, Map<string, unknown>>;
|
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";
|
import type { INationEntity } from "../NationEntity.js";
|
||||||
|
|
||||||
export interface IOldNation {
|
export interface IOldNation {
|
||||||
@@ -20,7 +20,7 @@ export interface IOldNation {
|
|||||||
ownerName?: string;
|
ownerName?: string;
|
||||||
|
|
||||||
npcType?: NpcType;
|
npcType?: NpcType;
|
||||||
icon?: string;
|
icon?: URILike;
|
||||||
|
|
||||||
officerLevel: OfficerLevel;
|
officerLevel: OfficerLevel;
|
||||||
officerCityID?: number;
|
officerCityID?: number;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { addSeconds } from "date-fns";
|
|||||||
|
|
||||||
export class General extends LazyEntityUpdater<IGeneralEntity> {
|
export class General extends LazyEntityUpdater<IGeneralEntity> {
|
||||||
protected readonly _indirectNames: (keyof IGeneralEntity)[] = [
|
protected readonly _indirectNames: (keyof IGeneralEntity)[] = [
|
||||||
"id", "nationID", "squadID", "nationID", "turntime"
|
"id", "nationID", "squadID", "nationID", "turnTime"
|
||||||
];
|
];
|
||||||
protected readonly _entityType = "General";
|
protected readonly _entityType = "General";
|
||||||
protected readonly _raw: IGeneralEntity;
|
protected readonly _raw: IGeneralEntity;
|
||||||
@@ -142,24 +142,24 @@ export class General extends LazyEntityUpdater<IGeneralEntity> {
|
|||||||
else{
|
else{
|
||||||
raw.officerLevel = OfficerLevel.normal;
|
raw.officerLevel = OfficerLevel.normal;
|
||||||
}
|
}
|
||||||
raw.nationBelong = 0;
|
raw.nationJoinedRelYear = 0;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public updateTurntime(){
|
public updateTurnTime(){
|
||||||
const secondsPerTurn = this.rsc.gameEnv().raw.secondsPerTurn;
|
const secondsPerTurn = this.rsc.gameEnv().raw.secondsPerTurn;
|
||||||
|
|
||||||
this.forceUpdate((raw) => {
|
this.forceUpdate((raw) => {
|
||||||
raw.turntime = addSeconds(raw.turntime, secondsPerTurn);
|
raw.turnTime = addSeconds(raw.turnTime, secondsPerTurn);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public compareTurntime(other: General): number {
|
public compareTurnTime(other: General): number {
|
||||||
if(this._raw.turntime < other._raw.turntime){
|
if(this._raw.turnTime < other._raw.turnTime){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if(this._raw.turntime > other._raw.turntime){
|
if(this._raw.turnTime > other._raw.turnTime){
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import type { WarUnitTriggerCaller } from "./TriggerCaller/WarUnitTriggerCaller.
|
|||||||
import type { GeneralTriggerCaller } from "./TriggerCaller/GeneralTriggerCaller.js";
|
import type { GeneralTriggerCaller } from "./TriggerCaller/GeneralTriggerCaller.js";
|
||||||
import type { General } from "./General.js";
|
import type { General } from "./General.js";
|
||||||
import type { WarUnit } from "./WarUnit.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에 가까워야함!
|
//TODO: turnType, varType이 string이면 안됨. enum에 가까워야함!
|
||||||
type onCalcDomesticFunc = (turnType: string, varType: string, value: number, aux?: unknown[]) => number;
|
type onCalcDomesticFunc = (turnType: string, varType: string, value: number, aux?: unknown[]) => number;
|
||||||
|
|
||||||
type onCalcStatFunc = (general: General, statName: CalcStatName, 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 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 onCalcIncomeFunc = (type: CalcIncomeType, value: number) => number;
|
||||||
|
|
||||||
type getWarPowerMultiplierFunc = (unit: WarUnit) => [number, number];
|
type getWarPowerMultiplierFunc = (unit: WarUnit) => [number, number];
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ export interface IResourceController {
|
|||||||
squad(id: SquadID, nation: NationID): Squad | undefined;
|
squad(id: SquadID, nation: NationID): Squad | undefined;
|
||||||
general(id: GeneralID): General | undefined;
|
general(id: GeneralID): General | undefined;
|
||||||
|
|
||||||
peekGeneralTurntimeQueue(): General | undefined;
|
peekGeneralTurnTimeQueue(): General | undefined;
|
||||||
popGeneralTurntimeQueue(): General | undefined;
|
popGeneralTurnTimeQueue(): General | undefined;
|
||||||
insertGeneralTurntimeQueue(general: General, maybeTail: boolean): void;
|
insertGeneralTurnTimeQueue(general: General, maybeTail: boolean): void;
|
||||||
|
|
||||||
gameEnv(): GameEnv;
|
gameEnv(): GameEnv;
|
||||||
|
|
||||||
|
|||||||
@@ -251,6 +251,10 @@ export interface ReservedTurn {
|
|||||||
//특수 숫자 정의
|
//특수 숫자 정의
|
||||||
//연 * 12 + 월
|
//연 * 12 + 월
|
||||||
export type IntYearMonth = number & { zz_t?: "YearMonth" };
|
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 타입
|
//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) {
|
while (true) {
|
||||||
//장수턴 부터 처리
|
//장수턴 부터 처리
|
||||||
const upcomingGeneral = this.rsc.popGeneralTurntimeQueue();
|
const upcomingGeneral = this.rsc.popGeneralTurnTimeQueue();
|
||||||
if (!upcomingGeneral) {
|
if (!upcomingGeneral) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
const generalTurntime = upcomingGeneral.raw.turntime;
|
const generalTurnTime = upcomingGeneral.raw.turnTime;
|
||||||
if (generalTurntime > now) {
|
if (generalTurnTime > now) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: 턴 수행해야지!
|
//TODO: 턴 수행해야지!
|
||||||
|
|
||||||
upcomingGeneral.updateTurntime();
|
upcomingGeneral.updateTurnTime();
|
||||||
this.rsc.insertGeneralTurntimeQueue(upcomingGeneral, true);
|
this.rsc.insertGeneralTurnTimeQueue(upcomingGeneral, true);
|
||||||
this.rsc.gameEnv().update((env) => {
|
this.rsc.gameEnv().update((env) => {
|
||||||
env.lastExecuted = generalTurntime;
|
env.lastExecuted = generalTurnTime;
|
||||||
})
|
})
|
||||||
processedGeneralCount++;
|
processedGeneralCount++;
|
||||||
}
|
}
|
||||||
@@ -147,11 +147,11 @@ export class GameEngine {
|
|||||||
//가장 빠른 장수
|
//가장 빠른 장수
|
||||||
do {
|
do {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
const upcomingGeneral = this.rsc.peekGeneralTurntimeQueue();
|
const upcomingGeneral = this.rsc.peekGeneralTurnTimeQueue();
|
||||||
if (!upcomingGeneral) {
|
if (!upcomingGeneral) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
const upcomingTurn = upcomingGeneral.raw.turntime;
|
const upcomingTurn = upcomingGeneral.raw.turnTime;
|
||||||
|
|
||||||
const waitGeneralTurnMs = upcomingTurn.getTime() - now.getTime();
|
const waitGeneralTurnMs = upcomingTurn.getTime() - now.getTime();
|
||||||
if (waitGeneralTurnMs > 0) {
|
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 { IGeneralEntity } from "@sammo/game_logic/src/Entity/GeneralEntity.js";
|
||||||
import type { ICityEntity, ValidEntityType } from "@sammo/game_logic/src/Entity/index.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 { 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 { ISquadEntity } from "@sammo/game_logic/src/Entity/SquadEntity.js";
|
||||||
import type { GameEnv } from "@sammo/game_logic/src/GameEnv.js";
|
import type { GameEnv } from "@sammo/game_logic/src/GameEnv.js";
|
||||||
import { General } from "@sammo/game_logic/src/General.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 _squad: Map<number, Squad> = new Map();
|
||||||
private _general: Map<number, General> = new Map();
|
private _general: Map<number, General> = new Map();
|
||||||
|
|
||||||
//내부적으로 turntime asc, id asc로 동작하는 PriorityQueue
|
//내부적으로 turnTime asc, id asc로 동작하는 PriorityQueue
|
||||||
private _generalByTurntime = new Denque<General>();
|
private _generalByTurnTime = new Denque<General>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -60,16 +60,16 @@ export class ResourceController implements IResourceController{
|
|||||||
throw new NotYetImplemented();
|
throw new NotYetImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
peekGeneralTurntimeQueue(): General | undefined {
|
peekGeneralTurnTimeQueue(): General | undefined {
|
||||||
return this._generalByTurntime.peekFront();
|
return this._generalByTurnTime.peekFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
popGeneralTurntimeQueue(): General | undefined {
|
popGeneralTurnTimeQueue(): General | undefined {
|
||||||
return this._generalByTurntime.shift();
|
return this._generalByTurnTime.shift();
|
||||||
}
|
}
|
||||||
|
|
||||||
insertGeneralTurntimeQueue(general: General, maybeTail: boolean): void {
|
insertGeneralTurnTimeQueue(general: General, maybeTail: boolean): void {
|
||||||
insertItemAtArrayLike(this._generalByTurntime, general, (a, b)=>a.compareTurntime(b), maybeTail);
|
insertItemAtArrayLike(this._generalByTurnTime, general, (a, b)=>a.compareTurnTime(b), maybeTail);
|
||||||
}
|
}
|
||||||
|
|
||||||
gameEnv(): GameEnv {
|
gameEnv(): GameEnv {
|
||||||
@@ -150,11 +150,11 @@ export class ResourceController implements IResourceController{
|
|||||||
|
|
||||||
//---- DB 접근 ---
|
//---- DB 접근 ---
|
||||||
|
|
||||||
getReservedTurn(general: General): Promise<IReservedTurn> {
|
getReservedTurn(general: General): Promise<ReservedTurn> {
|
||||||
throw new NotYetImplemented();
|
throw new NotYetImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
nationReservedTurn(general: General): Promise<IReservedTurn | undefined> {
|
nationReservedTurn(general: General): Promise<ReservedTurn | undefined> {
|
||||||
throw new NotYetImplemented();
|
throw new NotYetImplemented();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user