diff --git a/hwe/a_history.php b/hwe/a_history.php
index 1d8d9390..94473d95 100644
--- a/hwe/a_history.php
+++ b/hwe/a_history.php
@@ -203,9 +203,13 @@ $nations = $history['nations'];
= banner() ?> |
+ = WebUtil::printStaticValues([
+ 'staticValues' => [
+ 'serverNick' => DB::prefix(),
+ 'serverID' => UniqueConst::$serverID,
+ ]
+ ])?>
+
+
\ No newline at end of file
diff --git a/hwe/ts/components/DragSelect.vue b/hwe/ts/components/DragSelect.vue
index 53ba12c0..a2381e83 100644
--- a/hwe/ts/components/DragSelect.vue
+++ b/hwe/ts/components/DragSelect.vue
@@ -1,12 +1,14 @@
@@ -58,6 +60,11 @@ export default defineComponent({
required: false,
default: () => ref(new Set()),
},
+ disabled: {
+ type: Boolean,
+ required: false,
+ default: false,
+ }
},
emits: ["update:modelValue", "dragDone", "dragStart"],
setup(props, { emit }) {
@@ -138,6 +145,9 @@ export default defineComponent({
let isMine = false;
function startDrag(e: MouseEvent | Touch) {
+ if (props.disabled) {
+ return;
+ }
containerRect = uContainer.getBoundingClientRect();
children = uContainer.children;
start = getCoords(e);
@@ -152,6 +162,9 @@ export default defineComponent({
emit("dragStart");
}
function drag(e: MouseEvent | Touch) {
+ if (props.disabled) {
+ return;
+ }
end = getCoords(e);
const dimensions = getDimensions(start, end);
if (end.x < start.x) {
@@ -165,6 +178,9 @@ export default defineComponent({
intersection();
}
function endDrag() {
+ if (props.disabled) {
+ return;
+ }
start = { x: 0, y: 0 };
end = { x: 0, y: 0 };
box.style.width = "0";
@@ -172,16 +188,34 @@ export default defineComponent({
document.removeEventListener("mousemove", drag);
document.removeEventListener("touchmove", touchMove);
box.remove();
- if(isMine){
- emit("dragDone", intersected.value);
+ if (isMine) {
+ emit("dragDone", intersected.value);
}
isMine = false;
}
- uContainer.addEventListener("mousedown", startDrag);
- uContainer.addEventListener("touchstart", touchStart);
- document.addEventListener("mouseup", endDrag);
- document.addEventListener("touchend", endDrag);
+ watch(() => props.disabled, disabledNext => {
+ if (disabledNext) {
+ uContainer.removeEventListener("mousedown", startDrag);
+ uContainer.removeEventListener("touchstart", touchStart);
+ document.removeEventListener("mouseup", endDrag);
+ document.removeEventListener("touchend", endDrag);
+ }
+ else {
+ uContainer.addEventListener("mousedown", startDrag);
+ uContainer.addEventListener("touchstart", touchStart);
+ document.addEventListener("mouseup", endDrag);
+ document.addEventListener("touchend", endDrag);
+ }
+ });
+
+ if (!props.disabled) {
+ uContainer.addEventListener("mousedown", startDrag);
+ uContainer.addEventListener("touchstart", touchStart);
+ document.addEventListener("mouseup", endDrag);
+ document.addEventListener("touchend", endDrag);
+ }
+
onBeforeUnmount(() => {
uContainer.removeEventListener("mousedown", startDrag);
diff --git a/hwe/ts/defs.ts b/hwe/ts/defs.ts
index 870a0e9c..bf95199b 100644
--- a/hwe/ts/defs.ts
+++ b/hwe/ts/defs.ts
@@ -1,3 +1,5 @@
+import type { Args } from "./processing/args";
+
export type InvalidResponse = {
result: false;
reason: string;
@@ -33,6 +35,11 @@ export type GeneralListResponse = {
token: Record,
}
+export type ReserveCommandResponse = {
+ result: true,
+ brief: string,
+}
+
export type NationLevel = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7;
export const NationLevelText: Record = {
0: '방랑군',
@@ -176,13 +183,14 @@ export type OptionalFull = {
export type TurnObj = {
action: string;
brief: string;
- arg: null | [] | Record;
+ arg: Args;
};
export type CommandItem = {
value: string;
title: string;
+ info: string,
compensation: number;
simpleName: string;
possible: boolean;
@@ -215,6 +223,8 @@ export type ChiefResponse = {
category: string;
values: CommandItem[];
}[];
+ mapName: string,
+ unitSet: string,
};
@@ -250,4 +260,4 @@ export type BettingInfo = {
closeYearMonth: number;
candidates: SelectItem[];
winner?: number[];
-}
\ No newline at end of file
+}
diff --git a/hwe/ts/map.ts b/hwe/ts/map.ts
index 614ba5fc..405fd698 100644
--- a/hwe/ts/map.ts
+++ b/hwe/ts/map.ts
@@ -9,8 +9,12 @@ import { exportWindow } from '@util/exportWindow';
import { htmlReady } from './util/htmlReady';
import { initTooltip } from './legacy/initTooltip';
-declare const serverNick: string;
-declare const serverID: string;
+declare const staticValues: {
+ serverNick: string;
+ serverID: string;
+}
+
+const { serverNick, serverID } = staticValues;
type CityPositionMap = {
[cityID: number]: [string, number, number];
diff --git a/hwe/ts/util/StoredActionsHelper.ts b/hwe/ts/util/StoredActionsHelper.ts
new file mode 100644
index 00000000..70f3cf87
--- /dev/null
+++ b/hwe/ts/util/StoredActionsHelper.ts
@@ -0,0 +1,60 @@
+import type { TurnObj } from '@/defs';
+import { ref } from 'vue';
+
+
+export class StoredActionsHelper {
+ public readonly recentActions = ref([]);
+ public readonly storedActions = ref(new Map());
+ public readonly recentActionsKey: string;
+ public readonly storedActionsKey: string;
+
+ constructor(protected serverNick: string, protected type: 'general' | 'nation', protected mapName: string, protected unitSet: string, protected maxRecent = 10) {
+ this.recentActionsKey = `${serverNick}_${mapName}_${unitSet}_${type}RecentActions`;
+ this.storedActionsKey = `${serverNick}_${mapName}_${unitSet}_${type}StoredActions`;
+ this.loadRecentActions();
+ this.loadStoredActions();
+ }
+
+ loadRecentActions() {
+ this.recentActions.value = JSON.parse(localStorage.getItem(this.recentActionsKey) ?? '[]');
+ }
+
+ pushRecentActions(action: TurnObj) {
+ this.recentActions.value.unshift(action);
+ if (this.recentActions.value.length > this.maxRecent) {
+ this.recentActions.value.pop();
+ }
+ this.saveRecentActions();
+ }
+
+ saveRecentActions() {
+ localStorage.setItem(this.recentActionsKey, JSON.stringify(this.recentActions.value));
+ }
+
+ loadStoredActions() {
+ const rawValue: [string, [number[], TurnObj][]][] = JSON.parse(
+ localStorage.getItem(this.storedActionsKey) ?? '[]'
+ );
+ this.storedActions.value = new Map(rawValue);
+ }
+
+ setStoredActions(actionKey: string, actions: [number[], TurnObj][]) {
+ this.storedActions.value.set(actionKey, actions);
+ console.log(this.storedActions.value);
+ this.saveStoredActions();
+ }
+
+ deleteStoredActions(actionKey: string) {
+ if (this.storedActions.value.delete(actionKey)) {
+ this.saveStoredActions();
+ }
+ }
+
+ saveStoredActions() {
+ localStorage.setItem(
+ this.storedActionsKey,
+ JSON.stringify(Array.from(this.storedActions.value.entries()))
+ );
+ }
+
+}
\ No newline at end of file
diff --git a/hwe/ts/v_processing.ts b/hwe/ts/v_processing.ts
index a2d86a4b..ce31d859 100644
--- a/hwe/ts/v_processing.ts
+++ b/hwe/ts/v_processing.ts
@@ -9,11 +9,20 @@ import { type App, createApp } from 'vue';
import { auto500px } from './util/auto500px';
import { isString } from 'lodash';
import { type Args, testSubmitArgs } from './processing/args';
-import { SammoAPI, type ValidResponse } from './SammoAPI';
+import { SammoAPI } from './SammoAPI';
+import { StoredActionsHelper } from './util/StoredActionsHelper';
+import type { ReserveCommandResponse } from './defs';
-declare const turnList: number[];
+declare const staticValues: {
+ serverNick: string,
+ turnList: number[],
+ mapName: string,
+ unitSet: string,
+};
-async function submitCommand(isChiefTurn: boolean, turnList: number[], action: string, arg: Args): Promise {
+const { turnList } = staticValues;
+
+async function submitCommand(isChiefTurn: boolean, turnList: number[], action: string, arg: Args): Promise {
const targetAPI = isChiefTurn ? SammoAPI.NationCommand.ReserveCommand : SammoAPI.Command.ReserveCommand;
try {
@@ -22,19 +31,28 @@ async function submitCommand(isChiefTurn: boolean, turn
throw new TypeError(`Invalied Type ${testResult[0]}, ${testResult[2]} should be ${testResult[1]}`);
}
console.log('trySubmit', arg);
- const response = await targetAPI({
+ const responseP = targetAPI({
action,
turnList,
arg,
});
+ const storedActionsHelper = new StoredActionsHelper(staticValues.serverNick, isChiefTurn?'nation':'general', staticValues.mapName, staticValues.unitSet);
+
+ const response = await responseP;
+ storedActionsHelper.pushRecentActions({
+ action,
+ brief: response.brief,
+ arg: (arg??{}),
+ })
+
if (!isChiefTurn) {
window.location.href = './';
} else {
window.location.href = 'v_chiefCenter.php';
}
- return response as T;
+ return response;
}
catch (e) {
console.error(e);
diff --git a/hwe/v_processing.php b/hwe/v_processing.php
index e577fc53..3dd203ca 100644
--- a/hwe/v_processing.php
+++ b/hwe/v_processing.php
@@ -76,13 +76,22 @@ if (!$commandObj->hasPermissionToReserve()) {
= WebUtil::printJS('../d_shared/common_path.js') ?>
= WebUtil::printJS('d_shared/base_map.js') ?>
= WebUtil::printStaticValues([
- 'serverNick' => DB::prefix(),
- 'serverID' => UniqueConst::$serverID,
+ 'staticValues' => [
+ 'serverNick' => DB::prefix(),
+ 'serverID' => UniqueConst::$serverID,
+ 'commandName' => $commandObj->getName(),
+ 'turnList' => $turnList,
+ 'currentCity' => $general->getCityID(),
+ 'currentNation' => $general->getNationID(),
+ 'entryInfo' => [$isChiefTurn?'Nation':'General', $commandType],
+ 'mapName' => GameConst::$mapName,
+ 'unitSet' => GameConst::$unitSet,
+ ],
'commandName' => $commandObj->getName(),
'turnList' => $turnList,
'currentCity' => $general->getCityID(),
'currentNation' => $general->getNationID(),
- 'entryInfo' => [$isChiefTurn?'Nation':'General', $commandType]
+ 'entryInfo' => [$isChiefTurn?'Nation':'General', $commandType],
])?>
= WebUtil::printStaticValues($commandObj->exportJSVars(), false) ?>