-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix(frontend): リバーシの対局中に制限時間の経過が実際より遅く計測されることがある問題を修正 #17770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,29 +279,30 @@ function putStone(pos: number) { | |
| }); | ||
| appliedOps.push(id); | ||
|
|
||
| myTurnTimerRmain.value = game.value.timeLimitForEachTurn; | ||
| opTurnTimerRmain.value = game.value.timeLimitForEachTurn; | ||
| resetTurnTimer(); | ||
|
|
||
| checkEnd(); | ||
| } | ||
|
|
||
| const myTurnTimerRmain = ref<number>(game.value.timeLimitForEachTurn); | ||
| const opTurnTimerRmain = ref<number>(game.value.timeLimitForEachTurn); | ||
| let turnTimerDeadline = Date.now() + game.value.timeLimitForEachTurn * 1000; | ||
|
|
||
| function resetTurnTimer() { | ||
| turnTimerDeadline = Date.now() + game.value.timeLimitForEachTurn * 1000; | ||
| myTurnTimerRmain.value = game.value.timeLimitForEachTurn; | ||
| opTurnTimerRmain.value = game.value.timeLimitForEachTurn; | ||
| } | ||
|
|
||
| const TIMER_INTERVAL_SEC = 3; | ||
| if (!props.game.isEnded) { | ||
| useInterval(() => { | ||
| if (myTurnTimerRmain.value > 0) { | ||
| myTurnTimerRmain.value = Math.max(0, myTurnTimerRmain.value - TIMER_INTERVAL_SEC); | ||
| } | ||
| if (opTurnTimerRmain.value > 0) { | ||
| opTurnTimerRmain.value = Math.max(0, opTurnTimerRmain.value - TIMER_INTERVAL_SEC); | ||
| } | ||
| const remain = Math.max(0, Math.ceil((turnTimerDeadline - Date.now()) / 1000)); | ||
| myTurnTimerRmain.value = remain; | ||
| opTurnTimerRmain.value = remain; | ||
|
|
||
| if (iAmPlayer.value) { | ||
| if ((isMyTurn.value && myTurnTimerRmain.value === 0) || (!isMyTurn.value && opTurnTimerRmain.value === 0)) { | ||
| props.connection!.send('claimTimeIsUp', {}); | ||
| } | ||
| if (iAmPlayer.value && remain === 0) { | ||
| props.connection!.send('claimTimeIsUp', {}); | ||
|
Comment on lines
317
to
+325
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== game.board.vue around target ==\n'
sed -n '240,360p' packages/frontend/src/pages/reversi/game.board.vue
printf '\n== search useInterval implementation/usages ==\n'
rg -n "function useInterval|const useInterval|export .*useInterval|useInterval\(" packages/frontend/src -g '!**/*.map'
printf '\n== search claimTimeIsUp and end/start checks in reversi page ==\n'
rg -n "claimTimeIsUp|isEnded|isStarted|checkEnd\\(" packages/frontend/src/pages/reversi packages/frontend/src -g '!**/*.map'Repository: misskey-dev/misskey Length of output: 14429 🏁 Script executed: #!/bin/bash
set -euo pipefail
printf '\n== game.vue around GameBoard mount conditions ==\n'
sed -n '1,170p' packages/frontend/src/pages/reversi/game.vue
printf '\n== checkEnd() and related timer reset logic ==\n'
sed -n '360,430p' packages/frontend/src/pages/reversi/game.board.vueRepository: misskey-dev/misskey Length of output: 4838 時間切れ通知は1回に制限してください 🤖 Prompt for AI Agents |
||
| } | ||
| }, TIMER_INTERVAL_SEC * 1000, { immediate: false, afterMounted: true }); | ||
| } | ||
|
|
@@ -333,8 +334,7 @@ async function onStreamLog(log: Reversi.Serializer.Log & { id: string | null }) | |
| engine.value.putStone(log.pos); | ||
| triggerRef(engine); | ||
|
|
||
| myTurnTimerRmain.value = game.value.timeLimitForEachTurn; | ||
| opTurnTimerRmain.value = game.value.timeLimitForEachTurn; | ||
| resetTurnTimer(); | ||
|
|
||
| checkEnd(); | ||
| break; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.