feat(WIP): processing, 출병 추가

- 장수 선택기 추가
- v-model 안 쓰는 바보짓 수정
- proc 전역 변수를 procRes로 묶음
This commit is contained in:
2021-12-18 16:00:53 +09:00
parent 3ef5c2aa6d
commit 03993052a3
16 changed files with 407 additions and 88 deletions
+1 -2
View File
@@ -6,14 +6,13 @@
:group-select="false"
label="searchText"
track-by="value"
open-direction="bottom"
:show-labels="false"
selectLabel="선택(엔터)"
selectGroupLabel=""
selectedLabel="선택됨"
deselectLabel="해제(엔터)"
deselectGroupLabel=""
placeholder=" 선택"
placeholder="도시 선택"
:maxHeight="400"
:searchable="searchMode"
>
+10 -7
View File
@@ -17,7 +17,7 @@
</div>
<div class="row">
<div class="col">
<CitySelect :cities="citiesMap" :modelValue="selectedCityID" />
<CitySelect :cities="citiesMap" v-model="selectedCityID" />
</div>
<div class="col">
<b-button @click="submit">{{ commandName }}</b-button>
@@ -44,10 +44,14 @@ import { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
declare const mapTheme: string;
declare const cities: [number, string][];
declare const currentCity: number;
declare const distanceList: Record<number, number[]>;
declare const commandName: string;
declare const currentCity: number;
declare const procRes: {
distanceList: Record<number, number[]>,
cities: [number, string][],
}
export default defineComponent({
components: {
MapLegacyTemplate,
@@ -69,10 +73,9 @@ export default defineComponent({
info?: string;
}
>();
for (const [id, name] of cities) {
for (const [id, name] of procRes.cities) {
citiesMap.set(id, { name });
}
console.log(citiesMap);
const selectedCityID = ref(currentCity);
@@ -94,7 +97,7 @@ export default defineComponent({
citiesMap: ref(citiesMap),
selectedCityID,
selectedCityObj: ref(undefined as MapCityParsed | undefined),
distanceList,
distanceList: procRes.distanceList,
commandName,
selected,
submit,
+7 -6
View File
@@ -17,7 +17,7 @@
</div>
<div class="row">
<div class="col">
<CitySelect :cities="citiesMap" :modelValue="selectedCityID" />
<CitySelect :cities="citiesMap" v-model="selectedCityID" />
</div>
<div class="col">
<b-button @click="submit">{{ commandName }}</b-button>
@@ -44,10 +44,12 @@ import { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
declare const mapTheme: string;
declare const cities: [number, string][];
declare const currentCity: number;
declare const distanceList: Record<number, number[]>;
declare const commandName: string;
declare const procRes: {
distanceList: Record<number, number[]>,
cities: [number, string][],
}
export default defineComponent({
components: {
MapLegacyTemplate,
@@ -69,10 +71,9 @@ export default defineComponent({
info?: string;
}
>();
for (const [id, name] of cities) {
for (const [id, name] of procRes.cities) {
citiesMap.set(id, { name });
}
console.log(citiesMap);
const selectedCityID = ref(currentCity);
@@ -94,7 +95,7 @@ export default defineComponent({
citiesMap: ref(citiesMap),
selectedCityID,
selectedCityObj: ref(undefined as MapCityParsed | undefined),
distanceList,
distanceList: procRes.distanceList,
commandName,
selected,
submit,
+5 -4
View File
@@ -17,7 +17,7 @@
</div>
<div class="row">
<div class="col">
<CitySelect :cities="citiesMap" :modelValue="selectedCityID" />
<CitySelect :cities="citiesMap" v-model="selectedCityID" />
</div>
<div class="col">
<b-button @click="submit">{{ commandName }}</b-button>
@@ -38,9 +38,11 @@ import { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
declare const mapTheme: string;
declare const cities: [number, string][];
declare const currentCity: number;
declare const commandName: string;
declare const procRes: {
cities: [number, string][],
}
export default defineComponent({
components: {
MapLegacyTemplate,
@@ -61,10 +63,9 @@ export default defineComponent({
info?: string;
}
>();
for (const [id, name] of cities) {
for (const [id, name] of procRes.cities) {
citiesMap.set(id, { name });
}
console.log(citiesMap);
const selectedCityID = ref(currentCity);
+95
View File
@@ -0,0 +1,95 @@
<template>
<v-multiselect
v-model="selectedGeneral"
:allow-empty="false"
:options="forFind"
:group-select="false"
label="searchText"
track-by="value"
:show-labels="false"
selectLabel="선택(엔터)"
selectGroupLabel=""
selectedLabel="선택됨"
deselectLabel="해제(엔터)"
deselectGroupLabel=""
placeholder="장수 선택"
:maxHeight="400"
:searchable="searchMode"
>
<template v-slot:option="props">
{{ props.option.title }}
</template>
<template v-slot:singleLabel="props">
{{ props.option.simpleName }}
</template>
</v-multiselect>
</template>
<script lang="ts">
import { filter초성withAlphabet } from "@/util/filter초성withAlphabet";
import { defineComponent, PropType } from "vue";
import { procGeneralList, procTroopList } from './processingRes';
type SelectedGeneral = {
value: number;
searchText: string;
title: string;
simpleName: string;
};
export default defineComponent({
props: {
modelValue: {
type: Number,
required: true,
},
generals: {
type: Array as PropType<procGeneralList>,
required: true,
},
cities: {
type: Map as PropType<Map<number, { name: string; info?: string }>>,
required: true,
},
troops: {
type: Object as PropType<procTroopList>,
}
},
emits: ["update:modelValue"],
watch: {
modelValue(val: number) {
const target = this.targets.get(val);
this.selectedGeneral = target;
},
selectedGeneral(val: SelectedGeneral){
this.$emit('update:modelValue', val.value);
}
},
data() {
const forFind = [];
const targets = new Map<number, SelectedGeneral>();
let selectedGeneral;
for (const gen of this.generals) {
const [filteredTextH, filteredTextA] = filter초성withAlphabet(gen.name);
const obj: SelectedGeneral = {
value: gen.no,
title: `${gen.name}[${this.cities.get(gen.cityID)?.name}] (${gen.leadership}/${gen.leadership}/${gen.intel}) <병${gen.crew.toLocaleString()}/훈${gen.train}/사${gen.atmos}`,
simpleName: gen.name,
searchText: `${gen.name} ${filteredTextH} ${filteredTextA}`
};
if (gen.no == this.modelValue) {
selectedGeneral = obj;
}
forFind.push(obj);
targets.set(gen.no, obj);
}
return {
selectedGeneral,
searchMode: true,
forFind,
targets,
};
},
});
</script>
+124 -2
View File
@@ -1,7 +1,129 @@
<template>
<TopBackBar :title="commandName" type="chief" />
<div class="bg0">
<MapLegacyTemplate
:isDetailMap="false"
:clickableAll="true"
:neutralView="true"
:useCachedMap="true"
:mapTheme="mapTheme"
v-model="selectedCityObj"
/>
<div>
선택된 도시로 아국 장수를 발령합니다.<br />
아국 도시로만 발령이 가능합니다.<br />
목록을 선택하거나 도시를 클릭하세요.<br />
</div>
<div class="row">
<div class="col-12 col-md-4">
<GeneralSelect
:cities="citiesMap"
:generals="generalList"
:troops="troops"
v-model="selectedGeneralID"
/>
</div>
<div class="col-12 col-md-4">
<CitySelect :cities="citiesMap" v-model="selectedCityID" />
</div>
<div class="col-12 col-md-4">
<b-button @click="submit">{{ commandName }}</b-button>
</div>
</div>
</div>
<BottomBar :title="commandName" />
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import MapLegacyTemplate, {
MapCityParsed,
} from "@/components/MapLegacyTemplate.vue";
import CitySelect from "@/processing/CitySelect.vue";
import GeneralSelect from "@/processing/GeneralSelect.vue";
import { defineComponent, ref } from "vue";
import { unwrap } from "@/util/unwrap";
import { Args } from "@/processing/args";
import TopBackBar from "@/components/TopBackBar.vue";
import BottomBar from "@/components/BottomBar.vue";
import {
convertGeneralList,
procGeneralKeyList,
procGeneralRawItemList,
procTroopList,
} from "../processingRes";
declare const mapTheme: string;
declare const currentCity: number;
declare const commandName: string;
declare const procRes: {
distanceList: Record<number, number[]>;
cities: [number, string][];
troops: procTroopList;
generals: procGeneralRawItemList;
generalsKey: procGeneralKeyList;
};
export default defineComponent({
});
components: {
MapLegacyTemplate,
CitySelect,
GeneralSelect,
TopBackBar,
BottomBar,
},
watch: {
selectedCityObj(city: MapCityParsed) {
this.selectedCityID = city.id;
},
},
setup() {
const citiesMap = new Map<
number,
{
name: string;
info?: string;
}
>();
for (const [id, name] of procRes.cities) {
citiesMap.set(id, { name });
}
const generalList = convertGeneralList(
procRes.generalsKey,
procRes.generals
);
const selectedCityID = ref(currentCity);
function selectedCity(cityID: number) {
selectedCityID.value = cityID;
}
const selectedGeneralID = ref(generalList[0].no);
async function submit(e: Event) {
const event = new CustomEvent<Args>("customSubmit", {
detail: {
destCityID: selectedCityID.value,
destGeneralID: selectedGeneralID.value,
},
});
unwrap(e.target).dispatchEvent(event);
}
return {
mapTheme: ref(mapTheme),
citiesMap: ref(citiesMap),
selectedCityID,
selectedGeneralID,
selectedCityObj: ref(undefined as MapCityParsed | undefined),
distanceList: procRes.distanceList,
troops: procRes.troops,
generalList,
commandName,
selectedCity,
submit,
};
},
});
</script>
+2 -2
View File
@@ -1,2 +1,2 @@
export * as che_발령 from "./che_발령.vue";
export * as che_포상 from "./che_포상.vue";
export { default as che_발령 } from "./che_발령.vue";
export { default as che_포상 } from "./che_포상.vue";
+54
View File
@@ -0,0 +1,54 @@
import { combineArray } from "@/util/combineArray";
export type procGeneralItem = {
no: number,
name: string,
officerLevel: number,
npc: number,
gold: number,
rice: number,
leadership: number,
strength: number,
intel: number,
cityID: number,
crew: number,
train: number,
atmos: number,
troopID: number,
}
export type procGeneralList = procGeneralItem[];
export type procGeneralKeyList = [
'no', 'name', 'officerLevel', 'npc', 'gold', 'rice', 'leadership', 'strength', 'intel', 'cityID', 'crew', 'train', 'atmos', 'troopID'
];
export type procGeneralRawItem = [
procGeneralItem[procGeneralKeyList[0]],
procGeneralItem[procGeneralKeyList[1]],
procGeneralItem[procGeneralKeyList[2]],
procGeneralItem[procGeneralKeyList[3]],
procGeneralItem[procGeneralKeyList[4]],
procGeneralItem[procGeneralKeyList[5]],
procGeneralItem[procGeneralKeyList[6]],
procGeneralItem[procGeneralKeyList[7]],
procGeneralItem[procGeneralKeyList[8]],
procGeneralItem[procGeneralKeyList[9]],
procGeneralItem[procGeneralKeyList[10]],
procGeneralItem[procGeneralKeyList[11]],
procGeneralItem[procGeneralKeyList[12]],
procGeneralItem[procGeneralKeyList[13]],
];
export type procTroopItem = {
troop_leader: number,
nation: number,
name: string
};
export type procTroopList = Record<number, procTroopItem>;
export type procGeneralRawItemList = procGeneralRawItem[];
export function convertGeneralList(keys: procGeneralKeyList, rawList: procGeneralRawItemList): procGeneralList{
return combineArray(rawList, keys) as procGeneralList;
}