From dba8e5d69997c51b45c5b34fb83c4381591dcb09 Mon Sep 17 00:00:00 2001 From: hide_d Date: Wed, 8 Dec 2021 21:22:52 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=84=B4=20=EC=84=A0=ED=83=9D=EA=B8=B0?= =?UTF-8?q?=20=EC=8B=A4=ED=96=89=20=ED=9B=84=20=EC=B4=88=EA=B8=B0=ED=99=94?= =?UTF-8?q?=EC=8B=9C,=20=EC=9D=B4=EC=A0=84=20=ED=84=B4=20=EA=B8=B0?= =?UTF-8?q?=EC=96=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/ts/ReservedCommand.vue | 67 ++++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/hwe/ts/ReservedCommand.vue b/hwe/ts/ReservedCommand.vue index c0f2a5a7..00dcabcb 100644 --- a/hwe/ts/ReservedCommand.vue +++ b/hwe/ts/ReservedCommand.vue @@ -58,15 +58,15 @@ :key="turnIdx" height="28" :id="`command_${turnIdx}`" - :class="pressed[turnIdx] ? 'pressed' : ''" + :class="turnList.has(turnIdx) ? 'pressed' : ''" >
this.maxTurn) { - this.pressed.fill(false); + if (this.turnList.size * 3 > this.maxTurn) { + this.turnList.clear(); } else { - this.pressed.fill(true); + for (let i = 0; i < this.maxTurn; i++) { + this.turnList.add(i); + } } }, selectStep(begin: number, step: number) { + this.turnList.clear(); for (const idx of range(0, maxTurn)) { if ((idx - begin) % step == 0) { - this.pressed[idx] = true; - } else { - this.pressed[idx] = false; + this.turnList.add(idx); } } }, @@ -439,12 +437,11 @@ export default defineComponent({ this.timeDiff = timeDiff; }, async reserveCommand() { - const turnList: number[] = []; - for (const [turnIdx, pressed] of this.pressed.entries()) { - if (!pressed) { - continue; - } - turnList.push(turnIdx); + let turnList: number[]; + if (this.turnList.size == 0) { + turnList = Array.from(this.prevTurnList.values()); + } else { + turnList = Array.from(this.turnList.values()); } if (turnList.length == 0) { @@ -469,7 +466,14 @@ export default defineComponent({ turnList, 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) { console.error(e); alert(`실패했습니다: ${e}`); @@ -492,9 +496,6 @@ export default defineComponent({ this.updateNow(); }, 1000 - serverNowObj.getMilliseconds()); - const pressed = Array.from({ length: maxTurn }).fill(false); - //pressed[0] = true; - const selectedCommand = commandList[0].values[0]; for (const subCategory of commandList) { for (const command of subCategory.values) { @@ -521,6 +522,9 @@ export default defineComponent({ time: "", }); + const prevTurnList = new Set([0]); + const turnList = new Set(); + return { maxTurn, flippedMaxTurn: 16, @@ -529,7 +533,8 @@ export default defineComponent({ commandList, serverNow: formatTime(serverNowObj, "HH:mm:ss"), timeDiff, - pressed, + prevTurnList, + turnList, selectedCommand, reservedCommandList: emptyTurn, autorun_limit: null as null | number,