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()));
}
void TabGame::addMentionTag(QString value)
void TabGame::addMentionTag(const QString &value)
{
sayEdit->insert(value + " ");
sayEdit->setFocus();
}
void TabGame::linkCardToChat(QString cardName)
void TabGame::linkCardToChat(const QString &cardName)
{
sayEdit->insert("[[" + cardName + "]] ");
sayEdit->setFocus();
@ -1814,10 +1814,19 @@ void TabGame::createMessageDock(bool bReplay)
sayEdit->setCompleter(completer);
actCompleterChanged();
if (spectator && !gameInfo.spectators_can_chat() && tabSupervisor->getAdminLocked()) {
if (spectator) {
/* 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 = !tabSupervisor->getAdminLocked() || judge;
if (!isModOrJudge && !gameInfo.spectators_can_chat()) {
sayLabel->hide();
sayEdit->hide();
}
}
connect(tabSupervisor, SIGNAL(adminLockChanged(bool)), this, SLOT(adminLockChanged(bool)));
connect(sayEdit, SIGNAL(returnPressed()), this, SLOT(actSay()));

View file

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

View file

@ -621,6 +621,11 @@ void TabSupervisor::updateCurrent(int index)
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
{
if (!tabAdmin)

View file

@ -919,9 +919,17 @@ Server_Player::cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &
Response::ResponseCode
Server_Player::cmdGameSay(const Command_GameSay &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
{
if (spectator && !game->getSpectatorsCanTalk() && !(userInfo->user_level() & ServerInfo_User::IsModerator)) {
if (spectator) {
/* 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.set_message(cmd.message());