From 765c7e2b638ec3c422dee2d98836e7bc78a1e5bd Mon Sep 17 00:00:00 2001 From: Dragon Fire Date: Tue, 2 Jun 2020 00:02:48 -0400 Subject: [PATCH] Improve slot command appearance --- commands/games-sp/slots.js | 34 ++++++++++++++++++++++------------ package.json | 2 +- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/commands/games-sp/slots.js b/commands/games-sp/slots.js index 24da0969..302a167a 100644 --- a/commands/games-sp/slots.js +++ b/commands/games-sp/slots.js @@ -1,6 +1,6 @@ const Command = require('../../structures/Command'); const { stripIndents } = require('common-tags'); -const slots = ['🍇', '🍊', '🍐', '🍒', '🍋']; +const slots = ['🍇', '🍊', '🍐', '🍒', '🍋', '🍌', '🔔']; module.exports = class SlotsCommand extends Command { constructor(client) { @@ -13,18 +13,28 @@ module.exports = class SlotsCommand extends Command { } run(msg) { - const slotOne = slots[Math.floor(Math.random() * slots.length)]; - const slotTwo = slots[Math.floor(Math.random() * slots.length)]; - const slotThree = slots[Math.floor(Math.random() * slots.length)]; - if (slotOne === slotTwo && slotOne === slotThree) { - return msg.reply(stripIndents` - ${slotOne}|${slotTwo}|${slotThree} - Wow! You won! Great job... er... luck! - `); - } + const slotOne = Math.floor(Math.random() * slots.length); + const slotTwo = Math.floor(Math.random() * slots.length); + const slotThree = Math.floor(Math.random() * slots.length); return msg.reply(stripIndents` - ${slotOne}|${slotTwo}|${slotThree} - Aww... You lost... Guess it's just bad luck, huh? + **[ 🎰 | SLOTS ]** + ------------------ + ${this.wrapSlots(slotOne, false)} : ${this.wrapSlots(slotTwo, false)} : ${this.wrapSlots(slotThree, false)} + + ${slots[slotOne]} : ${slots[slotTwo]} : ${slots[slotThree]} **<** + + ${this.wrapSlots(slotOne, true)} : ${this.wrapSlots(slotTwo, true)} : ${this.wrapSlots(slotThree, true)} + ------------------ + | : : : **${slotOne === slotTwo === slotThree ? 'WIN!' : 'LOST'}** : : : | `); } + + wrapSlots(slot, add) { + if (add) { + if (slot + 1 > slots.length - 1) return slots[0]; + return slots[slot + 1]; + } + if (slot - 1 < 0) return slots[slots.length - 1]; + return slots[slot - 1]; + } }; diff --git a/package.json b/package.json index 96000a37..c15af921 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xiao", - "version": "115.2.0", + "version": "115.2.1", "description": "Your personal server companion.", "main": "Xiao.js", "scripts": {