From 28b78e0872e8ab4e1aea1fcb288ef731b5e4afa2 Mon Sep 17 00:00:00 2001 From: Hide_D Date: Mon, 11 Mar 2024 16:53:44 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9A=A9=EC=96=B4=20=EC=9E=AC=EC=A0=95?= =?UTF-8?q?=EC=9D=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- @sammo/game_logic/src/ActionRequest/index.ts | 6 +- @sammo/game_logic/src/Entity/CityEntity.ts | 15 +++-- .../src/Entity/External/DiplomaticLetter.ts | 4 +- @sammo/game_logic/src/Entity/GameEnvEntity.ts | 4 +- @sammo/game_logic/src/Entity/GeneralEntity.ts | 10 +-- @sammo/game_logic/src/Entity/NationEntity.ts | 6 +- .../src/Entity/Persistant/History.ts | 2 +- .../src/Entity/Persistant/OldGeneral.ts | 2 +- @sammo/game_logic/src/Entity/TroopEntity.ts | 6 +- @sammo/game_logic/src/Entity/index.ts | 6 +- @sammo/game_logic/src/General.ts | 62 +++++++++---------- @sammo/game_logic/src/IAction.ts | 2 +- @sammo/game_logic/src/IResourceController.ts | 16 ++--- @sammo/game_logic/src/{Troop.ts => Squad.ts} | 24 +++---- @sammo/game_logic/src/defs.ts | 8 +-- @sammo/server/src/GameEngineDefs.ts | 2 +- @sammo/server/src/ResourceController.ts | 20 +++--- 17 files changed, 100 insertions(+), 95 deletions(-) rename @sammo/game_logic/src/{Troop.ts => Squad.ts} (69%) diff --git a/@sammo/game_logic/src/ActionRequest/index.ts b/@sammo/game_logic/src/ActionRequest/index.ts index 8b016b4..2884f78 100644 --- a/@sammo/game_logic/src/ActionRequest/index.ts +++ b/@sammo/game_logic/src/ActionRequest/index.ts @@ -1,5 +1,5 @@ import type { IResourceController } from "@/IResourceController.js"; -import type { CityID, GeneralID, NationID, TroopID } from "@/defs.js"; +import type { CityID, GeneralID, NationID, SquadID } from "@/defs.js"; import { NotYetImplemented } from "@sammo/util"; @@ -10,7 +10,7 @@ export function setDefenceTrained(invoker: QueueType, arg: { generalID: GeneralI throw new NotYetImplemented(); } -export function kickTroopMember(invoker: QueueType, arg: { nationID: NationID, troopID: TroopID, memberID: GeneralID }, rsc: IResourceController): void { +export function kickSquadMember(invoker: QueueType, arg: { nationID: NationID, squadID: SquadID, memberID: GeneralID }, rsc: IResourceController): void { throw new NotYetImplemented(); } @@ -51,7 +51,7 @@ export type ActionPackDef = { export const ActionRequestList = { setDefenceTrained, - kickTroopMember, + kickSquadMember, blockAttackCommand, blockJoinNation, createGeneral, diff --git a/@sammo/game_logic/src/Entity/CityEntity.ts b/@sammo/game_logic/src/Entity/CityEntity.ts index 89595b5..fe8219f 100644 --- a/@sammo/game_logic/src/Entity/CityEntity.ts +++ b/@sammo/game_logic/src/Entity/CityEntity.ts @@ -1,4 +1,4 @@ -import type { CityID, CityLevel, CityName, CityOfficerLevel, CityState, FrontStatus, NationID, RegionID } from "../defs.js"; +import type { CityID, CityLevel, CityName, CityOfficerLevel, CityState, FrontStatus, NationID, FractionalRange, RegionID, RemainMonth } from "../defs.js"; export interface ICityEntity{ @@ -9,7 +9,7 @@ export interface ICityEntity{ level: CityLevel; //보급품 있음 - hasSupply: boolean; + isSupplied: boolean; //도시 접경 상태 frontStatus: FrontStatus; @@ -60,15 +60,20 @@ export interface ICityEntity{ battleDeath: number; //상인 존재 및 거래율, base 1 - trader?: number; + traderStatus: { + exists: false; + } | { + exists: true; + rate: FractionalRange; + } - officerSet: Record; + officerAssignability: Record; regionID: RegionID; state: CityState; //전투 잔여 개월 - remainWarMonth: number; + remainWarMonth: RemainMonth; //국가별 수비병 사살 수 conflict: Record; diff --git a/@sammo/game_logic/src/Entity/External/DiplomaticLetter.ts b/@sammo/game_logic/src/Entity/External/DiplomaticLetter.ts index ed26604..2e9eba8 100644 --- a/@sammo/game_logic/src/Entity/External/DiplomaticLetter.ts +++ b/@sammo/game_logic/src/Entity/External/DiplomaticLetter.ts @@ -21,8 +21,8 @@ export interface IDiplomaticLetter { icon: string; }; - textBrief: string; - textDetail: string; + publicText: string; + privateText: string; createdAt: Date; updatedAt: Date; diff --git a/@sammo/game_logic/src/Entity/GameEnvEntity.ts b/@sammo/game_logic/src/Entity/GameEnvEntity.ts index 7542a36..7df23f8 100644 --- a/@sammo/game_logic/src/Entity/GameEnvEntity.ts +++ b/@sammo/game_logic/src/Entity/GameEnvEntity.ts @@ -13,7 +13,7 @@ export interface IGameEnvEntity { year: number; month: number; - turntermSec: number; + secondsPerTurn: number; refreshedKillTurn: number; @@ -32,7 +32,7 @@ export interface IGameEnvEntity { maxNationCnt: number; remainGeniusCnt: number; - autorunUserPolicy: Record; + autoRunUserPolicy: Record; //게임 외부는 다른 엔티티로 분리 } \ No newline at end of file diff --git a/@sammo/game_logic/src/Entity/GeneralEntity.ts b/@sammo/game_logic/src/Entity/GeneralEntity.ts index 671e9ab..47010c1 100644 --- a/@sammo/game_logic/src/Entity/GeneralEntity.ts +++ b/@sammo/game_logic/src/Entity/GeneralEntity.ts @@ -1,4 +1,4 @@ -import type { CityID, DiplomaticPermission, GeneralID, GeneralName, ItemID, ItemKeyType, NationID, NpcType, OfficerLevel, PersonalityType, SpecialityDomesticType, SpecialityWarType, TroopID, UserID, UserName } from "../defs.js"; +import type { CityID, DiplomaticPermission, GeneralID, GeneralName, ItemID, ItemKeyType, NationID, NpcType, OfficerLevel, PersonalityType, SpecialityDomesticType, SpecialityWarType, SquadID, UserID, UserName } from "../defs.js"; export interface IGeneralEntity { id: GeneralID; @@ -10,7 +10,7 @@ export interface IGeneralEntity { ownerName?: UserName; nationID: NationID; cityID: number; - troopID?: TroopID; + squadID?: SquadID; leadership: number; leadershipExp: number; @@ -27,7 +27,7 @@ export interface IGeneralEntity { experienceLevel: number; dedicationLevel: number; - dex: number[]; + armyClassExperience: number[]; officerLevel: OfficerLevel; officerCityID?: CityID; @@ -59,8 +59,8 @@ export interface IGeneralEntity { defenceTrained: number; - crewType: number; - crew: number; + armyType: number; + armyCount: number; trained: number; morale: number; diff --git a/@sammo/game_logic/src/Entity/NationEntity.ts b/@sammo/game_logic/src/Entity/NationEntity.ts index 5e84942..f1bfbf6 100644 --- a/@sammo/game_logic/src/Entity/NationEntity.ts +++ b/@sammo/game_logic/src/Entity/NationEntity.ts @@ -1,4 +1,4 @@ -import type { CityID, ColorType, IntYearMonth, NationCmdType, NationID, NationLevel, NationName, NationType, RemainMonth, ReservedTurn, StaffLevel, StrategicCmdType } from "../defs.js"; +import type { CityID, ColorType, IntYearMonth, NationCmdType, NationID, NationLevel, NationName, NationType, FractionalRange, RemainMonth, ReservedTurn, StaffLevel, StrategicCmdType } from "../defs.js"; export interface INationEntity{ id: NationID; @@ -20,9 +20,9 @@ export interface INationEntity{ strategicCmdLimit: Record; //세율 - taxRate: number; + taxRate: FractionalRange; //지급율 - payRate: number; + payRate: FractionalRange; gold: number; rice: number; diff --git a/@sammo/game_logic/src/Entity/Persistant/History.ts b/@sammo/game_logic/src/Entity/Persistant/History.ts index b8a15cd..f5a46c7 100644 --- a/@sammo/game_logic/src/Entity/Persistant/History.ts +++ b/@sammo/game_logic/src/Entity/Persistant/History.ts @@ -19,7 +19,7 @@ export interface IHistory { cities: Map { protected readonly _indirectNames: (keyof IGeneralEntity)[] = [ - "id", "nationID", "troopID", "nationID", "turntime" + "id", "nationID", "squadID", "nationID", "turntime" ]; protected readonly _entityType = "General"; protected readonly _raw: IGeneralEntity; protected _city: WeakRef; - protected _troop: WeakRef | undefined; + protected _squad: WeakRef | undefined; protected _nation: WeakRef; protected readonly iActionHandlers: Map; @@ -32,8 +32,8 @@ export class General extends LazyEntityUpdater { this._city = new WeakRef(must(rsc.city(raw.cityID))); this._nation = new WeakRef(must(rsc.nation(raw.nationID))); - if(raw.troopID){ - this._troop = new WeakRef(must(rsc.troop(raw.troopID, raw.nationID))); + if(raw.squadID){ + this._squad = new WeakRef(must(rsc.squad(raw.squadID, raw.nationID))); } //TODO: iAction 처리해야함 @@ -52,8 +52,8 @@ export class General extends LazyEntityUpdater { return must(this._city.deref()); } - public get troop(): Troop | undefined { - return this._troop?.deref(); + public get squad(): Squad | undefined { + return this._squad?.deref(); } public get nation(): Nation { @@ -79,43 +79,43 @@ export class General extends LazyEntityUpdater { }); } - public quitTroop(){ - if(!this._troop){ + public quitSquad(){ + if(!this._squad){ return; } - const troop = must(this._troop.deref()); - if(troop.leader.id === this._raw.id){ - troop.destructTroop(false); + const squad = must(this._squad.deref()); + if(squad.leader.id === this._raw.id){ + squad.destructSquad(false); } else{ - troop.members.delete(this._raw.id); + squad.members.delete(this._raw.id); } - this._troop = undefined; + this._squad = undefined; this.forceUpdate((raw) => { - raw.troopID = undefined; + raw.squadID = undefined; }); } - public changeTroop(troop: TroopID | Troop){ - this.quitTroop(); + public changeSquad(squad: SquadID | Squad){ + this.quitSquad(); - const troopObj: Troop = (()=>{ - if(troop instanceof Troop){ - return troop; + const squadObj: Squad = (()=>{ + if(squad instanceof Squad){ + return squad; } - const troopObj = this.rsc.troop(troop, this._raw.nationID); - if(!troopObj){ - throw new InvalidArgument(`Troop not found: ${troop}`); + const squadObj = this.rsc.squad(squad, this._raw.nationID); + if(!squadObj){ + throw new InvalidArgument(`Squad not found: ${squad}`); } - return troopObj; + return squadObj; })(); - troopObj.members.set(this._raw.id, new WeakRef(this)); - this._troop = new WeakRef(troopObj); + squadObj.members.set(this._raw.id, new WeakRef(this)); + this._squad = new WeakRef(squadObj); this.forceUpdate((raw) => { - raw.troopID = troopObj.id; + raw.squadID = squadObj.id; }); } @@ -131,7 +131,7 @@ export class General extends LazyEntityUpdater { return nationObj; })(); this._nation = new WeakRef(nationObj); - this.quitTroop(); + this.quitSquad(); this.forceUpdate((raw) => { raw.nationID = nationObj.id; @@ -147,10 +147,10 @@ export class General extends LazyEntityUpdater { } public updateTurntime(){ - const turntermSec = this.rsc.gameEnv().raw.turntermSec; + const secondsPerTurn = this.rsc.gameEnv().raw.secondsPerTurn; this.forceUpdate((raw) => { - raw.turntime = addSeconds(raw.turntime, turntermSec); + raw.turntime = addSeconds(raw.turntime, secondsPerTurn); }); } diff --git a/@sammo/game_logic/src/IAction.ts b/@sammo/game_logic/src/IAction.ts index 884b294..cffeb12 100644 --- a/@sammo/game_logic/src/IAction.ts +++ b/@sammo/game_logic/src/IAction.ts @@ -30,7 +30,7 @@ export const IActionOrder = [ 'specialityDomestic', 'specialityWar', 'personlity', - 'crewType', + 'armyType', 'inheritBuff', 'scenarioEffect', 'horse', diff --git a/@sammo/game_logic/src/IResourceController.ts b/@sammo/game_logic/src/IResourceController.ts index 98d47c6..87f9d69 100644 --- a/@sammo/game_logic/src/IResourceController.ts +++ b/@sammo/game_logic/src/IResourceController.ts @@ -1,11 +1,11 @@ import type { General } from "./General.js"; import type { City } from "./City.js"; import type { Nation } from "./Nation.js"; -import type { CityID, GeneralID, NationID, ReservedTurn, TroopID } from "./defs.js"; +import type { CityID, GeneralID, NationID, ReservedTurn, SquadID } from "./defs.js"; import type { GameEnv } from "./GameEnv.js"; import type { IGeneralEntity } from "./Entity/GeneralEntity.js"; -import type { Troop } from "./Troop.js"; -import type { ITroopEntity } from "./Entity/TroopEntity.js"; +import type { Squad } from "./Squad.js"; +import type { ISquadEntity } from "./Entity/SquadEntity.js"; import type { LazyEntityUpdater } from "./LazyEntityUpdater.js"; import type { ICityEntity } from "./Entity/CityEntity.js"; import type { INationEntity } from "./Entity/NationEntity.js"; @@ -15,7 +15,7 @@ export interface IResourceController { nation(id: NationID): Nation | undefined; city(id: CityID): City | undefined; - troop(id: TroopID, nation: NationID): Troop | undefined; + squad(id: SquadID, nation: NationID): Squad | undefined; general(id: GeneralID): General | undefined; peekGeneralTurntimeQueue(): General | undefined; @@ -27,16 +27,16 @@ export interface IResourceController { allNations(): Map; allCities(): Map; allCitiesByNation(): Map>; - allTroops(): Map>; + allSquads(): Map>; allGenerals(): Map; generalByNation(id: NationID): Map; generalByCity(id: CityID, nationID?: NationID): Map; - generalByTroop(id: TroopID): Map; + generalBySquad(id: SquadID): Map; cityByNation(id: NationID): Map; - troopByNation(id: NationID): Map; + squadByNation(id: NationID): Map; //----Insert, Update, Delete @@ -49,7 +49,7 @@ export interface IResourceController { //TODO: reserveInsert와 구현 방식 비교 createGeneral(raw: IGeneralEntity): General; createNation(raw: INationEntity): Nation; - createTroop(raw: ITroopEntity): Troop; + createSquad(raw: ISquadEntity): Squad; _getAllChanges(): Record< diff --git a/@sammo/game_logic/src/Troop.ts b/@sammo/game_logic/src/Squad.ts similarity index 69% rename from @sammo/game_logic/src/Troop.ts rename to @sammo/game_logic/src/Squad.ts index e0f06b1..707ec0f 100644 --- a/@sammo/game_logic/src/Troop.ts +++ b/@sammo/game_logic/src/Squad.ts @@ -1,25 +1,25 @@ import { must } from "@sammo/util"; import type { General } from "./General.js"; import type { IResourceController } from "./IResourceController.js"; -import type { ITroopEntity } from "./Entity/TroopEntity.js"; +import type { ISquadEntity } from "./Entity/SquadEntity.js"; import type { GeneralID } from "./defs.js"; import { LazyEntityUpdater } from "./LazyEntityUpdater.js"; -export class Troop extends LazyEntityUpdater { - protected readonly _indirectNames: (keyof ITroopEntity)[] = ["id"]; - protected readonly _entityType = "Troop"; - protected readonly _raw: ITroopEntity; +export class Squad extends LazyEntityUpdater { + protected readonly _indirectNames: (keyof ISquadEntity)[] = ["id"]; + protected readonly _entityType = "Squad"; + protected readonly _raw: ISquadEntity; private _leader: WeakRef; private _members: Map>; constructor( - raw: ITroopEntity, + raw: ISquadEntity, protected rsc: IResourceController ){ super(); this._raw = raw; - const members = rsc.generalByTroop(raw.id); + const members = rsc.generalBySquad(raw.id); const leaderID: GeneralID = raw.id as GeneralID; this._leader = new WeakRef(must(members.get(leaderID))); members.delete(leaderID); @@ -38,13 +38,13 @@ export class Troop extends LazyEntityUpdater { return this._members; } - public destructTroop(withLeader = true){ + public destructSquad(withLeader = true){ this._members.forEach((member)=>{ const general = must(member.deref()); - general.quitTroop(); + general.quitSquad(); }); if(withLeader){ - this.leader.quitTroop(); + this.leader.quitSquad(); } this.rsc.reserveDelete(this); @@ -56,6 +56,6 @@ export class Troop extends LazyEntityUpdater { }); } - //joinTroop은 General에서 처리 - //quitTroop은 General에서 처리 + //joinSquad은 General에서 처리 + //quitSquad은 General에서 처리 } \ No newline at end of file diff --git a/@sammo/game_logic/src/defs.ts b/@sammo/game_logic/src/defs.ts index 0de1ce1..2e0bba9 100644 --- a/@sammo/game_logic/src/defs.ts +++ b/@sammo/game_logic/src/defs.ts @@ -8,8 +8,8 @@ export type GeneralName = string & { zz_t?: "GeneralName" }; export type CityID = number & { zz_t?: "CityID" }; export type CityName = string & { zz_t?: "CityName" }; -export type TroopID = number & { zz_t?: "TroopID" }; -export type TroopName = string & { zz_t?: "TroopName" }; +export type SquadID = number & { zz_t?: "SquadID" }; +export type SquadName = string & { zz_t?: "SquadName" }; export type NationID = number & { zz_t?: "NationID" }; export type NationName = string & { zz_t?: "NationName" }; @@ -39,7 +39,7 @@ export const enum NpcType { npc_scenario = 2, npc_generated = 3, npc_strategic = 4, - npc_troop_leader = 5, + npc_squad_leader = 5, npc_unselectable = 6, npc_invader = 9, @@ -253,4 +253,4 @@ export interface ReservedTurn { export type IntYearMonth = number & { zz_t?: "YearMonth" }; export type RemainMonth = number & { zz_t?: "RemainMonth" }; //1.0을 기준으로한 number 타입 -export type Ratio = number & { zz_t?: "Ratio" }; +export type FractionalRange = number & { zz_t?: "FractionalRange" }; \ No newline at end of file diff --git a/@sammo/server/src/GameEngineDefs.ts b/@sammo/server/src/GameEngineDefs.ts index e7e9eb6..81af946 100644 --- a/@sammo/server/src/GameEngineDefs.ts +++ b/@sammo/server/src/GameEngineDefs.ts @@ -1,7 +1,7 @@ import type { RPCLists } from "@sammo/server_util"; import type { ActionRequest, ActionResult } from "./GameEngine.js"; import type { MessagePort } from "node:worker_threads"; -import type { CityID, GeneralID, NationID, TroopID } from "@sammo/game_logic/src/defs.js"; +import type { CityID, GeneralID, NationID, SquadID } from "@sammo/game_logic/src/defs.js"; import type { ActionPackDef } from "@sammo/game_logic"; import type { ActionRequestList, QueueType } from "@sammo/game_logic/src/ActionRequest/index.js"; //Remove Third argument. Use Infer diff --git a/@sammo/server/src/ResourceController.ts b/@sammo/server/src/ResourceController.ts index 280c21c..7b7c17d 100644 --- a/@sammo/server/src/ResourceController.ts +++ b/@sammo/server/src/ResourceController.ts @@ -1,16 +1,16 @@ import type { IResourceController } from "@sammo/game_logic"; import type { City } from "@sammo/game_logic/src/City.js"; -import type { CityID, GeneralID, NationID, TroopID } from "@sammo/game_logic/src/defs.js"; +import type { CityID, GeneralID, NationID, SquadID } from "@sammo/game_logic/src/defs.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 { INationEntity } from "@sammo/game_logic/src/Entity/NationEntity.js"; import type { IReservedTurn } from "@sammo/game_logic/src/Entity/ReservedTurn.js"; -import type { ITroopEntity } from "@sammo/game_logic/src/Entity/TroopEntity.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"; import type { LazyEntityUpdater } from "@sammo/game_logic/src/LazyEntityUpdater.js"; import type { Nation } from "@sammo/game_logic/src/Nation.js"; -import type { Troop } from "@sammo/game_logic/src/Troop.js"; +import type { Squad } from "@sammo/game_logic/src/Squad.js"; import { insertItemAtArrayLike, NotYetImplemented } from "@sammo/util"; import Denque from "denque"; import type { Mongoose } from "mongoose"; @@ -27,7 +27,7 @@ export class ResourceController implements IResourceController{ private _nation: Map = new Map(); private _city: Map = new Map(); - private _troop: Map = new Map(); + private _squad: Map = new Map(); private _general: Map = new Map(); //내부적으로 turntime asc, id asc로 동작하는 PriorityQueue @@ -38,7 +38,7 @@ export class ResourceController implements IResourceController{ private changes = { Nation: new Map(), City: new Map(), - Troop: new Map(), + Squad: new Map(), General: new Map(), GameEnv: new Map(), @@ -52,7 +52,7 @@ export class ResourceController implements IResourceController{ throw new NotYetImplemented(); } - troop(id: TroopID, nation: NationID): Troop | undefined { + squad(id: SquadID, nation: NationID): Squad | undefined { throw new NotYetImplemented(); } @@ -88,7 +88,7 @@ export class ResourceController implements IResourceController{ throw new NotYetImplemented(); } - allTroops(): Map> { + allSquads(): Map> { throw new NotYetImplemented(); } @@ -104,7 +104,7 @@ export class ResourceController implements IResourceController{ throw new NotYetImplemented(); } - generalByTroop(id: TroopID): Map { + generalBySquad(id: SquadID): Map { throw new NotYetImplemented(); } @@ -112,7 +112,7 @@ export class ResourceController implements IResourceController{ throw new NotYetImplemented(); } - troopByNation(id: NationID): Map { + squadByNation(id: NationID): Map { throw new NotYetImplemented(); } @@ -139,7 +139,7 @@ export class ResourceController implements IResourceController{ throw new NotYetImplemented(); } - createTroop(raw: ITroopEntity): Troop { + createSquad(raw: ISquadEntity): Squad { throw new NotYetImplemented(); }