Judges can talk in games (#4091)

This commit is contained in:
Zach H 2020-09-09 13:20:59 -04:00 committed by GitHub
parent 79f590c99a
commit bec02b4952
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 9 deletions

View file

@ -445,13 +445,13 @@ TabGame::TabGame(TabSupervisor *_tabSupervisor,
QTimer::singleShot(0, this, SLOT(loadLayout())); QTimer::singleShot(0, this, SLOT(loadLayout()));
} }
void TabGame::addMentionTag(QString value) void TabGame::addMentionTag(const QString &value)
{ {
sayEdit->insert(value + " "); sayEdit->insert(value + " ");
sayEdit->setFocus(); sayEdit->setFocus();
} }
void TabGame::linkCardToChat(QString cardName) void TabGame::linkCardToChat(const QString &cardName)
{ {
sayEdit->insert("[[" + cardName + "]] "); sayEdit->insert("[[" + cardName + "]] ");
sayEdit->setFocus(); sayEdit->setFocus();
@ -1814,10 +1814,19 @@ void TabGame::createMessageDock(bool bReplay)
sayEdit->setCompleter(completer); sayEdit->setCompleter(completer);
actCompleterChanged(); actCompleterChanged();
if (spectator && !gameInfo.spectators_can_chat() && tabSupervisor->getAdminLocked()) { if (spectator) {
sayLabel->hide(); /* Spectators can only talk if:
sayEdit->hide(); * (a) the game creator allows it
* (b) the spectator is a moderator/administrator
* (c) the spectator is a judge
*/
bool isModOrJudge = !tabSupervisor->getAdminLocked() || judge;
if (!isModOrJudge && !gameInfo.spectators_can_chat()) {
sayLabel->hide();
sayEdit->hide();
}
} }
connect(tabSupervisor, SIGNAL(adminLockChanged(bool)), this, SLOT(adminLockChanged(bool))); connect(tabSupervisor, SIGNAL(adminLockChanged(bool)), this, SLOT(adminLockChanged(bool)));
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay())); connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay()));

View file

@ -242,8 +242,8 @@ private slots:
void actNextTurn(); void actNextTurn();
void actReverseTurn(); void actReverseTurn();
void addMentionTag(QString value); void addMentionTag(const QString &value);
void linkCardToChat(QString cardName); void linkCardToChat(const QString &cardName);
void commandFinished(const Response &response); void commandFinished(const Response &response);
void refreshShortcuts(); void refreshShortcuts();

View file

@ -621,6 +621,11 @@ void TabSupervisor::updateCurrent(int index)
emit setMenu(); emit setMenu();
} }
/**
* Determine if a user is a moderator/administrator
* By seeing if they have the admin tab open & unlocked
* @return if the admin tab is open & unlocked
*/
bool TabSupervisor::getAdminLocked() const bool TabSupervisor::getAdminLocked() const
{ {
if (!tabAdmin) if (!tabAdmin)

View file

@ -919,8 +919,16 @@ Server_Player::cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &
Response::ResponseCode Response::ResponseCode
Server_Player::cmdGameSay(const Command_GameSay &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges) Server_Player::cmdGameSay(const Command_GameSay &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
{ {
if (spectator && !game->getSpectatorsCanTalk() && !(userInfo->user_level() & ServerInfo_User::IsModerator)) { if (spectator) {
return Response::RespFunctionNotAllowed; /* Spectators can only talk if:
* (a) the game creator allows it
* (b) the spectator is a moderator/administrator
* (c) the spectator is a judge
*/
bool isModOrJudge = (userInfo->user_level() & (ServerInfo_User::IsModerator | ServerInfo_User::IsJudge));
if (!isModOrJudge && !game->getSpectatorsCanTalk()) {
return Response::RespFunctionNotAllowed;
}
} }
Event_GameSay event; Event_GameSay event;