Tue Jun 27 07:35:00 UTC 2023 inscode

上级 6e204267
...@@ -6,6 +6,7 @@ import { robotPlay } from './utils/api' ...@@ -6,6 +6,7 @@ import { robotPlay } from './utils/api'
const size = ref(20) const size = ref(20)
const win_size = ref(5) const win_size = ref(5)
const lattices = ref([]) const lattices = ref([])
const is_load = ref(false)
// 5 连珠的下标 // 5 连珠的下标
let isWin = [] let isWin = []
...@@ -17,6 +18,7 @@ function confirm() { ...@@ -17,6 +18,7 @@ function confirm() {
} }
// 玩家下棋 // 玩家下棋
async function playChess(item, row, col) { async function playChess(item, row, col) {
if (is_load.value) return
if (isWin.length || item !== is_empty) return if (isWin.length || item !== is_empty) return
lattices.value[row][col] = is_black lattices.value[row][col] = is_black
const test = checkWin({ row, col, board: lattices.value, player: is_black, win_size: win_size.value }) const test = checkWin({ row, col, board: lattices.value, player: is_black, win_size: win_size.value })
...@@ -24,7 +26,9 @@ async function playChess(item, row, col) { ...@@ -24,7 +26,9 @@ async function playChess(item, row, col) {
isWin = test isWin = test
return return
} else { } else {
is_load.value = true
const [x, y] = await robotPlay(lattices.value, is_white, win_size.value) const [x, y] = await robotPlay(lattices.value, is_white, win_size.value)
is_load.value = false
lattices.value[x][y] = is_white lattices.value[x][y] = is_white
} }
} }
......
...@@ -40,7 +40,7 @@ export async function robotPlay(board, player, win_size) { ...@@ -40,7 +40,7 @@ export async function robotPlay(board, player, win_size) {
try { try {
_res = JSON.parse(arr) _res = JSON.parse(arr)
} catch (err) { } catch (err) {
_res = await robotPlay(board, player, win_size) _res = []
} }
return _res return _res
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册