mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-22 10:19:11 +02:00
Better balloon pop
This commit is contained in:
@@ -36,10 +36,12 @@ module.exports = class BalloonPopCommand extends Command {
|
|||||||
}
|
}
|
||||||
let userTurn = false;
|
let userTurn = false;
|
||||||
let winner = null;
|
let winner = null;
|
||||||
let remains = 1000;
|
let remains = 500;
|
||||||
|
let turns = 0;
|
||||||
while (!winner) {
|
while (!winner) {
|
||||||
const user = userTurn ? msg.author : opponent;
|
const user = userTurn ? msg.author : opponent;
|
||||||
let pump;
|
let pump;
|
||||||
|
++turns;
|
||||||
if (!opponent.bot || (opponent.bot && userTurn)) {
|
if (!opponent.bot || (opponent.bot && userTurn)) {
|
||||||
await msg.say(`${user}, do you pump the balloon?`);
|
await msg.say(`${user}, do you pump the balloon?`);
|
||||||
const verification = await verify(msg.channel, user);
|
const verification = await verify(msg.channel, user);
|
||||||
@@ -49,14 +51,20 @@ module.exports = class BalloonPopCommand extends Command {
|
|||||||
}
|
}
|
||||||
if (pump) {
|
if (pump) {
|
||||||
await msg.say(`${user} pumps the balloon!`);
|
await msg.say(`${user} pumps the balloon!`);
|
||||||
remains -= randomRange(25, 75);
|
remains -= randomRange(50, 100);
|
||||||
const popped = Math.floor(Math.random() * remains);
|
const popped = Math.floor(Math.random() * remains);
|
||||||
if (popped < 0) {
|
if (popped <= 0) {
|
||||||
await msg.say('The balloon pops!');
|
await msg.say('The balloon pops!');
|
||||||
winner = userTurn ? opponent : msg.author;
|
winner = userTurn ? opponent : msg.author;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (turns >= 3) {
|
||||||
|
turns = 0;
|
||||||
|
userTurn = !userTurn;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await msg.say(`${user} steps back!`);
|
await msg.say(`${user} steps back!`);
|
||||||
|
turns = 0;
|
||||||
userTurn = !userTurn;
|
userTurn = !userTurn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "xiao",
|
"name": "xiao",
|
||||||
"version": "61.0.0",
|
"version": "61.0.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