Add /8ball

This commit is contained in:
MangosArentLiterature 2021-04-04 16:16:37 -05:00
parent 9aab9f30bc
commit b1c00cb46f
3 changed files with 56 additions and 0 deletions

View File

@ -0,0 +1,20 @@
It is certain.
It is decidedly so.
Without a doubt.
Yes - definitely.
You may rely on it.
As I see it, yes.
Most likely.
Outlook good.
Yes.
Signs point to yes.
Reply hazy, try again.
Ask again later.
Better not tell you now.
Cannot predict now.
Concentrate and ask again.
Don't count on it.
My reply is no.
My sources say no.
Outlook not so good.
Very doubtful.

View File

@ -1369,6 +1369,8 @@ class AOClient : public QObject {
*/
void cmdPM(int argc, QStringList argv);
void cmd8Ball(int argc, QStringList argv);
///@}
/**
@ -1560,6 +1562,7 @@ class AOClient : public QObject {
{"notecard_reveal", {ACLFlags.value("CM"), 0, &AOClient::cmdNoteCardReveal}},
{"notecardclear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
{"notecard_clear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
{"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}},
};
/**

View File

@ -1240,6 +1240,39 @@ void AOClient::cmdNoteCardReveal(int argc, QStringList argv)
area->notecards.clear();
}
void AOClient::cmd8Ball(int argc, QStringList argv)
{
QFileInfo magic8ball_info("config/text/8ball.txt");
if (!(magic8ball_info.exists() && magic8ball_info.isFile())) {
qWarning() << "8ball.txt doesn't exist!";
sendServerMessage("8ball.txt doesn't exist.");
}
else {
QStringList answers;
QFile file("config/text/8ball.txt");
file.open(QIODevice::ReadOnly | QIODevice::Text);
while (!file.atEnd()) {
answers.append(file.readLine().trimmed());
}
file.close();
if (answers.isEmpty()) {
qWarning() << "8ball.txt is empty!";
sendServerMessage("8ball.txt is empty.");
}
else {
int answerindex = answers.size();
QString response = answers[(genRand(1, answerindex))];
QString sender_name = ooc_name;
QString sender_message = argv.join(" ");
sendServerMessageArea(sender_name + " asked the magic 8-ball " + sender_message + " and the answer is: " + response);
}
}
}
QStringList AOClient::buildAreaList(int area_idx)
{
QStringList entries;