Handle finishing game
This commit is contained in:
13
index.html
13
index.html
@@ -241,7 +241,7 @@
|
||||
mouse = [x, y];
|
||||
i = Math.floor((x / width) * 8);
|
||||
j = Math.floor((y / height) * 8);
|
||||
if (ready) {
|
||||
if (ready && state == -1) {
|
||||
canvas.style.cursor = 'default';
|
||||
if (board) {
|
||||
if (color == 0) {
|
||||
@@ -267,7 +267,7 @@
|
||||
canvas.addEventListener('mouseup', (e) => {
|
||||
i = mHouse[0];
|
||||
j = mHouse[1];
|
||||
if (ready && board) {
|
||||
if (state == -1 && ready && board) {
|
||||
if (board[j][i] !== "E" && (board[j][i] === board[j][i].toUpperCase() ? 0 : 1) === color && turn == color) {
|
||||
|
||||
selected = [i, j];
|
||||
@@ -302,6 +302,7 @@
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
board = data.board.grid;
|
||||
boardOnChange();
|
||||
console.log(data);
|
||||
selected = undefined;
|
||||
moves = [];
|
||||
@@ -326,6 +327,11 @@
|
||||
ready = data.ready;
|
||||
turn = data.turn;
|
||||
board = data.board.grid;
|
||||
boardOnChange();
|
||||
state = data.state;
|
||||
start_time = new Date(data.start_time);
|
||||
|
||||
setUI();
|
||||
})
|
||||
.catch((error) => console.error('Error:', error));
|
||||
}
|
||||
@@ -362,11 +368,14 @@
|
||||
color = data.color;
|
||||
ready = data.ready;
|
||||
turn = data.turn;
|
||||
state = data.state;
|
||||
start_time = new Date(data.start_time);
|
||||
}
|
||||
ROOM_ID = rid;
|
||||
board = data.board.grid;
|
||||
numberMap = "12345678";
|
||||
letterMap = "abcdefgh";
|
||||
setUI();
|
||||
document.getElementById('join-menu').outerHTML = '';
|
||||
const urlID = extractIdFromPath();
|
||||
if (urlID == null) {
|
||||
|
||||
Reference in New Issue
Block a user