diff --git a/hwe/sammo/API/Global/GetConst.php b/hwe/sammo/API/Global/GetConst.php index b568905f..dd5eadbd 100644 --- a/hwe/sammo/API/Global/GetConst.php +++ b/hwe/sammo/API/Global/GetConst.php @@ -20,7 +20,7 @@ use function sammo\prepareDir; class GetConst extends \sammo\BaseAPI { /** 반환하는 StaticValues 타입이 달라지면 +1 */ - const CONST_API_VERSION = 1; + const CONST_API_VERSION = 2; const CACHE_KEY = 'JSConst'; private ?string $cacheKey = null; @@ -258,6 +258,18 @@ class GetConst extends \sammo\BaseAPI $iActionInfo[$mappedKey] = $actionInfo; } + + $crewtypeMap = []; + foreach(GameUnitConst::all() as $crewtypeObj){ + $crewtypeMap[$crewtypeObj->id] = [ + 'value'=>(string)$crewtypeObj->id, + 'name'=>$crewtypeObj->name, + 'info'=>$crewtypeObj->getInfo(), + ]; + } + $iActionInfo['crewtype'] = $crewtypeMap; + + return [ 'gameConst' => get_class_vars('\sammo\GameConst'), 'gameUnitConst' => GameUnitConst::all(), diff --git a/hwe/ts/components/GeneralList.vue b/hwe/ts/components/GeneralList.vue index 095a90fb..f122a5e3 100644 --- a/hwe/ts/components/GeneralList.vue +++ b/hwe/ts/components/GeneralList.vue @@ -38,8 +38,8 @@ import type { BaseWithValueColDefParams, ValueGetterParams } from "ag-grid-commu import type { GameConstStore } from "@/GameConstStore"; import { unwrap } from "@/util/unwrap"; import SimpleTooltipCell from "@/gridCellRenderer/SimpleTooltipCell.vue"; -import GridTooltipCell from "@/gridCellRenderer/GridTooltipCell.vue"; -import type { GameIActionInfo } from "@/defs/GameObj"; +import GridTooltipCell, { type GridCellInfo } from "@/gridCellRenderer/GridTooltipCell.vue"; +import { formatConnectScore } from "@/utilGame/formatConnectScore"; const props = defineProps({ list: { @@ -53,9 +53,9 @@ const props = defineProps({ default: "static", }, env: { - type: Object as PropType, + type: Object as PropType, required: true, - } + }, }); const gameConstStore = unwrap(inject>("gameConstStore")); @@ -111,8 +111,7 @@ function setRowHeight() { rowHeight.value = gridApi.value?.getSizesForCurrentTheme().rowHeight ?? 28; } - -function getRowHeight():number{ +function getRowHeight(): number { return rowHeight.value; } @@ -149,11 +148,13 @@ interface GenCellClassParams extends CellClassParams { data: GeneralListItem; } -type GridCellInfo = { - iActionMap?: Record; - info?: string; - target: keyof GeneralListItem; -}; +function naiveCheClassNameFilter(value: string): string { + const text = value.split("_").pop() ?? "None"; + if (text === "None") { + return "-"; + } + return text; +} function numberFormatter(value: GenValueParams): string { return (value.value as number).toLocaleString(); @@ -174,13 +175,13 @@ const defaultColDef = ref({ headerClass: "default-cell-header", cellClass: centerCellClass, floatingFilter: true, - width: 90, + width: 80, }); const columnRawDefs = ref>>({ icon: { headerName: "아이콘", - width: 64 + 24, + width: 64 + 16, suppressSizeToFit: true, resizable: false, cellRenderer: (obj: GenValueParams) => { @@ -195,7 +196,7 @@ const columnRawDefs = ref field: "name", pinned: "left", sortable: true, - width: 130, + width: 120, sortingOrder: ["asc", "desc", null], lockPosition: true, cellStyle: (val: GenCellClassParams) => { @@ -216,7 +217,7 @@ const columnRawDefs = ref children: [ { headerName: "통|무|지", - width: 90, + width: 88, cellRenderer: (obj: GenValueParams) => { const gen = obj.data; @@ -229,7 +230,7 @@ const columnRawDefs = ref field: "leadership", ...sortableNumber, columnGroupShow: "open", - width: 70, + width: 60, type: "numericColumn", }, { @@ -237,14 +238,14 @@ const columnRawDefs = ref field: "strength", ...sortableNumber, columnGroupShow: "open", - width: 70, + width: 60, }, { headerName: "지력", field: "intel", ...sortableNumber, columnGroupShow: "open", - width: 70, + width: 60, }, ], }, @@ -254,14 +255,28 @@ const columnRawDefs = ref sortable: true, comparator: (a, b, c, d) => c.data.officerLevel - d.data.officerLevel, cellRenderer: ({ data }: GenValueParams) => { - if (data.permission == 2 && 2 <= data.officerLevel && 4 <= data.officerLevel) { - return `${data.officer_city} ${data.officerLevelText}`; + if ([2, 3, 4].includes(data.permission)) { + const dataP2 = data as GeneralListItemP2; + if (2 <= dataP2.officerLevel && dataP2.officerLevel <= 4) { + const cityName = gameConstStore.value.cityConst[dataP2.officer_city].name; + return `${cityName}
${dataP2.officerLevelText}`; + } + } + return data.officerLevelText; + }, + filterValueGetter: ({ data }) => { + if ([2, 3, 4].includes(data.permission)) { + const dataP2 = data as GeneralListItemP2; + if (2 <= dataP2.officerLevel && dataP2.officerLevel <= 4) { + const cityName = gameConstStore.value.cityConst[dataP2.officer_city].name; + return `${cityName} ${dataP2.officerLevelText}`; + } } return data.officerLevelText; }, filter: true, cellClass: centerCellClass, - width: 90, + width: 70, }, expDedLv: { headerName: "명성", @@ -271,7 +286,7 @@ const columnRawDefs = ref { headerName: "/계급", columnGroupShow: "closed", - width: 70, + width: 60, cellRenderer: ({ data }: GenValueParams) => { return `Lv ${data.explevel}
${data.dedLevelText}`; }, @@ -279,17 +294,18 @@ const columnRawDefs = ref { headerName: "명성", field: "explevel", - width: 75, + width: 60, cellRenderer: ({ data }: GenValueParams) => { return `Lv ${data.explevel}
(${data.honorText})`; }, ...sortableNumber, + cellClass: centerCellClass, columnGroupShow: "open", }, { headerName: "계급", field: "dedLevelText", - width: 75, + width: 70, cellRenderer: ({ data }: GenValueParams) => { return `${data.dedLevelText}
(${data.bill.toLocaleString()})`; }, @@ -299,11 +315,37 @@ const columnRawDefs = ref }, ], }, - gold: { headerName: "금", field: "gold", ...sortableNumber, valueFormatter: numberFormatter, width: 75 }, - rice: { headerName: "쌀", field: "rice", ...sortableNumber, valueFormatter: numberFormatter, width: 75 }, - + gold: { headerName: "금", field: "gold", ...sortableNumber, valueFormatter: numberFormatter, width: 70 }, + rice: { headerName: "쌀", field: "rice", ...sortableNumber, valueFormatter: numberFormatter, width: 70 }, + crew: { + headerName: "보유 병력", + children: [ + { + headerName: "병종", + cellRenderer: GridTooltipCell, + cellRendererParams: { + cells: ((): GridCellInfo[][] => { + return [ + [{ target: "crewtype", iActionMap: gameConstStore.value.iActionInfo.crewtype }], + [{ target: "crew", converter: (value) => [`${value.crew.toLocaleString()}명`, undefined] }], + ]; + })(), + }, + }, + { + headerName: "훈/사", + width: 60, + cellRenderer: ({ data }: GenValueParams) => { + if (data.permission == 0 || data.permission == 1) { + return "?"; + } + return `${data.train}
${data.atmos}`; + }, + }, + ], + }, specials: { - headerName: "성격/내특/전특", + headerName: "특성", children: [ { headerName: "요약", @@ -319,7 +361,7 @@ const columnRawDefs = ref ]; })(), }, - width: 90, + width: 80, columnGroupShow: "closed", }, { @@ -329,7 +371,7 @@ const columnRawDefs = ref cellRendererParams: { iActionMap: gameConstStore.value.iActionInfo.personality, }, - width: 70, + width: 60, sortable: true, filter: true, columnGroupShow: "open", @@ -341,7 +383,7 @@ const columnRawDefs = ref cellRendererParams: { iActionMap: gameConstStore.value.iActionInfo.specialDomestic, }, - width: 70, + width: 60, sortable: true, filter: true, columnGroupShow: "open", @@ -353,7 +395,7 @@ const columnRawDefs = ref cellRendererParams: { iActionMap: gameConstStore.value.iActionInfo.specialWar, }, - width: 70, + width: 60, sortable: true, filter: true, columnGroupShow: "open", @@ -365,6 +407,7 @@ const columnRawDefs = ref children: [ { headerName: "요약", + width: 60, cellRenderer: ({ data }: GenValueParams) => { return `${data.age}세
${data.belong}년`; }, @@ -376,7 +419,7 @@ const columnRawDefs = ref field: "age", ...sortableNumber, valueFormatter: (v: GenValueParams) => `${v.value}세`, - width: 70, + width: 60, cellClass: centerCellClass, columnGroupShow: "open", }, @@ -385,12 +428,55 @@ const columnRawDefs = ref field: "belong", ...sortableNumber, valueFormatter: (v: GenValueParams) => `${v.value}년`, - width: 70, + width: 60, cellClass: centerCellClass, columnGroupShow: "open", }, ], }, + reservedCommand: { + headerName: "명령", + children: [ + { + headerName: "단축", + width: 70, + cellRenderer: ({ data }: GenValueParams) => { + if (data.npc >= 2) { + return "NPC 장수"; + } + const commandList = data.reservedCommand; + if (!commandList) { + return "???"; + } + return commandList.map(({ action }) => naiveCheClassNameFilter(action)).join("
"); + }, + cellStyle: { + lineHeight: "1em", + fontSize: "0.85em", + }, + columnGroupShow: "closed", + }, + { + headerName: "전체", + width: 120, + cellRenderer: ({ data }: GenValueParams) => { + if (data.npc >= 2) { + return "NPC 장수"; + } + const commandList = data.reservedCommand; + if (!commandList) { + return "???"; + } + return commandList.map(({ brief }) => brief).join("
"); + }, + cellStyle: { + lineHeight: "1em", + fontSize: "0.85em", + }, + columnGroupShow: "open", + }, + ], + }, killturnAndConnect: { headerName: "기타", children: [ @@ -401,6 +487,7 @@ const columnRawDefs = ref }, cellClass: rightAlignClass, columnGroupShow: "closed", + width: 70, }, { headerName: "삭턴", @@ -409,15 +496,17 @@ const columnRawDefs = ref return `${data.killturn.toLocaleString()}턴`; }, ...sortableNumber, + width: 70, columnGroupShow: "open", }, { headerName: "벌점", field: "connect", cellRenderer: ({ data }: GenValueParams) => { - return `${data.connect.toLocaleString()}점`; + return `${data.connect.toLocaleString()}점
(${formatConnectScore(data.connect)})`; }, ...sortableNumber, + width: 70, columnGroupShow: "open", }, ], @@ -433,18 +522,6 @@ watch(columnRawDefs, (val) => { gridApi.value?.redrawRows(); }); -/* -let currentWidth = -1; -window.addEventListener("resize", (e) => { - setTimeout(() => { - const newWidth = document.querySelector(".container")?.clientWidth ?? -1; - if (currentWidth != newWidth) { - currentWidth = newWidth; - columnApi.value?.autoSizeAllColumns(); - } - }, 1); -}); -*/ diff --git a/hwe/ts/defs/GameObj.ts b/hwe/ts/defs/GameObj.ts index 5da99a84..ad21e2c2 100644 --- a/hwe/ts/defs/GameObj.ts +++ b/hwe/ts/defs/GameObj.ts @@ -203,7 +203,7 @@ export type GameCityDefault = { path: Record; }; -export type GameIActionCategory = "nationType" | "specialDomestic" | "specialWar" | "personality" | "item"; +export type GameIActionCategory = "nationType" | "specialDomestic" | "specialWar" | "personality" | "item" | "crewtype"; export type GameIActionInfo = { value: string; diff --git a/hwe/ts/gridCellRenderer/GridTooltipCell.vue b/hwe/ts/gridCellRenderer/GridTooltipCell.vue index 9cfd0aab..1a189faa 100644 --- a/hwe/ts/gridCellRenderer/GridTooltipCell.vue +++ b/hwe/ts/gridCellRenderer/GridTooltipCell.vue @@ -6,10 +6,13 @@ v-if="colValue.iActionMap" v-b-tooltip.hover class="col" - :title="colValue.iActionMap[params.data[colValue.target ] as string ].info??''" + :title="colValue.iActionMap[params.data[colValue.target] as string ].info??''" > {{ colValue.iActionMap[params.data[colValue.target] as string ].name }} +
+ {{colValue.converter(params.data)[0]}} +
{{params.data[colValue.target] as string}}
@@ -18,21 +21,26 @@ - +