Add /judgelog command

Adds a judgelog to each area and a helper function to update it. Adds /judgelog to retrieve it.
This commit is contained in:
MangosArentLiterature 2021-04-06 00:41:28 -05:00
parent a54772234d
commit d98eedd6e9
5 changed files with 40 additions and 1 deletions

View File

@ -1389,6 +1389,8 @@ class AOClient : public QObject {
*/ */
void cmd8Ball(int argc, QStringList argv); void cmd8Ball(int argc, QStringList argv);
void cmdJudgeLog(int argc, QStringList argv);
///@} ///@}
/** /**
@ -1582,6 +1584,7 @@ class AOClient : public QObject {
{"notecard_clear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}}, {"notecard_clear", {ACLFlags.value("NONE"), 0, &AOClient::cmdNoteCardClear}},
{"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}}, {"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}},
{"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}}, {"lm", {ACLFlags.value("MODCHAT"), 1, &AOClient::cmdLM}},
{"judgelog", {ACLFlags.value("CM"), 0, &AOClient::cmdJudgeLog}}
}; };
/** /**
@ -1629,6 +1632,8 @@ class AOClient : public QObject {
* @details Used to determine if the incoming message is a duplicate. * @details Used to determine if the incoming message is a duplicate.
*/ */
QString last_message; QString last_message;
void updateJudgeLog(AreaData* area, AOClient* client, QString action);
}; };
#endif // AOCLIENT_H #endif // AOCLIENT_H

View File

@ -272,6 +272,8 @@ class AreaData : public QObject {
*/ */
EvidenceMod evi_mod; EvidenceMod evi_mod;
QMap<QString, QString> notecards; QMap<QString, QString> notecards;
QStringList judgelog;
}; };
#endif // AREA_DATA_H #endif // AREA_DATA_H

View File

@ -24,7 +24,8 @@ AreaData::AreaData(QString p_name, int p_index) :
locked(FREE), locked(FREE),
document("No document."), document("No document."),
def_hp(10), def_hp(10),
pro_hp(10) pro_hp(10),
judgelog()
{ {
QStringList name_split = p_name.split(":"); QStringList name_split = p_name.split(":");
name_split.removeFirst(); name_split.removeFirst();

View File

@ -1280,6 +1280,17 @@ void AOClient::cmd8Ball(int argc, QStringList argv)
} }
void AOClient::cmdJudgeLog(int argc, QStringList argv)
{
AreaData* area = server->areas[current_area];
if (area->judgelog.isEmpty()) {
sendServerMessage("There have been no judge actions in this area.");
return;
}
QString message = area->judgelog.join("\n");
sendServerMessage(message);
}
QStringList AOClient::buildAreaList(int area_idx) QStringList AOClient::buildAreaList(int area_idx)
{ {
QStringList entries; QStringList entries;

View File

@ -260,6 +260,7 @@ void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket pack
return; return;
last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch(); last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch();
server->broadcast(packet, current_area); server->broadcast(packet, current_area);
updateJudgeLog(area, this, "WT/CE");
} }
void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket packet)
@ -276,6 +277,7 @@ void AOClient::pktHpBar(AreaData* area, int argc, QStringList argv, AOPacket pac
} }
server->broadcast(AOPacket("HP", {"1", QString::number(area->def_hp)}), area->index); server->broadcast(AOPacket("HP", {"1", QString::number(area->def_hp)}), area->index);
server->broadcast(AOPacket("HP", {"2", QString::number(area->pro_hp)}), area->index); server->broadcast(AOPacket("HP", {"2", QString::number(area->pro_hp)}), area->index);
updateJudgeLog(area, this, "updated the penalties");
} }
void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPacket packet) void AOClient::pktWebSocketIp(AreaData* area, int argc, QStringList argv, AOPacket packet)
@ -638,3 +640,21 @@ bool AOClient::checkEvidenceAccess(AreaData *area)
return false; return false;
} }
} }
void AOClient::updateJudgeLog(AreaData* area, AOClient* client, QString action)
{
QString timestamp = QTime::currentTime().toString("hh:mm:ss");
QString uid = QString::number(client->id);
QString char_name = client->current_char;
QString ipid = client->getIpid();
QString message = action;
QString logmessage = QString("[%1]: [%2] %3 (%4) %5").arg(timestamp, uid, char_name, ipid, message);
int size = area->judgelog.size();
if (size == 10) {
area->judgelog.removeFirst();
area->judgelog.append(logmessage);
}
else area->judgelog.append(logmessage);
}