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:
parent
a54772234d
commit
d98eedd6e9
@ -1389,6 +1389,8 @@ class AOClient : public QObject {
|
||||
*/
|
||||
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}},
|
||||
{"8ball", {ACLFlags.value("NONE"), 1, &AOClient::cmd8Ball}},
|
||||
{"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.
|
||||
*/
|
||||
QString last_message;
|
||||
|
||||
void updateJudgeLog(AreaData* area, AOClient* client, QString action);
|
||||
};
|
||||
|
||||
#endif // AOCLIENT_H
|
||||
|
@ -272,6 +272,8 @@ class AreaData : public QObject {
|
||||
*/
|
||||
EvidenceMod evi_mod;
|
||||
QMap<QString, QString> notecards;
|
||||
|
||||
QStringList judgelog;
|
||||
};
|
||||
|
||||
#endif // AREA_DATA_H
|
||||
|
@ -24,7 +24,8 @@ AreaData::AreaData(QString p_name, int p_index) :
|
||||
locked(FREE),
|
||||
document("No document."),
|
||||
def_hp(10),
|
||||
pro_hp(10)
|
||||
pro_hp(10),
|
||||
judgelog()
|
||||
{
|
||||
QStringList name_split = p_name.split(":");
|
||||
name_split.removeFirst();
|
||||
|
@ -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 entries;
|
||||
|
@ -260,6 +260,7 @@ void AOClient::pktWtCe(AreaData* area, int argc, QStringList argv, AOPacket pack
|
||||
return;
|
||||
last_wtce_time = QDateTime::currentDateTime().toSecsSinceEpoch();
|
||||
server->broadcast(packet, current_area);
|
||||
updateJudgeLog(area, this, "WT/CE");
|
||||
}
|
||||
|
||||
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", {"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)
|
||||
@ -638,3 +640,21 @@ bool AOClient::checkEvidenceAccess(AreaData *area)
|
||||
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);
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user