diff --git a/hwe/func_command.php b/hwe/func_command.php index d66beebc..d8b6ac8c 100644 --- a/hwe/func_command.php +++ b/hwe/func_command.php @@ -393,6 +393,7 @@ function setGeneralCommand(int $generalID, array $rawTurnList, string $command, _setGeneralCommand($commandObj, $turnList); return [ 'result'=>true, + 'brief'=>$commandObj->getBrief(), 'reason'=>'success' ]; } @@ -474,6 +475,7 @@ function setNationCommand(int $generalID, array $turnList, string $command, ?arr _setNationCommand($commandObj, $turnList); return [ 'result'=>true, + 'brief'=>$commandObj->getBrief(), 'arg_test'=>true, 'reason'=>'success' ]; diff --git a/hwe/ts/PartialReservedCommand.vue b/hwe/ts/PartialReservedCommand.vue index 24958d21..20d3591c 100644 --- a/hwe/ts/PartialReservedCommand.vue +++ b/hwe/ts/PartialReservedCommand.vue @@ -3,47 +3,12 @@

명령 목록

-
-
-
- 취소 -
-
- {{ selectedCommand.simpleName }} ▾ -
-
- 실행 -
-
-
-
- 고급 모드 - - 해제 - 모든턴 - 홀수턴 - 짝수턴 - - - - {{ spanIdx }}턴 간격 -
- - {{ beginIdx }} - -
-
+ {{ isEditMode ? '일반 모드로' : '고급 모드로' }}
+
+
+
+ + 해제 + 모든턴 + 홀수턴 + 짝수턴 + + + + {{ spanIdx }}턴 간격 +
+ + {{ beginIdx }} + +
+
+
+
+ + + +
+
+ + +  잘라내기 + + +  복사하기 + + +  붙여넣기 + + + +  보관하기 + + +  반복하기 + + + +  비우기 + + +  지우고 당기기 + + +  뒤로 밀기 + + + +
+ +
+ + {{ action.brief }} + +
+
+ 명령 선택 ▾ +
+
+
+
- +
- + @@ -269,16 +311,12 @@ import { mb_strwidth } from "@util/mb_strwidth"; import { parseTime } from "@util/parseTime"; import { parseYearMonth } from "@util/parseYearMonth"; import DragSelect from "@/components/DragSelect.vue"; -import { SammoAPI } from "./SammoAPI"; -import type { CommandItem } from "@/defs"; +import { SammoAPI, type InvalidResponse } from "./SammoAPI"; +import type { CommandItem, ReserveCommandResponse } from "@/defs"; import CommandSelectForm from "@/components/CommandSelectForm.vue"; import { BButton, BButtonGroup, BDropdownItem, BDropdown, BDropdownText, BDropdownDivider } from "bootstrap-vue-3"; - -type TurnObj = { - action: string; - brief: string; - arg: null | [] | Record; -}; +import { StoredActionsHelper } from "./util/StoredActionsHelper"; +import type { TurnObj } from '@/defs'; type TurnObjWithTime = TurnObj & { time: string; @@ -362,7 +400,7 @@ setTimeout(() => { const emptyTurn: TurnObjWithTime[] = Array.from({ length: staticValues.maxTurn, }).fill({ - arg: null, + arg: {}, brief: "", action: "", year: undefined, @@ -375,17 +413,20 @@ const editModeKey = `sammo_edit_mode_key`; const prevTurnList = ref(new Set([0])); const turnList = ref(new Set()); const reservedCommandList = ref(emptyTurn); -const isEditMode = ref(localStorage.getItem(editModeKey)==='1'); +const isEditMode = ref(localStorage.getItem(editModeKey) === '1'); -const flippedMaxTurn = 15; +const flippedMaxTurn = 14; + +const editModeRowHeight = 29.35; +const basicModeRowHeight = 34.4; const viewMaxTurn = ref(flippedMaxTurn); const rowGridStyle = ref({ display: "grid", - gridTemplateRows: `repeat(${viewMaxTurn.value}, 29.4px)`, + gridTemplateRows: `repeat(${viewMaxTurn.value}, ${isEditMode.value ? editModeRowHeight : basicModeRowHeight}px)`, }); -watch(viewMaxTurn, (val) => { - rowGridStyle.value.gridTemplateRows = `repeat(${val}, 29.4px)`; +watch([isEditMode, viewMaxTurn], ([isEditMode, maxTurn]) => { + rowGridStyle.value.gridTemplateRows = `repeat(${maxTurn}, ${isEditMode ? editModeRowHeight : basicModeRowHeight}px)`; }); const isDragSingle = ref(false); @@ -484,12 +525,15 @@ async function pushGeneralCommand(amount: number) { await reloadCommandList(); } -/* + function pushGeneralCommandSingle(e: Event) { //NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함 if (isDropdownChildren(e)) { return; } + if (!isEditMode.value) { + return; + } void pushGeneralCommand(1); } @@ -498,9 +542,12 @@ function pullGeneralCommandSingle(e: Event) { if (isDropdownChildren(e)) { return; } + if (!isEditMode.value) { + return; + } void pushGeneralCommand(-1); } -*/ + async function reloadCommandList() { let result: ReservedCommandResponse; @@ -563,6 +610,41 @@ async function reloadCommandList() { timeDiff.value = serverNow.value.getTime() - clientNow.value.getTime(); } +async function reserveCommandDirect(args: [number[], TurnObj][], reload = true): Promise { + const waiterList: Promise[] = []; + for (const [turnList, { action, arg }] of args) { + waiterList.push( + SammoAPI.Command.ReserveCommand({ + turnList, + action, + arg, + }, true) + ); + } + + let success = true; + for (const [idx, waiter] of waiterList.entries()) { + try { + const response = await waiter; + if (!response.result) { + const message = `${args[idx][0].join(',')}을 예약하지 못했습니다: ${response.reason}` + console.error(message, args[idx][1]); + alert(message); + success = false; + } + } + catch (e) { + const message = `${args[idx][0].join(',')}을 예약하지 못했습니다: ${e}` + console.error(message, args[idx][1]); + success = false; + } + } + if (reload) { + await reloadCommandList(); + } + return success; +} + async function reserveCommand() { let reqTurnList: number[]; if (turnList.value.size == 0) { @@ -589,11 +671,17 @@ async function reserveCommand() { } try { - await SammoAPI.Command.ReserveCommand({ + const result = await SammoAPI.Command.ReserveCommand({ turnList: reqTurnList, action: commandName, }); + storedActionsHelper.pushRecentActions({ + action: commandName, + brief: result.brief, + arg: {} + }); + if (turnList.value.size > 0) { prevTurnList.value.clear(); for (const v of turnList.value) { @@ -614,6 +702,7 @@ function chooseCommand(val?: string) { return; } selectedCommand.value = invCommandMap[val]; + void reserveCommand(); } const commandQuickReserveForm = ref | null>(null); @@ -637,13 +726,9 @@ function toggleQuickReserveForm(turnIdx: number) { commandQuickReserveForm.value?.show(); } -onMounted(() => { - void reloadCommandList(); -}); - watch(isEditMode, newEditMode => { - localStorage.setItem(editModeKey, newEditMode?'1':'0'); + localStorage.setItem(editModeKey, newEditMode ? '1' : '0'); if (newEditMode) { commandQuickReserveForm.value?.close(); currentQuickReserveTarget.value = -1; @@ -653,6 +738,15 @@ watch(isEditMode, newEditMode => { } }); +const storedActionsHelper = new StoredActionsHelper(staticValues.serverNick, 'general'); + +const recentActions = storedActionsHelper.recentActions; +const storedActions = storedActionsHelper.storedActions; + +onMounted(() => { + void reloadCommandList(); +}); +