mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-04 15:56:52 +02:00
Make doors the monty hall paradox
This commit is contained in:
@@ -248,7 +248,7 @@ Xiao is a Discord bot coded in JavaScript with
|
||||
* **box-choosing:** Do you believe that there are choices in life? Taken from Higurashi Chapter 4.
|
||||
* **captcha:** Try to guess what the captcha says.
|
||||
* **chance:** Attempt to win with a 1 in 1000 (or your choice) chance of winning.
|
||||
* **doors:** Open the right door, and you win the money! Make the wrong one, and you get the fire!
|
||||
* **doors:** Open the right door, and you win the money! Make the wrong choice, and you get the fire!
|
||||
* **emoji-emoji-revolution:** Can you type arrow emoji faster than anyone else has ever typed them before?
|
||||
* **fishy:** Go fishing.
|
||||
* **google-feud:** Attempt to determine the top suggestions for a Google search.
|
||||
|
||||
+32
-9
@@ -1,14 +1,16 @@
|
||||
const Command = require('../../structures/Command');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { verify } = require('../../util/Util');
|
||||
const doors = [1, 2, 3];
|
||||
|
||||
module.exports = class DoorsCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'doors',
|
||||
aliases: ['door', 'door-opening', 'open-door'],
|
||||
aliases: ['door', 'door-opening', 'open-door', 'monty-hall'],
|
||||
group: 'games',
|
||||
memberName: 'doors',
|
||||
description: 'Open the right door, and you win the money! Make the wrong one, and you get the fire!',
|
||||
description: 'Open the right door, and you win the money! Make the wrong choice, and you get the fire!',
|
||||
args: [
|
||||
{
|
||||
key: 'door',
|
||||
@@ -19,14 +21,35 @@ module.exports = class DoorsCommand extends Command {
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.playing = new Set();
|
||||
}
|
||||
|
||||
run(msg, { door }) {
|
||||
const win = Math.floor(Math.random() * 3) + 1;
|
||||
const emoji = door === win ? '💰' : '🔥';
|
||||
return msg.reply(stripIndents`
|
||||
${door === win ? 'You chose wisely.' : 'Hmm... Try again.'}
|
||||
${door === 1 ? emoji : '🚪'} ${door === 2 ? emoji : '🚪'} ${door === 3 ? emoji : '🚪'}
|
||||
`);
|
||||
async run(msg, { door }) {
|
||||
if (this.playing.has(msg.channel.id)) return msg.reply('Only one game may be occurring per channel.');
|
||||
this.playing.add(msg.channel.id);
|
||||
try {
|
||||
const win = doors[Math.floor(Math.random() * doors.length)];
|
||||
const doorNoWin = doors.filter(thisDoor => thisDoor !== win);
|
||||
const noWin = doorNoWin[Math.floor(Math.random() * doorNoWin.length)];
|
||||
await msg.reply(stripIndents`
|
||||
Well, there's nothing behind door number **${noWin}**. Do you want to stick with door ${door}?
|
||||
${this.doorEmoji(1, noWin)} ${this.doorEmoji(2, noWin)} ${this.doorEmoji(3, noWin)}
|
||||
`);
|
||||
const stick = await verify(msg.channel, msg.author);
|
||||
if (!stick) door = doors.filter(thisDoor => door !== thisDoor && thisDoor !== noWin)[0];
|
||||
this.playing.delete(msg.channel.id);
|
||||
return msg.reply(stripIndents`
|
||||
${door === win ? 'You chose wisely.' : 'Hmm... Try again.'}
|
||||
${this.doorEmoji(1, noWin, win)} ${this.doorEmoji(2, noWin, win)} ${this.doorEmoji(3, noWin, win)}
|
||||
`);
|
||||
} catch (err) {
|
||||
this.playing.delete(msg.channel.id);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
doorEmoji(door, noWin, win) {
|
||||
return door === win ? '💰' : door === noWin ? '🔥' : '🚪';
|
||||
}
|
||||
};
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "98.0.2",
|
||||
"version": "98.0.3",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user