From af6c2ab377ffd0c5aa60ad867d42da75d7c6602f Mon Sep 17 00:00:00 2001
From: Yangfan Wu <39647285+wyf027@users.noreply.github.com>
Date: Sun, 5 Jul 2026 05:17:00 +0800
Subject: [PATCH 1/2] =?UTF-8?q?feat(classic-games):=20=E6=96=B0=E5=A2=9E?=
=?UTF-8?q?=20Mini=20Hexapawn=20=E5=B0=8F=E6=B8=B8=E6=88=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../classic-games/20260705-0515-hexapawn.html | 213 ++++++++++++++++++
1 file changed, 213 insertions(+)
create mode 100644 project/classic-games/20260705-0515-hexapawn.html
diff --git a/project/classic-games/20260705-0515-hexapawn.html b/project/classic-games/20260705-0515-hexapawn.html
new file mode 100644
index 00000000..d96fafe6
--- /dev/null
+++ b/project/classic-games/20260705-0515-hexapawn.html
@@ -0,0 +1,213 @@
+
+
+
+
+
+ Mini Hexapawn
+
+
+
+
+
+
+
+
+
+
+
+
+
+
From 7f46bc6bc8d29935c652ebc3fa87245e3732b492 Mon Sep 17 00:00:00 2001
From: Yangfan Wu <39647285+wyf027@users.noreply.github.com>
Date: Mon, 6 Jul 2026 03:02:51 +0800
Subject: [PATCH 2/2] fix(classic-games): cancel pending Hexapawn bot move on
reset
---
.../classic-games/20260705-0515-hexapawn.html | 22 +++++++++++++++++--
1 file changed, 20 insertions(+), 2 deletions(-)
diff --git a/project/classic-games/20260705-0515-hexapawn.html b/project/classic-games/20260705-0515-hexapawn.html
index d96fafe6..f5977a2d 100644
--- a/project/classic-games/20260705-0515-hexapawn.html
+++ b/project/classic-games/20260705-0515-hexapawn.html
@@ -53,8 +53,25 @@ 棋盘
let selected = null;
let turn = "P";
let gameOver = false;
+ let botTurnTimer = null;
+
+ function clearPendingBotTurn() {
+ if (botTurnTimer !== null) {
+ window.clearTimeout(botTurnTimer);
+ botTurnTimer = null;
+ }
+ }
+
+ function scheduleBotTurn() {
+ clearPendingBotTurn();
+ botTurnTimer = window.setTimeout(() => {
+ botTurnTimer = null;
+ botTurn();
+ }, 450);
+ }
function resetGame() {
+ clearPendingBotTurn();
board = [
["B", "B", "B"],
["", "", ""],
@@ -115,7 +132,7 @@ 棋盘
turn = "B";
setMessage("电脑行动。");
render();
- window.setTimeout(botTurn, 450);
+ scheduleBotTurn();
}
return;
}
@@ -136,7 +153,8 @@ 棋盘
}
function botTurn() {
- if (gameOver) return;
+ botTurnTimer = null;
+ if (gameOver || turn !== "B") return;
const moves = allMoves("B");
if (!moves.length) {
finish("你赢了,电脑无棋可走。");