diff --git a/bin/config_sample/text/gimp.txt b/bin/config_sample/text/gimp.txt new file mode 100644 index 0000000..db1e8ea --- /dev/null +++ b/bin/config_sample/text/gimp.txt @@ -0,0 +1,11 @@ +I love the mods on this server! +At 3:03 PM maya went into my house and ate my corn bread +Enlargement +Do you think I am imcompetent? +WE CAN'T TRUST ANY OF THE WITNESSES THROW THEM ALL OUT +I'm not a clown, I'm the entire circus. +What if the murder, it was not a murder? +omti +<3 +what's an akashi +*punches bailiff* diff --git a/include/aoclient.h b/include/aoclient.h index a02f111..fa755a6 100644 --- a/include/aoclient.h +++ b/include/aoclient.h @@ -221,17 +221,17 @@ class AOClient : public QObject { /** * @brief If true, the client's in-character messages will have their word order randomised. */ - bool is_shaken; + bool is_shaken = false; /** * @brief If true, the client's in-character messages will have their vowels (English alphabet only) removed. */ - bool is_disemvoweled; + bool is_disemvoweled = false; /** * @brief If true, the client's in-character messages will be overwritten by a randomly picked predetermined message. */ - bool is_gimped; + bool is_gimped = false; public slots: /** @@ -1399,6 +1399,60 @@ class AOClient : public QObject { */ void cmd8Ball(int argc, QStringList argv); + /** + * @brief Replaces a target client's in-character messages with strings randomly selected from gimp.txt. + * + * @details The only argument is the **the target's ID** whom the client wants to gimp. + * + * @iscommand + */ + void cmdGimp(int argc, QStringList argv); + + /** + * @brief Allows a gimped client to speak normally. + * + * @details The only argument is **the target's ID** whom the client wants to ungimp. + * + * @iscommand + */ + void cmdUnGimp(int argc, QStringList argv); + + /** + * @brief Removes all vowels from a target client's in-character messages. + * + * @details The only argument is **the target's ID** whom the client wants to disemvowel. + * + * @iscommand + */ + void cmdDisemvowel(int argc, QStringList argv); + + /** + * @brief Allows a disemvoweled client to speak normally. + * + * @details The only argument is **the target's ID** whom the client wants to undisemvowel. + * + * @iscommand + */ + void cmdUnDisemvowel(int argc, QStringList argv); + + /** + * @brief Scrambles the words of a target client's in-character messages. + * + * @details The only argument is **the target's ID** whom the client wants to shake. + * + * @iscommand + */ + void cmdShake(int argc, QStringList argv); + + /** + * @brief Allows a shaken client to speak normally. + * + * @details The only argument is **the target's ID** whom the client wants to unshake. + * + * @iscommand + */ + void cmdUnShake(int argc, QStringList argv); + /** * @brief Reloads all server configuration files. * @@ -1624,8 +1678,14 @@ class AOClient : public QObject { {"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}}, {"judgelog", {ACLFlags.value("CM"), 0, &AOClient::cmdJudgeLog}}, {"allow_blankposting", {ACLFlags.value("MODCHAT"), 0, &AOClient::cmdAllow_Blankposting}}, + {"gimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdGimp}}, + {"ungimp", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnGimp}}, {"baninfo", {ACLFlags.value("BAN"), 1, &AOClient::cmdBanInfo}}, {"reload", {ACLFlags.value("SUPER"), 0, &AOClient::cmdReload}}, + {"disemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdDisemvowel}}, + {"undisemvowel", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnDisemvowel}}, + {"shake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdShake}}, + {"unshake", {ACLFlags.value("MUTE"), 1, &AOClient::cmdUnShake}}, }; /** diff --git a/include/server.h b/include/server.h index 4c98e87..a02743e 100644 --- a/include/server.h +++ b/include/server.h @@ -264,6 +264,11 @@ class Server : public QObject { */ QStringList reprimands_list; + /** + * @brief List holding the contents of gimp.txt, used by AOClient::cmdGimp. + */ + QStringList gimp_list; + public slots: /** * @brief Handles a new connection. diff --git a/src/commands.cpp b/src/commands.cpp index 39505f3..b5a47d6 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -1289,6 +1289,45 @@ void AOClient::cmdAllow_Blankposting(int argc, QStringList argv) } } +void AOClient::cmdGimp(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_gimped) + sendServerMessage("That player is already gimped!"); + else { + sendServerMessage("Gimped player."); + target->sendServerMessage("You have been gimped! " + getReprimand()); + } + target->is_gimped = true; +} + +void AOClient::cmdUnGimp(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!(target->is_gimped)) + sendServerMessage("That player is not gimped!"); + else { + sendServerMessage("Ungimped player."); + target->sendServerMessage("A moderator has ungimped you! " + getReprimand(true)); + } + target->is_gimped = false; +} void AOClient::cmdBanInfo(int argc, QStringList argv) { QStringList ban_info; @@ -1335,6 +1374,86 @@ void AOClient::cmdReload(int argc, QStringList argv) sendServerMessage("Reloaded configurations"); } +void AOClient::cmdDisemvowel(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_disemvoweled) + sendServerMessage("That player is already disemvoweled!"); + else { + sendServerMessage("Disemvoweled player."); + target->sendServerMessage("You have been disemvoweled! " + getReprimand()); + } + target->is_disemvoweled = true; +} + +void AOClient::cmdUnDisemvowel(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!(target->is_disemvoweled)) + sendServerMessage("That player is not disemvoweled!"); + else { + sendServerMessage("Undisemvoweled player."); + target->sendServerMessage("A moderator has undisemvoweled you! " + getReprimand(true)); + } + target->is_disemvoweled = false; +} + +void AOClient::cmdShake(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (target->is_shaken) + sendServerMessage("That player is already shaken!"); + else { + sendServerMessage("Shook player."); + target->sendServerMessage("A moderator has shaken your words! " + getReprimand()); + } + target->is_shaken = true; +} + +void AOClient::cmdUnShake(int argc, QStringList argv) +{ + bool conv_ok = false; + int uid = argv[0].toInt(&conv_ok); + if (!conv_ok) { + sendServerMessage("Invalid user ID."); + return; + } + + AOClient* target = server->getClientByID(uid); + + if (!(target->is_shaken)) + sendServerMessage("That player is not shaken!"); + else { + sendServerMessage("Unshook player."); + target->sendServerMessage("A moderator has unshook you! " + getReprimand(true)); + } + target->is_shaken = false; +} + QStringList AOClient::buildAreaList(int area_idx) { QStringList entries; diff --git a/src/config_manager.cpp b/src/config_manager.cpp index 016991e..048bd4d 100644 --- a/src/config_manager.cpp +++ b/src/config_manager.cpp @@ -182,7 +182,7 @@ bool ConfigManager::fileExists(QFileInfo* file) bool ConfigManager::verifyCommandConfig() { - QStringList filelist = {"8ball", "praise", "reprimands"}; + QStringList filelist = {"8ball", "praise", "reprimands", "gimp"}; foreach (QString filename, filelist) { QFileInfo file("config/text/" + filename + ".txt"); if (!(fileExists(&file))) { diff --git a/src/packets.cpp b/src/packets.cpp index fb35689..a922595 100644 --- a/src/packets.cpp +++ b/src/packets.cpp @@ -443,6 +443,24 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) sendServerMessage("Blankposting has been forbidden in this area."); return invalid; } + + if (is_gimped) { + QString gimp_message = server->gimp_list[(genRand(1, server->gimp_list.size() - 1))]; + incoming_msg = gimp_message; + } + + if (is_shaken) { + QStringList parts = incoming_msg.split(" "); + std::random_shuffle(parts.begin(), parts.end()); + incoming_msg = parts.join(" "); + } + + if (is_disemvoweled) { + QString disemvoweled_message = incoming_msg.remove(QRegExp("[AEIOUaeiou]")); + incoming_msg = disemvoweled_message; + } + + last_message = incoming_msg; args.append(incoming_msg); // side diff --git a/src/server.cpp b/src/server.cpp index 2b44c7b..9ac35c8 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -203,6 +203,7 @@ void Server::loadCommandConfig() magic_8ball_answers = (loadConfigFile("8ball")); praise_list = (loadConfigFile("praise")); reprimands_list = (loadConfigFile("reprimands")); + gimp_list = (loadConfigFile("gimp")); } QStringList Server::loadConfigFile(QString filename)