diff --git a/src/App.vue b/src/App.vue index dc15928ac08711e501a6a1548373ba1581978fa5..a7f4243161d7d7e594f68a79ecb28a8e2d1a171f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -4,7 +4,7 @@ import { is_empty, checkWin, is_black, is_white, robotPlay } from "./utils" import RandomTree from "./components/RandomTree.vue"; // import { robotPlay } from './utils/api' // 配置 -const size = ref(30) +const size = ref(20) const win_size = ref(5) // 棋盘 const lattices = ref([]) @@ -14,14 +14,19 @@ const records = ref([]) let isWin = [] const time = ref(Date.now()) const records_obj = computed(() => { - return records.value.reduce((r, { location, type }) => { - const [y, x] = location || [] - const _win = isWin.map(([r, c]) => `${r}_${c}`).includes(`${y}_${x}`) + const obj = records.value.reduce((r, { location: [y, x], type }) => { return { ...r, - [`${y}_${x}`]: _win ? 'isWin' : type + [`${y}_${x}`]: type === is_black ? 'isBlack' : 'isWhite' } }, {}) + + if (isWin.length) { + isWin.map(([r, c]) => { + obj[`${r}_${c}`] = 'isWin' + }); + } + return obj }) onMounted(confirm) diff --git a/src/assets/main.css b/src/assets/main.css index bd390121218e07643fee5832547390e1a74edff0..b700187c3042d253938b066880796e3a280f1502 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -62,9 +62,9 @@ input { left: calc((20px - 20px * 0.9) * 0.5); box-shadow: - inset 1px 1px 1px rgba(0, 0, 0, 0.3), - inset -1px -1px 1px rgba(255, 255, 255, 0.7), - -2px -2px 2px rgba(0, 0, 0, 0.4); + inset -1px -1px 1px rgba(0, 0, 0, 0.3), + inset 1px 1px 1px rgba(255, 255, 255, 0.7), + 2px 2px 2px rgba(0, 0, 0, 0.4); } /* 竖线隐藏 */ diff --git a/src/utils/index.js b/src/utils/index.js index b3ffe7a97402a157fb61a388ab1804e4a5238b1c..a928b125d8b6aa7a580fb00e6e2e06c6fa99317b 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,9 +1,9 @@ -export const is_empty = 'isEmpty'; +export const is_empty = 0; /** * 机器人 */ -export const is_white = 'isWhite'; -export const is_black = 'isBlack'; +export const is_white = 1; +export const is_black = 2; /** * [y, x] === [row, col] === [行,列] */