Update /8ball and AOClient::getReprimands to use the new command config loader
This commit is contained in:
parent
290862c504
commit
cff51674bb
@ -1249,35 +1249,18 @@ void AOClient::cmdNoteCardReveal(int argc, QStringList argv)
|
|||||||
|
|
||||||
void AOClient::cmd8Ball(int argc, QStringList argv)
|
void AOClient::cmd8Ball(int argc, QStringList argv)
|
||||||
{
|
{
|
||||||
QFileInfo magic8ball_info("config/text/8ball.txt");
|
if (server->magic_8ball_answers.isEmpty()) {
|
||||||
if (!(magic8ball_info.exists() && magic8ball_info.isFile())) {
|
qWarning() << "8ball.txt is empty!";
|
||||||
qWarning() << "8ball.txt doesn't exist!";
|
sendServerMessage("8ball.txt is empty.");
|
||||||
sendServerMessage("8ball.txt doesn't exist.");
|
}
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
QStringList answers;
|
int answerindex = server->magic_8ball_answers.size();
|
||||||
QFile file("config/text/8ball.txt");
|
QString response = server->magic_8ball_answers[(genRand(1, answerindex))];
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
QString sender_name = ooc_name;
|
||||||
while (!file.atEnd()) {
|
QString sender_message = argv.join(" ");
|
||||||
answers.append(file.readLine().trimmed());
|
|
||||||
|
sendServerMessageArea(sender_name + " asked the magic 8-ball, \"" + sender_message + "\" and the answer is: " + response);
|
||||||
}
|
}
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::cmdAllow_Blankposting(int argc, QStringList argv)
|
void AOClient::cmdAllow_Blankposting(int argc, QStringList argv)
|
||||||
@ -1454,18 +1437,10 @@ long long AOClient::parseTime(QString input)
|
|||||||
|
|
||||||
QString AOClient::getReprimand(bool positive)
|
QString AOClient::getReprimand(bool positive)
|
||||||
{
|
{
|
||||||
QString filename = positive ? "praise" : "reprimands";
|
if (positive) {
|
||||||
QFileInfo reprimands_info("config/text/" + filename + ".txt");
|
return server->praise_list[genRand(0, server->praise_list.size() - 1)];
|
||||||
if (!(reprimands_info.exists() && reprimands_info.isFile())) {
|
}
|
||||||
qWarning() << filename + ".txt doesn't exist!";
|
else {
|
||||||
return "";
|
return server->reprimands_list[genRand(0, server->reprimands_list.size() - 1)];
|
||||||
}
|
}
|
||||||
QStringList reprimands;
|
|
||||||
QFile file("config/text/" + filename + ".txt");
|
|
||||||
file.open(QIODevice::ReadOnly | QIODevice::Text);
|
|
||||||
while (!file.atEnd()) {
|
|
||||||
reprimands.append(file.readLine().trimmed());
|
|
||||||
}
|
|
||||||
file.close();
|
|
||||||
return reprimands[genRand(0, reprimands.size() - 1)];
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user