feat: 턴 선택기 실행 후 초기화시, 이전 턴 기억
This commit is contained in:
+36
-31
@@ -58,15 +58,15 @@
|
|||||||
:key="turnIdx"
|
:key="turnIdx"
|
||||||
height="28"
|
height="28"
|
||||||
:id="`command_${turnIdx}`"
|
:id="`command_${turnIdx}`"
|
||||||
:class="pressed[turnIdx] ? 'pressed' : ''"
|
:class="turnList.has(turnIdx) ? 'pressed' : ''"
|
||||||
>
|
>
|
||||||
<div class="idx_pad center d-grid" @click="toggleTurn(turnIdx)">
|
<div class="idx_pad center d-grid" @click="toggleTurn(turnIdx)">
|
||||||
<b-button
|
<b-button
|
||||||
size="sm"
|
size="sm"
|
||||||
:variant="
|
:variant="
|
||||||
pressed[turnIdx]
|
turnList.has(turnIdx)
|
||||||
? 'info'
|
? 'info'
|
||||||
: turnIdx == 0 && pressed.filter((t) => t).length == 0
|
: turnList.size == 0 && prevTurnList.has(turnIdx)
|
||||||
? 'success'
|
? 'success'
|
||||||
: 'primary'
|
: 'primary'
|
||||||
"
|
"
|
||||||
@@ -138,7 +138,7 @@
|
|||||||
<b-button
|
<b-button
|
||||||
:pressed="searchMode"
|
:pressed="searchMode"
|
||||||
@click="searchCommand()"
|
@click="searchCommand()"
|
||||||
:variant="searchMode?'info':'primary'"
|
:variant="searchMode ? 'info' : 'primary'"
|
||||||
v-b-tooltip.hover
|
v-b-tooltip.hover
|
||||||
title="검색 기능을 활성화합니다."
|
title="검색 기능을 활성화합니다."
|
||||||
><i class="bi bi-search"></i
|
><i class="bi bi-search"></i
|
||||||
@@ -301,11 +301,15 @@ export default defineComponent({
|
|||||||
}, 1000 - serverNow.getMilliseconds());
|
}, 1000 - serverNow.getMilliseconds());
|
||||||
},
|
},
|
||||||
toggleTurn(turnIdx: number) {
|
toggleTurn(turnIdx: number) {
|
||||||
this.pressed[turnIdx] = !this.pressed[turnIdx];
|
if (this.turnList.has(turnIdx)) {
|
||||||
|
this.turnList.delete(turnIdx);
|
||||||
|
} else {
|
||||||
|
this.turnList.add(turnIdx);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
selectTurn(turnIdx: number) {
|
selectTurn(turnIdx: number) {
|
||||||
this.pressed.fill(false);
|
this.turnList.clear();
|
||||||
this.pressed[turnIdx] = true;
|
this.turnList.add(turnIdx);
|
||||||
},
|
},
|
||||||
selectAll(e: Event | true) {
|
selectAll(e: Event | true) {
|
||||||
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
//NOTE: split 구현에 버그가 있어서, 수동으로 구분해야함
|
||||||
@@ -313,25 +317,19 @@ export default defineComponent({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let pressedCnt = 0;
|
if (this.turnList.size * 3 > this.maxTurn) {
|
||||||
for (const pressed of this.pressed) {
|
this.turnList.clear();
|
||||||
if (pressed) {
|
|
||||||
pressedCnt += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pressedCnt * 3 > this.maxTurn) {
|
|
||||||
this.pressed.fill(false);
|
|
||||||
} else {
|
} else {
|
||||||
this.pressed.fill(true);
|
for (let i = 0; i < this.maxTurn; i++) {
|
||||||
|
this.turnList.add(i);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
selectStep(begin: number, step: number) {
|
selectStep(begin: number, step: number) {
|
||||||
|
this.turnList.clear();
|
||||||
for (const idx of range(0, maxTurn)) {
|
for (const idx of range(0, maxTurn)) {
|
||||||
if ((idx - begin) % step == 0) {
|
if ((idx - begin) % step == 0) {
|
||||||
this.pressed[idx] = true;
|
this.turnList.add(idx);
|
||||||
} else {
|
|
||||||
this.pressed[idx] = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -439,12 +437,11 @@ export default defineComponent({
|
|||||||
this.timeDiff = timeDiff;
|
this.timeDiff = timeDiff;
|
||||||
},
|
},
|
||||||
async reserveCommand() {
|
async reserveCommand() {
|
||||||
const turnList: number[] = [];
|
let turnList: number[];
|
||||||
for (const [turnIdx, pressed] of this.pressed.entries()) {
|
if (this.turnList.size == 0) {
|
||||||
if (!pressed) {
|
turnList = Array.from(this.prevTurnList.values());
|
||||||
continue;
|
} else {
|
||||||
}
|
turnList = Array.from(this.turnList.values());
|
||||||
turnList.push(turnIdx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (turnList.length == 0) {
|
if (turnList.length == 0) {
|
||||||
@@ -469,7 +466,14 @@ export default defineComponent({
|
|||||||
turnList,
|
turnList,
|
||||||
action: commandName,
|
action: commandName,
|
||||||
});
|
});
|
||||||
this.pressed.fill(false);
|
|
||||||
|
if (this.turnList.size > 0) {
|
||||||
|
this.prevTurnList.clear();
|
||||||
|
for (const v of this.turnList) {
|
||||||
|
this.prevTurnList.add(v);
|
||||||
|
}
|
||||||
|
this.turnList.clear();
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e);
|
console.error(e);
|
||||||
alert(`실패했습니다: ${e}`);
|
alert(`실패했습니다: ${e}`);
|
||||||
@@ -492,9 +496,6 @@ export default defineComponent({
|
|||||||
this.updateNow();
|
this.updateNow();
|
||||||
}, 1000 - serverNowObj.getMilliseconds());
|
}, 1000 - serverNowObj.getMilliseconds());
|
||||||
|
|
||||||
const pressed = Array.from<boolean>({ length: maxTurn }).fill(false);
|
|
||||||
//pressed[0] = true;
|
|
||||||
|
|
||||||
const selectedCommand = commandList[0].values[0];
|
const selectedCommand = commandList[0].values[0];
|
||||||
for (const subCategory of commandList) {
|
for (const subCategory of commandList) {
|
||||||
for (const command of subCategory.values) {
|
for (const command of subCategory.values) {
|
||||||
@@ -521,6 +522,9 @@ export default defineComponent({
|
|||||||
time: "",
|
time: "",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const prevTurnList = new Set([0]);
|
||||||
|
const turnList = new Set<number>();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
maxTurn,
|
maxTurn,
|
||||||
flippedMaxTurn: 16,
|
flippedMaxTurn: 16,
|
||||||
@@ -529,7 +533,8 @@ export default defineComponent({
|
|||||||
commandList,
|
commandList,
|
||||||
serverNow: formatTime(serverNowObj, "HH:mm:ss"),
|
serverNow: formatTime(serverNowObj, "HH:mm:ss"),
|
||||||
timeDiff,
|
timeDiff,
|
||||||
pressed,
|
prevTurnList,
|
||||||
|
turnList,
|
||||||
selectedCommand,
|
selectedCommand,
|
||||||
reservedCommandList: emptyTurn,
|
reservedCommandList: emptyTurn,
|
||||||
autorun_limit: null as null | number,
|
autorun_limit: null as null | number,
|
||||||
|
|||||||
Reference in New Issue
Block a user