feat: 부대장 발령 시 부대장 대신 부대 이름 표기

This commit is contained in:
2022-07-10 20:50:33 +09:00
parent 93490276fd
commit 94bb96d208
4 changed files with 69 additions and 10 deletions
@@ -63,9 +63,9 @@ class GetReservedCommand extends \sammo\BaseAPI
$nationTurnList = [];
foreach ($db->queryAllLists(
'SELECT officer_level, turn_idx, action, arg, brief FROM nation_turn WHERE nation_id = %i ORDER BY officer_level DESC, turn_idx ASC',
$me['nation']
) as [$officer_level, $turn_idx, $action, $arg, $brief]) {
'SELECT officer_level, turn_idx, action, arg, brief FROM nation_turn WHERE nation_id = %i ORDER BY officer_level DESC, turn_idx ASC',
$me['nation']
) as [$officer_level, $turn_idx, $action, $arg, $brief]) {
if (!key_exists($officer_level, $nationTurnList)) {
$nationTurnList[$officer_level] = [];
}
@@ -76,6 +76,14 @@ class GetReservedCommand extends \sammo\BaseAPI
];
}
$troopList = [];
foreach ($db->queryAllLists(
'SELECT troop_leader, `name` FROM troop WHERE `nation` = %i',
$nationID
) as [$troopID, $troopName]) {
$troopList[$troopID] = $troopName;
}
$nationChiefList = [];
foreach ($nationTurnList as $officer_level => $turnBrief) {
@@ -111,7 +119,8 @@ class GetReservedCommand extends \sammo\BaseAPI
'turnTerm' => $turnTerm,
'date' => TimeUtil::now(true),
'chiefList' => $nationChiefList,
'isChief'=>($me['officer_level'] > 4),
'troopList' => $troopList,
'isChief' => ($me['officer_level'] > 4),
'autorun_limit' => $generalObj->getAuxVar('autorun_limit'),
'officerLevel' => $me['officer_level'],
'commandList' => getChiefCommandTable($generalObj),
+16 -2
View File
@@ -2,7 +2,7 @@
<div id="container" class="pageChiefCenter">
<TopBackBar title="사령부" reloadable @reload="reloadTable" />
<div v-if="chiefList !== undefined" id="mainTable" :class="`${targetIsMe ? 'targetIsMe' : 'targetIsNotMe'}`">
<div v-if="asyncReady && chiefList !== undefined" id="mainTable" :class="`${targetIsMe ? 'targetIsMe' : 'targetIsNotMe'}`">
<template v-for="(chiefLevel, vidx) in [12, 10, 8, 6, 11, 9, 7, 5]" :key="chiefLevel">
<div v-if="vidx % 4 == 0" :class="['turnIdx', vidx == 0 && !targetIsMe ? undefined : 'only1000px']">
<div :class="['subRows', 'bg0']" :style="mainTableGridRows">
@@ -33,6 +33,7 @@
:turn="officer.turn"
:turnTerm="turnTerm"
:commandList="unwrap(commandList)"
:troopList="unwrap(troopList)"
:turnTime="officer.turnTime"
:maxTurn="maxChiefTurn"
:maxPushTurn="Math.floor(maxChiefTurn / 2)"
@@ -107,17 +108,30 @@ import { SammoAPI } from "./SammoAPI";
import { unwrap } from "@/util/unwrap";
import { StoredActionsHelper } from "./util/StoredActionsHelper";
import type { ChiefResponse } from "./defs/API/NationCommand";
import { getGameConstStore, type GameConstStore } from "./GameConstStore";
const props = defineProps({
maxChiefTurn: VueTypes.number.isRequired,
});
const asyncReady = ref<boolean>(false);
const gameConstStore = ref<GameConstStore>();
provide("gameConstStore", gameConstStore);
const storeP = getGameConstStore().then((store) => {
gameConstStore.value = store;
});
void Promise.all([storeP]).then(() => {
asyncReady.value = true;
});
const tableObj = reactive<Omit<OptionalFull<ChiefResponse>, "result">>({
lastExecute: undefined,
year: undefined,
month: undefined,
turnTerm: undefined,
date: undefined,
troopList: undefined,
chiefList: undefined,
isChief: undefined,
autorun_limit: undefined,
@@ -127,7 +141,7 @@ const tableObj = reactive<Omit<OptionalFull<ChiefResponse>, "result">>({
unitSet: undefined,
});
const { year, month, turnTerm, date, chiefList, officerLevel, commandList } = toRefs(tableObj);
const { year, month, turnTerm, date, chiefList, troopList, officerLevel, commandList } = toRefs(tableObj);
const viewTarget = ref<number | undefined>();
+39 -4
View File
@@ -187,7 +187,7 @@
</div>
</DragSelect>
<div :style="rowGridStyle">
<div v-for="(turnObj, turnIdx) in reservedCommandList" :key="turnIdx" class="turn_pad center">
<div v-for="(turnObj, turnIdx) in reservedCommandList.map(postFilterTurnBrief)" :key="turnIdx" class="turn_pad center">
<span v-b-tooltip.hover class="turn_text" :style="turnObj.style" :title="turnObj.tooltip">
<!-- eslint-disable-next-line vue/no-v-html -->
<span v-html="turnObj.brief" />
@@ -256,7 +256,7 @@
<script lang="ts" setup>
import addMinutes from "date-fns/esm/addMinutes";
import { stringifyUrl } from "query-string";
import { onMounted, ref, watch, type PropType, inject } from "vue";
import { onMounted, ref, watch, type PropType, inject, type Ref } from "vue";
import { formatTime } from "@util/formatTime";
import { joinYearMonth } from "@util/joinYearMonth";
import { mb_strwidth } from "@util/mb_strwidth";
@@ -276,6 +276,10 @@ import { BButton, BDropdownItem, BDropdownText, BButtonGroup, BDropdownDivider,
import CommandSelectForm from "@/components/CommandSelectForm.vue";
import SimpleClock from "@/components/SimpleClock.vue";
import type { ChiefResponse } from "@/defs/API/NationCommand";
import { unwrap } from "@/util/unwrap";
import { unwrap_err } from "@/util/unwrap_err";
import type { GameConstStore } from "@/GameConstStore";
import { pick as josaPick } from "@/util/JosaUtil";
type TurnObjWithTime = TurnObj & {
time: string;
@@ -308,13 +312,15 @@ const props = defineProps({
type: Object as PropType<ChiefResponse["commandList"]>,
required: true,
},
troopList: {
type: Object as PropType<ChiefResponse["troopList"]>,
required: true,
},
officer: {
type: Object as PropType<ChiefResponse["chiefList"][0]>,
required: true,
},
});
const basicModeRowHeight = 30;
const listReqArgCommand = new Set<string>();
@@ -439,6 +445,35 @@ async function pushNationCommand(amount: number) {
emit("raise-reload");
}
const gameConstStore = unwrap_err(
inject<Ref<GameConstStore>>("gameConstStore"),
Error,
"gameConstStore가 주입되지 않았습니다."
);
function postFilterTurnBrief(turnObj: TurnObjWithTime): TurnObjWithTime{
if(turnObj.action != 'che_발령'){
return turnObj;
}
const destGeneralID = unwrap(turnObj.arg.destGeneralID);
if(!(destGeneralID in props.troopList)){
return turnObj;
}
const troopName = props.troopList[destGeneralID];
const destCityID = unwrap(turnObj.arg.destCityID);
const destCityName = gameConstStore.value.cityConst[destCityID].name;
const josaRo = josaPick(destCityName, "로");
const brief = `${troopName}》【${destCityName}${josaRo} 발령`;
const tooltip = `${troopName}${turnObj.brief}`;
return {
...turnObj,
brief,
tooltip,
}
}
const queryActionHelper = new QueryActionHelper(props.maxTurn);
const reservedCommandList = queryActionHelper.reservedCommandList;
const prevSelectedTurnList = queryActionHelper.prevSelectedTurnList;
+1
View File
@@ -18,6 +18,7 @@ export type ChiefResponse = {
turn: TurnObj[];
}
>;
troopList: Record<number, string>;
isChief: boolean;
autorun_limit: number;
officerLevel: number;