mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 22:34:46 +02:00
Update cards against humanity/apples to apples
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { escapeMarkdown } = require('discord.js');
|
const { Collection, escapeMarkdown } = require('discord.js');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { shuffle, awaitPlayers } = require('../../util/Util');
|
const { shuffle, awaitPlayers } = require('../../util/Util');
|
||||||
const { greenCards, redCards } = require('../../assets/json/apples-to-apples');
|
const { greenCards, redCards } = require('../../assets/json/apples-to-apples');
|
||||||
@@ -52,15 +52,15 @@ module.exports = class ApplesToApplesCommand extends Command {
|
|||||||
Sending DMs...
|
Sending DMs...
|
||||||
`);
|
`);
|
||||||
const chosenCards = [];
|
const chosenCards = [];
|
||||||
for (const player of players.values()) {
|
const turns = players.map(async player => {
|
||||||
if (player.hand.size < 11) {
|
if (player.hand.size < 11) {
|
||||||
const valid = redCards.filter(card => !player.hand.has(card));
|
const valid = redCards.filter(card => !player.hand.has(card));
|
||||||
player.hand.add(valid[Math.floor(Math.random() * valid.length)]);
|
player.hand.add(valid[Math.floor(Math.random() * valid.length)]);
|
||||||
}
|
}
|
||||||
if (player.user.id === czar.user.id) continue;
|
if (player.user.id === czar.user.id) return;
|
||||||
if (!player.hand.size) {
|
if (!player.hand.size) {
|
||||||
await player.user.send('You don\'t have enough cards!');
|
await player.user.send('You don\'t have enough cards!');
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
const hand = Array.from(player.hand);
|
const hand = Array.from(player.hand);
|
||||||
await player.user.send(stripIndents`
|
await player.user.send(stripIndents`
|
||||||
@@ -84,7 +84,7 @@ module.exports = class ApplesToApplesCommand extends Command {
|
|||||||
});
|
});
|
||||||
if (!choice.size) {
|
if (!choice.size) {
|
||||||
await player.user.send('Skipping your turn...');
|
await player.user.send('Skipping your turn...');
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
if (chosen === '<Blank>') {
|
if (chosen === '<Blank>') {
|
||||||
const handled = await this.handleBlank(player);
|
const handled = await this.handleBlank(player);
|
||||||
@@ -97,7 +97,8 @@ module.exports = class ApplesToApplesCommand extends Command {
|
|||||||
card: chosen
|
card: chosen
|
||||||
});
|
});
|
||||||
await player.user.send(`Nice! Return to ${msg.channel} to await the results!`);
|
await player.user.send(`Nice! Return to ${msg.channel} to await the results!`);
|
||||||
}
|
});
|
||||||
|
await Promise.all(turns);
|
||||||
if (!chosenCards.length) {
|
if (!chosenCards.length) {
|
||||||
await msg.say('Hmm... No one even tried.');
|
await msg.say('Hmm... No one even tried.');
|
||||||
break;
|
break;
|
||||||
@@ -137,7 +138,7 @@ module.exports = class ApplesToApplesCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async generatePlayers(list) {
|
async generatePlayers(list) {
|
||||||
const players = new Map();
|
const players = new Collection();
|
||||||
for (const user of list) {
|
for (const user of list) {
|
||||||
const cards = new Set();
|
const cards = new Set();
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
const Command = require('../../structures/Command');
|
const Command = require('../../structures/Command');
|
||||||
const { escapeMarkdown } = require('discord.js');
|
const { Collection, escapeMarkdown } = require('discord.js');
|
||||||
const { stripIndents } = require('common-tags');
|
const { stripIndents } = require('common-tags');
|
||||||
const { shuffle, awaitPlayers } = require('../../util/Util');
|
const { shuffle, awaitPlayers } = require('../../util/Util');
|
||||||
const { blackCards, whiteCards } = require('../../assets/json/cards-against-humanity');
|
const { blackCards, whiteCards } = require('../../assets/json/cards-against-humanity');
|
||||||
@@ -53,15 +53,15 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
|||||||
Sending DMs...
|
Sending DMs...
|
||||||
`);
|
`);
|
||||||
const chosenCards = [];
|
const chosenCards = [];
|
||||||
for (const player of players.values()) {
|
const turns = players.map(async player => {
|
||||||
if (player.hand.size < 11) {
|
if (player.hand.size < 11) {
|
||||||
const valid = whiteCards.filter(card => !player.hand.has(card));
|
const valid = whiteCards.filter(card => !player.hand.has(card));
|
||||||
player.hand.add(valid[Math.floor(Math.random() * valid.length)]);
|
player.hand.add(valid[Math.floor(Math.random() * valid.length)]);
|
||||||
}
|
}
|
||||||
if (player.user.id === czar.user.id) continue;
|
if (player.user.id === czar.user.id) return;
|
||||||
if (player.hand.size < black.pick) {
|
if (player.hand.size < black.pick) {
|
||||||
await player.user.send('You don\'t have enough cards!');
|
await player.user.send('You don\'t have enough cards!');
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
const hand = Array.from(player.hand);
|
const hand = Array.from(player.hand);
|
||||||
await player.user.send(stripIndents`
|
await player.user.send(stripIndents`
|
||||||
@@ -86,7 +86,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
|||||||
});
|
});
|
||||||
if (!choices.size || choices.size < black.pick) {
|
if (!choices.size || choices.size < black.pick) {
|
||||||
await player.user.send('Skipping your turn...');
|
await player.user.send('Skipping your turn...');
|
||||||
continue;
|
return;
|
||||||
}
|
}
|
||||||
if (chosen.includes('<Blank>')) {
|
if (chosen.includes('<Blank>')) {
|
||||||
const handled = await this.handleBlank(player);
|
const handled = await this.handleBlank(player);
|
||||||
@@ -98,7 +98,8 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
|||||||
cards: chosen
|
cards: chosen
|
||||||
});
|
});
|
||||||
await player.user.send(`Nice! Return to ${msg.channel} to await the results!`);
|
await player.user.send(`Nice! Return to ${msg.channel} to await the results!`);
|
||||||
}
|
});
|
||||||
|
await Promise.all(turns);
|
||||||
if (!chosenCards.length) {
|
if (!chosenCards.length) {
|
||||||
await msg.say('Hmm... No one even tried.');
|
await msg.say('Hmm... No one even tried.');
|
||||||
break;
|
break;
|
||||||
@@ -138,7 +139,7 @@ module.exports = class CardsAgainstHumanityCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async generatePlayers(list) {
|
async generatePlayers(list) {
|
||||||
const players = new Map();
|
const players = new Collection();
|
||||||
for (const user of list) {
|
for (const user of list) {
|
||||||
const cards = new Set();
|
const cards = new Set();
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "85.11.0",
|
"version": "85.11.1",
|
||||||
"description": "Your personal server companion.",
|
"description": "Your personal server companion.",
|
||||||
"main": "Xiao.js",
|
"main": "Xiao.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
Reference in New Issue
Block a user