Add /shake

- also adds /unshake
This commit is contained in:
MangosArentLiterature 2021-04-14 02:09:58 -05:00
parent 9b54a44a52
commit 8e4f8c31c7
3 changed files with 48 additions and 0 deletions

View File

@ -1684,6 +1684,8 @@ class AOClient : public QObject {
{"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}},
};
/**

View File

@ -1414,6 +1414,46 @@ void AOClient::cmdUnDisemvowel(int argc, QStringList argv)
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;

View File

@ -449,6 +449,12 @@ AOPacket AOClient::validateIcPacket(AOPacket packet)
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;