server for my chess game
support two undos
bendn 2022-06-29
parent dc8a8c5 · commit c83d455
-rw-r--r--.gitignore2
-rw-r--r--src/index.js4
2 files changed, 4 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index bad4718..c546035 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,7 +6,7 @@
.idea
.DS_Store
/src/test.js
-/src/test.mjs
+*.mjs
npm-debug.log*
yarn-debug.log*
diff --git a/src/index.js b/src/index.js
index 9f62ca4..a839b0d 100644
--- a/src/index.js
+++ b/src/index.js
@@ -327,8 +327,10 @@ function handle_move(data, ws) {
function handle_undo(data, ws) {
const gc = data.gamecode;
- if (signal_other(data, ws, HEADERS.undo) && data.accepted == true)
+ if (signal_other(data, ws, HEADERS.undo) && data.accepted == true) {
games[gc].pop_move();
+ if (data.two === true) games[gc].pop_move();
+ }
}
function handle_spectate(data, ws) {