mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-27 14:18:36 +02:00
randomRange util function
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { stripIndents } = require('common-tags');
|
||||
const { verify } = require('../../util/Util');
|
||||
const { randomRange, verify } = require('../../util/Util');
|
||||
|
||||
module.exports = class BattleCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -88,7 +88,7 @@ module.exports = class BattleCommand extends Command {
|
||||
} else if (choice === 'special') {
|
||||
const hit = Math.floor(Math.random() * 4) + 1;
|
||||
if (hit === 1) {
|
||||
const damage = Math.floor(Math.random() * ((guard ? 150 : 300) - 100 + 1)) + 100;
|
||||
const damage = randomRange(100, guard ? 150 : 300);
|
||||
await msg.say(`${user} deals **${damage}** damage!`);
|
||||
dealDamage(damage);
|
||||
} else {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { randomRange } = require('../../util/Util');
|
||||
const fishes = require('../../assets/json/fishy');
|
||||
|
||||
module.exports = class FishyCommand extends Command {
|
||||
@@ -13,13 +14,14 @@ module.exports = class FishyCommand extends Command {
|
||||
}
|
||||
|
||||
run(msg) {
|
||||
const fish = Math.floor(Math.random() * 10) + 1;
|
||||
const fishID = Math.floor(Math.random() * 10) + 1;
|
||||
let rarity;
|
||||
if (fish < 5) rarity = 'junk';
|
||||
else if (fish < 8) rarity = 'common';
|
||||
else if (fish < 10) rarity = 'uncommon';
|
||||
if (fishID < 5) rarity = 'junk';
|
||||
else if (fishID < 8) rarity = 'common';
|
||||
else if (fishID < 10) rarity = 'uncommon';
|
||||
else rarity = 'rare';
|
||||
const worth = Math.floor(Math.random() * (fishes[rarity].max - fishes[rarity].min + 1)) + fishes[rarity].min;
|
||||
return msg.say(`You caught a ${fishes[rarity].symbol}. I bet it'd sell for around $${worth}.`);
|
||||
const fish = fishes[rarity];
|
||||
const worth = randomRange(fish.min, fish.max);
|
||||
return msg.say(`You caught a ${fish.symbol}. I bet it'd sell for around $${worth}.`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const { wait, verify } = require('../../util/Util');
|
||||
const { wait, randomRange, verify } = require('../../util/Util');
|
||||
const words = ['fire', 'draw', 'shoot', 'bang', 'pull'];
|
||||
|
||||
module.exports = class GunfightCommand extends Command {
|
||||
@@ -36,8 +36,7 @@ module.exports = class GunfightCommand extends Command {
|
||||
return msg.say('Looks like they declined...');
|
||||
}
|
||||
await msg.say('Get Ready...');
|
||||
const length = Math.floor(Math.random() * (30000 - 1000 + 1)) + 1000;
|
||||
await wait(length);
|
||||
await wait(randomRange(1000, 30000));
|
||||
const word = words[Math.floor(Math.random() * words.length)];
|
||||
await msg.say(`TYPE \`${word.toUpperCase()}\` NOW!`);
|
||||
const filter = res => [opponent.id, msg.author.id].includes(res.author.id) && res.content.toLowerCase() === word;
|
||||
|
||||
Reference in New Issue
Block a user