mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-11 11:21:16 +02:00
Improve math-quiz difficulty handling
This commit is contained in:
@@ -4,13 +4,21 @@ const { list } = require('../../util/Util');
|
||||
const difficulties = ['baby', 'easy', 'medium', 'hard', 'extreme', 'impossible'];
|
||||
const operations = ['+', '-', '*'];
|
||||
const maxValues = {
|
||||
baby: 5,
|
||||
easy: 10,
|
||||
baby: 10,
|
||||
easy: 50,
|
||||
medium: 100,
|
||||
hard: 500,
|
||||
extreme: 1000,
|
||||
impossible: Number.MAX_SAFE_INTEGER
|
||||
};
|
||||
const maxMultiplyValues = {
|
||||
baby: 5,
|
||||
easy: 12,
|
||||
medium: 30,
|
||||
hard: 50,
|
||||
extreme: 100,
|
||||
impossible: Number.MAX_SAFE_INTEGER
|
||||
};
|
||||
|
||||
module.exports = class MathQuizCommand extends Command {
|
||||
constructor(client) {
|
||||
@@ -33,14 +41,24 @@ module.exports = class MathQuizCommand extends Command {
|
||||
}
|
||||
|
||||
async run(msg, { difficulty }) {
|
||||
const value1 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
|
||||
const value2 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
|
||||
const operation = operations[Math.floor(Math.random() * operations.length)];
|
||||
let answer;
|
||||
let answer, value1, value2;
|
||||
switch (operation) {
|
||||
case '+': answer = value1 + value2; break;
|
||||
case '-': answer = value1 - value2; break;
|
||||
case '*': answer = value1 * value2; break;
|
||||
case '+':
|
||||
value1 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
|
||||
value2 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
|
||||
answer = value1 + value2;
|
||||
break;
|
||||
case '-':
|
||||
value1 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
|
||||
value2 = Math.floor(Math.random() * maxValues[difficulty]) + 1;
|
||||
answer = value1 - value2;
|
||||
break;
|
||||
case '*':
|
||||
value1 = Math.floor(Math.random() * maxMultiplyValues[difficulty]) + 1;
|
||||
value2 = Math.floor(Math.random() * maxMultiplyValues[difficulty]) + 1;
|
||||
answer = value1 * value2;
|
||||
break;
|
||||
}
|
||||
await msg.reply(stripIndents`
|
||||
**You have 10 seconds to answer this question.**
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "xiao",
|
||||
"version": "114.10.2",
|
||||
"version": "114.10.3",
|
||||
"description": "Your personal server companion.",
|
||||
"main": "Xiao.js",
|
||||
"scripts": {
|
||||
|
||||
Reference in New Issue
Block a user