feat(wip): 세력장수 추가작업, 병종 등

This commit is contained in:
2022-04-07 03:03:38 +09:00
parent 0a3c98ec5a
commit 35eafa36d6
4 changed files with 176 additions and 59 deletions
+13 -1
View File
@@ -20,7 +20,7 @@ use function sammo\prepareDir;
class GetConst extends \sammo\BaseAPI class GetConst extends \sammo\BaseAPI
{ {
/** 반환하는 StaticValues 타입이 달라지면 +1 */ /** 반환하는 StaticValues 타입이 달라지면 +1 */
const CONST_API_VERSION = 1; const CONST_API_VERSION = 2;
const CACHE_KEY = 'JSConst'; const CACHE_KEY = 'JSConst';
private ?string $cacheKey = null; private ?string $cacheKey = null;
@@ -258,6 +258,18 @@ class GetConst extends \sammo\BaseAPI
$iActionInfo[$mappedKey] = $actionInfo; $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 [ return [
'gameConst' => get_class_vars('\sammo\GameConst'), 'gameConst' => get_class_vars('\sammo\GameConst'),
'gameUnitConst' => GameUnitConst::all(), 'gameUnitConst' => GameUnitConst::all(),
+144 -47
View File
@@ -38,8 +38,8 @@ import type { BaseWithValueColDefParams, ValueGetterParams } from "ag-grid-commu
import type { GameConstStore } from "@/GameConstStore"; import type { GameConstStore } from "@/GameConstStore";
import { unwrap } from "@/util/unwrap"; import { unwrap } from "@/util/unwrap";
import SimpleTooltipCell from "@/gridCellRenderer/SimpleTooltipCell.vue"; import SimpleTooltipCell from "@/gridCellRenderer/SimpleTooltipCell.vue";
import GridTooltipCell from "@/gridCellRenderer/GridTooltipCell.vue"; import GridTooltipCell, { type GridCellInfo } from "@/gridCellRenderer/GridTooltipCell.vue";
import type { GameIActionInfo } from "@/defs/GameObj"; import { formatConnectScore } from "@/utilGame/formatConnectScore";
const props = defineProps({ const props = defineProps({
list: { list: {
@@ -53,9 +53,9 @@ const props = defineProps({
default: "static", default: "static",
}, },
env: { env: {
type: Object as PropType<GeneralListResponse['env']>, type: Object as PropType<GeneralListResponse["env"]>,
required: true, required: true,
} },
}); });
const gameConstStore = unwrap(inject<Ref<GameConstStore>>("gameConstStore")); const gameConstStore = unwrap(inject<Ref<GameConstStore>>("gameConstStore"));
@@ -111,8 +111,7 @@ function setRowHeight() {
rowHeight.value = gridApi.value?.getSizesForCurrentTheme().rowHeight ?? 28; rowHeight.value = gridApi.value?.getSizesForCurrentTheme().rowHeight ?? 28;
} }
function getRowHeight(): number {
function getRowHeight():number{
return rowHeight.value; return rowHeight.value;
} }
@@ -149,11 +148,13 @@ interface GenCellClassParams extends CellClassParams {
data: GeneralListItem; data: GeneralListItem;
} }
type GridCellInfo = { function naiveCheClassNameFilter(value: string): string {
iActionMap?: Record<string, GameIActionInfo>; const text = value.split("_").pop() ?? "None";
info?: string; if (text === "None") {
target: keyof GeneralListItem; return "-";
}; }
return text;
}
function numberFormatter(value: GenValueParams): string { function numberFormatter(value: GenValueParams): string {
return (value.value as number).toLocaleString(); return (value.value as number).toLocaleString();
@@ -174,13 +175,13 @@ const defaultColDef = ref<ColDef>({
headerClass: "default-cell-header", headerClass: "default-cell-header",
cellClass: centerCellClass, cellClass: centerCellClass,
floatingFilter: true, floatingFilter: true,
width: 90, width: 80,
}); });
const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>>>({ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>>>({
icon: { icon: {
headerName: "아이콘", headerName: "아이콘",
width: 64 + 24, width: 64 + 16,
suppressSizeToFit: true, suppressSizeToFit: true,
resizable: false, resizable: false,
cellRenderer: (obj: GenValueParams) => { cellRenderer: (obj: GenValueParams) => {
@@ -195,7 +196,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "name", field: "name",
pinned: "left", pinned: "left",
sortable: true, sortable: true,
width: 130, width: 120,
sortingOrder: ["asc", "desc", null], sortingOrder: ["asc", "desc", null],
lockPosition: true, lockPosition: true,
cellStyle: (val: GenCellClassParams) => { cellStyle: (val: GenCellClassParams) => {
@@ -216,7 +217,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
children: [ children: [
{ {
headerName: "통|무|지", headerName: "통|무|지",
width: 90, width: 88,
cellRenderer: (obj: GenValueParams) => { cellRenderer: (obj: GenValueParams) => {
const gen = obj.data; const gen = obj.data;
@@ -229,7 +230,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "leadership", field: "leadership",
...sortableNumber, ...sortableNumber,
columnGroupShow: "open", columnGroupShow: "open",
width: 70, width: 60,
type: "numericColumn", type: "numericColumn",
}, },
{ {
@@ -237,14 +238,14 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "strength", field: "strength",
...sortableNumber, ...sortableNumber,
columnGroupShow: "open", columnGroupShow: "open",
width: 70, width: 60,
}, },
{ {
headerName: "지력", headerName: "지력",
field: "intel", field: "intel",
...sortableNumber, ...sortableNumber,
columnGroupShow: "open", columnGroupShow: "open",
width: 70, width: 60,
}, },
], ],
}, },
@@ -254,14 +255,28 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
sortable: true, sortable: true,
comparator: (a, b, c, d) => c.data.officerLevel - d.data.officerLevel, comparator: (a, b, c, d) => c.data.officerLevel - d.data.officerLevel,
cellRenderer: ({ data }: GenValueParams) => { cellRenderer: ({ data }: GenValueParams) => {
if (data.permission == 2 && 2 <= data.officerLevel && 4 <= data.officerLevel) { if ([2, 3, 4].includes(data.permission)) {
return `${data.officer_city} ${data.officerLevelText}`; const dataP2 = data as GeneralListItemP2;
if (2 <= dataP2.officerLevel && dataP2.officerLevel <= 4) {
const cityName = gameConstStore.value.cityConst[dataP2.officer_city].name;
return `${cityName}<br>${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; return data.officerLevelText;
}, },
filter: true, filter: true,
cellClass: centerCellClass, cellClass: centerCellClass,
width: 90, width: 70,
}, },
expDedLv: { expDedLv: {
headerName: "명성", headerName: "명성",
@@ -271,7 +286,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
{ {
headerName: "/계급", headerName: "/계급",
columnGroupShow: "closed", columnGroupShow: "closed",
width: 70, width: 60,
cellRenderer: ({ data }: GenValueParams) => { cellRenderer: ({ data }: GenValueParams) => {
return `Lv ${data.explevel}<br>${data.dedLevelText}`; return `Lv ${data.explevel}<br>${data.dedLevelText}`;
}, },
@@ -279,17 +294,18 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
{ {
headerName: "명성", headerName: "명성",
field: "explevel", field: "explevel",
width: 75, width: 60,
cellRenderer: ({ data }: GenValueParams) => { cellRenderer: ({ data }: GenValueParams) => {
return `Lv ${data.explevel}<br>(${data.honorText})`; return `Lv ${data.explevel}<br>(${data.honorText})`;
}, },
...sortableNumber, ...sortableNumber,
cellClass: centerCellClass,
columnGroupShow: "open", columnGroupShow: "open",
}, },
{ {
headerName: "계급", headerName: "계급",
field: "dedLevelText", field: "dedLevelText",
width: 75, width: 70,
cellRenderer: ({ data }: GenValueParams) => { cellRenderer: ({ data }: GenValueParams) => {
return `${data.dedLevelText}<br>(${data.bill.toLocaleString()})`; return `${data.dedLevelText}<br>(${data.bill.toLocaleString()})`;
}, },
@@ -299,11 +315,37 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
}, },
], ],
}, },
gold: { headerName: "금", field: "gold", ...sortableNumber, valueFormatter: numberFormatter, width: 75 }, gold: { headerName: "금", field: "gold", ...sortableNumber, valueFormatter: numberFormatter, width: 70 },
rice: { headerName: "쌀", field: "rice", ...sortableNumber, valueFormatter: numberFormatter, width: 75 }, 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}<br>${data.atmos}`;
},
},
],
},
specials: { specials: {
headerName: "성격/내특/전특", headerName: "특",
children: [ children: [
{ {
headerName: "요약", headerName: "요약",
@@ -319,7 +361,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
]; ];
})(), })(),
}, },
width: 90, width: 80,
columnGroupShow: "closed", columnGroupShow: "closed",
}, },
{ {
@@ -329,7 +371,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellRendererParams: { cellRendererParams: {
iActionMap: gameConstStore.value.iActionInfo.personality, iActionMap: gameConstStore.value.iActionInfo.personality,
}, },
width: 70, width: 60,
sortable: true, sortable: true,
filter: true, filter: true,
columnGroupShow: "open", columnGroupShow: "open",
@@ -341,7 +383,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellRendererParams: { cellRendererParams: {
iActionMap: gameConstStore.value.iActionInfo.specialDomestic, iActionMap: gameConstStore.value.iActionInfo.specialDomestic,
}, },
width: 70, width: 60,
sortable: true, sortable: true,
filter: true, filter: true,
columnGroupShow: "open", columnGroupShow: "open",
@@ -353,7 +395,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellRendererParams: { cellRendererParams: {
iActionMap: gameConstStore.value.iActionInfo.specialWar, iActionMap: gameConstStore.value.iActionInfo.specialWar,
}, },
width: 70, width: 60,
sortable: true, sortable: true,
filter: true, filter: true,
columnGroupShow: "open", columnGroupShow: "open",
@@ -365,6 +407,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
children: [ children: [
{ {
headerName: "요약", headerName: "요약",
width: 60,
cellRenderer: ({ data }: GenValueParams) => { cellRenderer: ({ data }: GenValueParams) => {
return `${data.age}세<br>${data.belong}`; return `${data.age}세<br>${data.belong}`;
}, },
@@ -376,7 +419,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "age", field: "age",
...sortableNumber, ...sortableNumber,
valueFormatter: (v: GenValueParams) => `${v.value}`, valueFormatter: (v: GenValueParams) => `${v.value}`,
width: 70, width: 60,
cellClass: centerCellClass, cellClass: centerCellClass,
columnGroupShow: "open", columnGroupShow: "open",
}, },
@@ -385,12 +428,55 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "belong", field: "belong",
...sortableNumber, ...sortableNumber,
valueFormatter: (v: GenValueParams) => `${v.value}`, valueFormatter: (v: GenValueParams) => `${v.value}`,
width: 70, width: 60,
cellClass: centerCellClass, cellClass: centerCellClass,
columnGroupShow: "open", 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("<br>");
},
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("<br>");
},
cellStyle: {
lineHeight: "1em",
fontSize: "0.85em",
},
columnGroupShow: "open",
},
],
},
killturnAndConnect: { killturnAndConnect: {
headerName: "기타", headerName: "기타",
children: [ children: [
@@ -401,6 +487,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
}, },
cellClass: rightAlignClass, cellClass: rightAlignClass,
columnGroupShow: "closed", columnGroupShow: "closed",
width: 70,
}, },
{ {
headerName: "삭턴", headerName: "삭턴",
@@ -409,15 +496,17 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
return `${data.killturn.toLocaleString()}`; return `${data.killturn.toLocaleString()}`;
}, },
...sortableNumber, ...sortableNumber,
width: 70,
columnGroupShow: "open", columnGroupShow: "open",
}, },
{ {
headerName: "벌점", headerName: "벌점",
field: "connect", field: "connect",
cellRenderer: ({ data }: GenValueParams) => { cellRenderer: ({ data }: GenValueParams) => {
return `${data.connect.toLocaleString()}`; return `${data.connect.toLocaleString()}<br>(${formatConnectScore(data.connect)})`;
}, },
...sortableNumber, ...sortableNumber,
width: 70,
columnGroupShow: "open", columnGroupShow: "open",
}, },
], ],
@@ -433,18 +522,6 @@ watch(columnRawDefs, (val) => {
gridApi.value?.redrawRows(); 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);
});
*/
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
@@ -495,5 +572,25 @@ window.addEventListener("resize", (e) => {
.cell-sp .col { .cell-sp .col {
min-width: 30px; min-width: 30px;
} }
.ag-header-cell,
.ag-header-group-cell,
.ag-cell {
padding-left: 4px;
padding-right: 4px;
}
.ag-header-cell-label,
.ag-header-group-cell-label {
justify-content: center;
}
.ag-ltr .ag-floating-filter-button {
margin-left: 2px;
}
.ag-rtl .ag-floating-filter-button {
margin-right: 2px;
}
} }
</style> </style>
+1 -1
View File
@@ -203,7 +203,7 @@ export type GameCityDefault = {
path: Record<CityID, string>; path: Record<CityID, string>;
}; };
export type GameIActionCategory = "nationType" | "specialDomestic" | "specialWar" | "personality" | "item"; export type GameIActionCategory = "nationType" | "specialDomestic" | "specialWar" | "personality" | "item" | "crewtype";
export type GameIActionInfo = { export type GameIActionInfo = {
value: string; value: string;
+18 -10
View File
@@ -6,10 +6,13 @@
v-if="colValue.iActionMap" v-if="colValue.iActionMap"
v-b-tooltip.hover v-b-tooltip.hover
class="col" 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.iActionMap[params.data[colValue.target] as string ].name }}
</div> </div>
<div v-else-if="colValue.converter" v-b-tooltip.hover class="col" :title="colValue.converter(params.data)[1] ?? ''">
{{colValue.converter(params.data)[0]}}
</div>
<div v-else v-b-tooltip.hover class="col" :title="colValue.info ?? ''"> <div v-else v-b-tooltip.hover class="col" :title="colValue.info ?? ''">
{{params.data[colValue.target] as string}} {{params.data[colValue.target] as string}}
</div> </div>
@@ -18,21 +21,26 @@
</div> </div>
</template> </template>
<script lang="ts" setup> <script lang="ts">
import type { GeneralListItem } from "@/defs/API/Nation"; import type { GeneralListItemP2 } from "@/defs/API/Nation";
import type { GameIActionInfo } from "@/defs/GameObj"; import type { GameIActionInfo } from "@/defs/GameObj";
import type { CellClassParams } from "ag-grid-community"; import type { CellClassParams } from "ag-grid-community";
import type { PropType } from "vue";
interface GenCellClassParams extends CellClassParams { //제일 큰 타입 기준
data: GeneralListItem; export type GridCellInfo = {
}
type GridCellInfo = {
iActionMap?: Record<string, GameIActionInfo>; iActionMap?: Record<string, GameIActionInfo>;
info?: string; info?: string;
target: keyof GeneralListItem; converter?: (value: GeneralListItemP2)=>[string, string?],
target: keyof GeneralListItemP2;
}; };
</script>
<script lang="ts" setup>
import type { PropType } from "vue";
interface GenCellClassParams extends CellClassParams {
data: GeneralListItemP2;
}
const props = defineProps({ const props = defineProps({
params: { params: {