Final grade calculator

This commit is contained in:
Daniel Odendahl Jr
2017-12-14 22:24:18 +00:00
parent e4242539c6
commit 44c4d3496f
3 changed files with 89 additions and 1 deletions
+37
View File
@@ -0,0 +1,37 @@
{
"above100": [
"Maybe theres extra credit?",
"On the bright side, grades dont really matter anyway.",
"Try aiming a little lower.",
"Is that even possible to get?",
"Better luck next time!"
],
"above92": [
"Dont give up! You can do it!",
"Good luck!",
"Dont give up! I believe in you!",
"But Ive never known you to shy away from a challenge.",
"But whats life without a challenge?",
"Start studying!"
],
"above88": [
"On the bright side, it could be a lot worse.",
"I think youll do just fine!",
"Relax, you can do it!",
"Good luck!",
"Show them what youve got!"
],
"above80": [
"Dont worry, itll be a piece of cake.",
"You can do it, no problem!",
"Good luck!"
],
"below80": [
"You dont even need to bother studying.",
"Have fun (doing other things)!",
"Maybe you can just draw a flower on the test or something.",
"Congratulations!",
"Nice job! You earned it.",
"Try aiming higher!"
]
}
@@ -0,0 +1,51 @@
const { Command } = require('discord.js-commando');
const { above100, above92, above88, above80, below80 } = require('../../assets/json/final-grade-calculator');
module.exports = class FinalGradeCalculatorCommand extends Command {
constructor(client) {
super(client, {
name: 'final-grade-calculator',
aliases: ['final-grade', 'roger-hub'],
group: 'number-edit',
memberName: 'final-grade-calculator',
description: 'Determines the grade you need to make on your final to get your desired course grade.',
args: [
{
key: 'current',
label: 'current grade',
prompt: 'What is your current grade in the class?',
type: 'integer',
min: 0
},
{
key: 'desired',
label: 'desired grade',
prompt: 'What is the minimum grade you want in the class?',
type: 'integer',
min: 0
},
{
key: 'weight',
prompt: 'What percentage of your grade is the final worth?',
type: 'integer',
max: 100,
min: 0
}
]
});
}
run(msg, { current, desired, weight }) {
const weightDecimal = weight / 100;
const remainingWeight = 1 - weightDecimal;
const required = Math.round(((desired - (current * remainingWeight)) / weightDecimal) * 100);
const diff = current - desired;
let text;
if (required > 100) text = above100[Math.floor(Math.random() * above100.length)];
else if (required > 92 || diff > weight * 0.3) text = above92[Math.floor(Math.random() * above92.length)];
else if (required > 88 || diff > 0) text = above88[Math.floor(Math.random() * above88.length)];
else if (required > 80 || diff > weight * -0.3) text = above80[Math.floor(Math.random() * above80.length)];
else text = below80[Math.floor(Math.random() * below80.length)];
return msg.say(`You will need to score at least ${required}% on your final to get a ${desired}% overall. ${text}`);
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiao",
"version": "58.1.0",
"version": "58.2.0",
"description": "Your personal server companion.",
"main": "Xiao.js",
"scripts": {