mirror of
https://github.com/JonnyBro/JaBa.git
synced 2024-11-25 14:44:58 +05:00
Расчёт награды в зависимости от кол-ва участников
This commit is contained in:
parent
e29a32485f
commit
086180f4a9
3 changed files with 25 additions and 21 deletions
|
@ -19,7 +19,7 @@ class Eightball extends Command {
|
|||
async run(message, args) {
|
||||
if (!args[0] || !message.content.endsWith("?")) return message.error("fun/8ball:ERR_QUESTION");
|
||||
|
||||
const answerN = this.client.functions.randomNum(1, 20);
|
||||
const answerN = this.client.functions.randomNum(1, 19);
|
||||
const answer = message.translate(`fun/8ball:RESPONSE_${answerN + 1}`);
|
||||
|
||||
message.channel.send(answer);
|
||||
|
|
|
@ -26,6 +26,7 @@ class FindWords extends Command {
|
|||
let lang = null;
|
||||
if (message.guild.data.language === "uk-UA") return lang = "ru-RU";
|
||||
else lang = message.guild.data.language;
|
||||
|
||||
const wordList = require(`../../assets/json/words/${lang}.json`);
|
||||
|
||||
// Init some utils variables
|
||||
|
@ -105,7 +106,7 @@ class FindWords extends Command {
|
|||
id: user.id,
|
||||
guildID: message.guild.id
|
||||
});
|
||||
userdata.money = userdata.money + 150;
|
||||
userdata.money = userdata.money + (150 * (participants.length * 0.5));
|
||||
userdata.save();
|
||||
};
|
||||
};
|
||||
|
@ -116,15 +117,14 @@ class FindWords extends Command {
|
|||
async function getWinner(array) {
|
||||
return new Promise(function (resolve) {
|
||||
const counts = {};
|
||||
let compare = 0;
|
||||
let mostFrequent;
|
||||
let compare = 0,
|
||||
mostFrequent;
|
||||
|
||||
for (let i = 0, len = array.length; i < len; i++) {
|
||||
const winner = array[i];
|
||||
if (!counts[winner]) {
|
||||
counts[winner] = 1;
|
||||
} else {
|
||||
counts[winner] = counts[winner] + 1;
|
||||
};
|
||||
if (!counts[winner]) counts[winner] = 1;
|
||||
else counts[winner] = counts[winner] + 1;
|
||||
|
||||
if (counts[winner] > compare) {
|
||||
compare = counts[winner];
|
||||
mostFrequent = array[i];
|
||||
|
|
|
@ -22,8 +22,8 @@ class Number extends Command {
|
|||
async run(message, args, data) {
|
||||
if (currentGames[message.guild.id]) return message.error("fun/number:GAME_RUNNING");
|
||||
|
||||
const participants = [];
|
||||
const number = Math.floor(Math.random() * 3000);
|
||||
const participants = [],
|
||||
number = Math.floor(Math.random() * 3000);
|
||||
|
||||
await message.sendT("fun/number:GAME_START");
|
||||
|
||||
|
@ -51,17 +51,21 @@ class Number extends Command {
|
|||
participantCount: participants.length,
|
||||
participants: participants.map(p => `<@${p}>`).join(", ")
|
||||
});
|
||||
|
||||
if (participants.length > 1 && data.guild.disabledCategories && !data.guild.disabledCategories.includes("Economy")) {
|
||||
message.sendT("fun/number:WON", {
|
||||
winner: msg.author.toString()
|
||||
winner: msg.author.username
|
||||
});
|
||||
|
||||
const userdata = await this.client.findOrCreateMember({
|
||||
id: msg.author.id,
|
||||
guildID: message.guild.id
|
||||
});
|
||||
userdata.money = userdata.money + 100;
|
||||
userdata.money = userdata.money + (100 * (participants.length * 0.5));
|
||||
userdata.save();
|
||||
collector.stop(msg.author.username);
|
||||
};
|
||||
};
|
||||
if (parseInt(msg.content) < number) message.error("fun/number:BIG", {
|
||||
user: msg.author.toString(),
|
||||
number: parsedNumber
|
||||
|
|
Loading…
Reference in a new issue