mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-05 00:06:42 +02:00
Replace chess-set-up with an arg
This commit is contained in:
@@ -618,7 +618,6 @@ Total: 594
|
||||
* **bingo:** Play bingo with up to 99 other users.
|
||||
* **car-race:** Race a car against another user or the AI.
|
||||
* **chess-delete:** Deletes your saved Chess game.
|
||||
* **chess-set-up:** Sets up and saves a custom Chess game.
|
||||
* **chess:** Play a game of Chess with another user or the AI.
|
||||
* **connect-four:** Play a game of Connect Four with another user or the AI.
|
||||
* **cram:** Play a game of Cram with another user.
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const validateFEN = require('fen-validator').default;
|
||||
|
||||
module.exports = class ChessSetUpCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'chess-set-up',
|
||||
aliases: ['set-up-chess', 'chess-create', 'create-chess'],
|
||||
group: 'games-mp',
|
||||
memberName: 'chess-set-up',
|
||||
description: 'Sets up and saves a custom Chess game.',
|
||||
args: [
|
||||
{
|
||||
key: 'fen',
|
||||
prompt: 'What FEN would you like to use for the game?',
|
||||
type: 'string',
|
||||
validate: fen => validateFEN(fen)
|
||||
}
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
async run(msg, { fen }) {
|
||||
const data = await this.client.redis.exists(`chess-${msg.author.id}`);
|
||||
if (data) return msg.reply('You already have a saved Chess game.');
|
||||
await this.client.redis.set(`chess-${msg.author.id}`, JSON.stringify({
|
||||
fen,
|
||||
whiteTime: -1,
|
||||
blackTime: -1,
|
||||
color: 'white',
|
||||
fiftyRuleMove: 0
|
||||
}));
|
||||
const usage = this.client.registry.commands.get('chess').usage();
|
||||
return msg.say(`Your custom game has been saved. You can use it using ${usage}.`);
|
||||
}
|
||||
};
|
||||
@@ -2,6 +2,7 @@ const Command = require('../../structures/Command');
|
||||
const jsChess = require('js-chess-engine');
|
||||
const { createCanvas, loadImage } = require('canvas');
|
||||
const moment = require('moment');
|
||||
const validateFEN = require('fen-validator').default;
|
||||
const { stripIndents } = require('common-tags');
|
||||
const path = require('path');
|
||||
const { verify, reactIfAble } = require('../../util/Util');
|
||||
@@ -43,6 +44,13 @@ module.exports = class ChessCommand extends Command {
|
||||
max: 120,
|
||||
min: 0,
|
||||
default: 15
|
||||
},
|
||||
{
|
||||
key: 'fen',
|
||||
prompt: 'What FEN would you like to use for the start board?',
|
||||
type: 'string',
|
||||
default: '',
|
||||
validate: fen => validateFEN(fen)
|
||||
}
|
||||
]
|
||||
});
|
||||
@@ -50,7 +58,7 @@ module.exports = class ChessCommand extends Command {
|
||||
this.images = null;
|
||||
}
|
||||
|
||||
async run(msg, { opponent, time }) {
|
||||
async run(msg, { opponent, time, fen }) {
|
||||
if (opponent.id === msg.author.id) return msg.reply('You may not play against yourself.');
|
||||
const current = this.client.games.get(msg.channel.id);
|
||||
if (current) return msg.reply(`Please wait until the current game of \`${current.name}\` is finished.`);
|
||||
@@ -92,10 +100,10 @@ module.exports = class ChessCommand extends Command {
|
||||
return msg.reply('An error occurred reading your saved game. Please try again.');
|
||||
}
|
||||
} else {
|
||||
game = new jsChess.Game();
|
||||
game = new jsChess.Game(fen || undefined);
|
||||
}
|
||||
} else {
|
||||
game = new jsChess.Game();
|
||||
game = new jsChess.Game(fen || undefined);
|
||||
}
|
||||
let prevPieces = null;
|
||||
let saved = false;
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "128.5.2",
|
||||
"version": "129.0.0",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user