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
{
/** 반환하는 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(),
+144 -47
View File
@@ -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<GeneralListResponse['env']>,
type: Object as PropType<GeneralListResponse["env"]>,
required: true,
}
},
});
const gameConstStore = unwrap(inject<Ref<GameConstStore>>("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<string, GameIActionInfo>;
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<ColDef>({
headerClass: "default-cell-header",
cellClass: centerCellClass,
floatingFilter: true,
width: 90,
width: 80,
});
const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>>>({
icon: {
headerName: "아이콘",
width: 64 + 24,
width: 64 + 16,
suppressSizeToFit: true,
resizable: false,
cellRenderer: (obj: GenValueParams) => {
@@ -195,7 +196,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
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<Partial<Record<headerType, GenColDef | GenColGroupDef>
children: [
{
headerName: "통|무|지",
width: 90,
width: 88,
cellRenderer: (obj: GenValueParams) => {
const gen = obj.data;
@@ -229,7 +230,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "leadership",
...sortableNumber,
columnGroupShow: "open",
width: 70,
width: 60,
type: "numericColumn",
},
{
@@ -237,14 +238,14 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
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<Partial<Record<headerType, GenColDef | GenColGroupDef>
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}<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;
},
filter: true,
cellClass: centerCellClass,
width: 90,
width: 70,
},
expDedLv: {
headerName: "명성",
@@ -271,7 +286,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
{
headerName: "/계급",
columnGroupShow: "closed",
width: 70,
width: 60,
cellRenderer: ({ data }: GenValueParams) => {
return `Lv ${data.explevel}<br>${data.dedLevelText}`;
},
@@ -279,17 +294,18 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
{
headerName: "명성",
field: "explevel",
width: 75,
width: 60,
cellRenderer: ({ data }: GenValueParams) => {
return `Lv ${data.explevel}<br>(${data.honorText})`;
},
...sortableNumber,
cellClass: centerCellClass,
columnGroupShow: "open",
},
{
headerName: "계급",
field: "dedLevelText",
width: 75,
width: 70,
cellRenderer: ({ data }: GenValueParams) => {
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 },
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}<br>${data.atmos}`;
},
},
],
},
specials: {
headerName: "성격/내특/전특",
headerName: "특",
children: [
{
headerName: "요약",
@@ -319,7 +361,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
];
})(),
},
width: 90,
width: 80,
columnGroupShow: "closed",
},
{
@@ -329,7 +371,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellRendererParams: {
iActionMap: gameConstStore.value.iActionInfo.personality,
},
width: 70,
width: 60,
sortable: true,
filter: true,
columnGroupShow: "open",
@@ -341,7 +383,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellRendererParams: {
iActionMap: gameConstStore.value.iActionInfo.specialDomestic,
},
width: 70,
width: 60,
sortable: true,
filter: true,
columnGroupShow: "open",
@@ -353,7 +395,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
cellRendererParams: {
iActionMap: gameConstStore.value.iActionInfo.specialWar,
},
width: 70,
width: 60,
sortable: true,
filter: true,
columnGroupShow: "open",
@@ -365,6 +407,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
children: [
{
headerName: "요약",
width: 60,
cellRenderer: ({ data }: GenValueParams) => {
return `${data.age}세<br>${data.belong}`;
},
@@ -376,7 +419,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
field: "age",
...sortableNumber,
valueFormatter: (v: GenValueParams) => `${v.value}`,
width: 70,
width: 60,
cellClass: centerCellClass,
columnGroupShow: "open",
},
@@ -385,12 +428,55 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
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("<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: {
headerName: "기타",
children: [
@@ -401,6 +487,7 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
},
cellClass: rightAlignClass,
columnGroupShow: "closed",
width: 70,
},
{
headerName: "삭턴",
@@ -409,15 +496,17 @@ const columnRawDefs = ref<Partial<Record<headerType, GenColDef | GenColGroupDef>
return `${data.killturn.toLocaleString()}`;
},
...sortableNumber,
width: 70,
columnGroupShow: "open",
},
{
headerName: "벌점",
field: "connect",
cellRenderer: ({ data }: GenValueParams) => {
return `${data.connect.toLocaleString()}`;
return `${data.connect.toLocaleString()}<br>(${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);
});
*/
</script>
<style scoped lang="scss">
@@ -495,5 +572,25 @@ window.addEventListener("resize", (e) => {
.cell-sp .col {
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>
+1 -1
View File
@@ -203,7 +203,7 @@ export type GameCityDefault = {
path: Record<CityID, string>;
};
export type GameIActionCategory = "nationType" | "specialDomestic" | "specialWar" | "personality" | "item";
export type GameIActionCategory = "nationType" | "specialDomestic" | "specialWar" | "personality" | "item" | "crewtype";
export type GameIActionInfo = {
value: string;
+18 -10
View File
@@ -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 }}
</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 ?? ''">
{{params.data[colValue.target] as string}}
</div>
@@ -18,21 +21,26 @@
</div>
</template>
<script lang="ts" setup>
import type { GeneralListItem } from "@/defs/API/Nation";
<script lang="ts">
import type { GeneralListItemP2 } from "@/defs/API/Nation";
import type { GameIActionInfo } from "@/defs/GameObj";
import type { CellClassParams } from "ag-grid-community";
import type { PropType } from "vue";
interface GenCellClassParams extends CellClassParams {
data: GeneralListItem;
}
type GridCellInfo = {
//제일 큰 타입 기준
export type GridCellInfo = {
iActionMap?: Record<string, GameIActionInfo>;
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({
params: {