mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-26 22:32:52 +02:00
Fix?
This commit is contained in:
@@ -6,7 +6,7 @@ const path = require('path');
|
|||||||
const { verify, reactIfAble } = require('../../util/Util');
|
const { verify, reactIfAble } = require('../../util/Util');
|
||||||
const { drawImageWithTint } = require('../../util/Canvas');
|
const { drawImageWithTint } = require('../../util/Canvas');
|
||||||
const { FAILURE_EMOJI_ID } = process.env;
|
const { FAILURE_EMOJI_ID } = process.env;
|
||||||
const turnRegex = /^([A-H][1-8]) ?([A-H][1-8])$/;
|
const turnRegex = /^([A-H][1-8])(?: |, ?|-?>?)?([A-H][1-8])$/;
|
||||||
const pieces = ['pawn', 'rook', 'knight', 'king', 'queen', 'bishop'];
|
const pieces = ['pawn', 'rook', 'knight', 'king', 'queen', 'bishop'];
|
||||||
const cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
|
const cols = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'];
|
||||||
|
|
||||||
@@ -88,16 +88,16 @@ module.exports = class ChessCommand extends Command {
|
|||||||
};
|
};
|
||||||
const turn = await msg.channel.awaitMessages(pickFilter, {
|
const turn = await msg.channel.awaitMessages(pickFilter, {
|
||||||
max: 1,
|
max: 1,
|
||||||
time: 60000
|
time: 120000
|
||||||
});
|
});
|
||||||
if (!turn.size) {
|
if (!turn.size) {
|
||||||
if (lastTurnTimeout) {
|
if (lastTurnTimeout) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
await msg.say('Sorry, time is up! Playing random move.');
|
|
||||||
const available = Object.keys(moves);
|
const available = Object.keys(moves);
|
||||||
const piece = available[Math.floor(Math.random() * available.length)];
|
const piece = available[Math.floor(Math.random() * available.length)];
|
||||||
const move = moves[piece][Math.floor(Math.random() * moves[piece].length)];
|
const move = moves[piece][Math.floor(Math.random() * moves[piece].length)];
|
||||||
|
await msg.say(`Sorry, time is up! Playing random move (${piece}->${move}).`);
|
||||||
game.move(piece, move);
|
game.move(piece, move);
|
||||||
lastTurnTimeout = true;
|
lastTurnTimeout = true;
|
||||||
continue;
|
continue;
|
||||||
@@ -134,12 +134,12 @@ module.exports = class ChessCommand extends Command {
|
|||||||
const prevGamePiece = prevGameState ? prevGameState.pieces[`${cols[col]}${row}`] : null;
|
const prevGamePiece = prevGameState ? prevGameState.pieces[`${cols[col]}${row}`] : null;
|
||||||
if (piece) {
|
if (piece) {
|
||||||
const parsed = this.pickImage(piece);
|
const parsed = this.pickImage(piece);
|
||||||
if (prevGameState && !prevGamePiece) {
|
if (piece !== prevGamePiece) {
|
||||||
drawImageWithTint(ctx, this.images[parsed.color][parsed.name], 'green', w, h, 52, 52);
|
drawImageWithTint(ctx, this.images[parsed.color][parsed.name], 'green', w, h, 52, 52);
|
||||||
} else {
|
} else {
|
||||||
ctx.drawImage(this.images[parsed.color][parsed.name], w, h, 52, 52);
|
ctx.drawImage(this.images[parsed.color][parsed.name], w, h, 52, 52);
|
||||||
}
|
}
|
||||||
} else if (prevGameState && prevGamePiece) {
|
} else if (prevGamePiece) {
|
||||||
ctx.fillStyle = 'green';
|
ctx.fillStyle = 'green';
|
||||||
ctx.globalAlpha = 0.5;
|
ctx.globalAlpha = 0.5;
|
||||||
ctx.fillRect(w, h, 52, 52);
|
ctx.fillRect(w, h, 52, 52);
|
||||||
|
|||||||
Reference in New Issue
Block a user