Add end to sorting hat

This commit is contained in:
lilyissillyyy
2025-09-18 17:24:14 -04:00
parent 7cf53e2b33
commit 43423c9977
2 changed files with 31 additions and 6 deletions
+23 -2
View File
@@ -1271,18 +1271,39 @@
}
]
}
],
"bigot": [
{
"text": "Do you agree that J.K. Rowling is a disgusting bigot?",
"answers": [
{
"text": "Yes, of course.",
"points": {
"b": 0
}
},
{
"text": "No, I agree with her.",
"points": {
"b": 100
}
}
]
}
]
},
"houses": {
"g": "Gryffindor",
"r": "Ravenclaw",
"h": "Hufflepuff",
"s": "Slytherin"
"s": "Slytherin",
"b": "Bigot"
},
"descriptions": {
"g": "With a lion as its crest and Professor McGonagall at its head, Gryffindor is the house which most values the virtues of courage, bravery and determination.",
"r": "Ravenclaws prize wit, learning, and wisdom. It's an ethos etched into founder Rowena Ravenclaw diadem: 'wit beyond measure is man's greatest treasure'.",
"h": "Hufflepuffs value hard work, patience, loyalty, and fair play. The house has produced its share of great wizards not least Newt Scamander, author of Fantastic Beasts and Where to Find Them.",
"s": "Slytherin produces more than its share of Dark wizards, but also turns out leaders who are proud, ambitious and cunning. Merlin is one particularly famous Slytherin."
"s": "Slytherin produces more than its share of Dark wizards, but also turns out leaders who are proud, ambitious and cunning. Merlin is one particularly famous Slytherin.",
"b": "I'm sorry, but I don't offer my services to bigots. You'll have to come again after some self-reflection."
}
}
+8 -4
View File
@@ -2,7 +2,7 @@ const Command = require('../../framework/Command');
const { stripIndents } = require('common-tags');
const { shuffle } = require('../../util/Util');
const { questions, houses, descriptions } = require('../../assets/json/sorting-hat');
const choices = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P'];
const choices = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'END'];
module.exports = class SortingHatCommand extends Command {
constructor(client) {
@@ -33,17 +33,20 @@ module.exports = class SortingHatCommand extends Command {
g: 0,
s: 0,
h: 0,
r: 0
r: 0,
b: 0
};
const blacklist = [];
const questionNums = ['2', '3', '4', '5', '6', '7'];
let turn = 1;
while (turn < 9) {
while (turn < 10) {
let question;
if (turn === 1) {
question = questions.first[Math.floor(Math.random() * questions.first.length)];
} else if (turn === 8) {
question = questions.last[Math.floor(Math.random() * questions.last.length)];
} else if (turn === 9) {
question = questions.bigot[0];
} else {
const possible = questionNums.filter(num => !blacklist.includes(num));
const value = possible[Math.floor(Math.random() * possible.length)];
@@ -53,7 +56,7 @@ module.exports = class SortingHatCommand extends Command {
}
const answers = shuffle(question.answers);
await msg.say(stripIndents`
**${turn}.** ${question.text}
**${turn}.** ${question.text} _(Type \`end\` to end)_
${answers.map((answer, i) => `- **${choices[i]}.** ${answer.text}`).join('\n')}
`);
const filter = res =>
@@ -65,6 +68,7 @@ module.exports = class SortingHatCommand extends Command {
});
if (!choice.size) return msg.say('Oh no, you ran out of time! Too bad.');
const answer = answers[choices.indexOf(choice.first().content.toUpperCase())];
if (answer === 'END') return msg.say('See you next time!');
for (const [house, amount] of Object.entries(answer.points)) points[house] += amount;
++turn;
}