mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-13 05:20:00 -08:00
[Client] Let moderators set the turn order
The server accepts SET_PLAYER_ORDER from the host or a moderator, but the client hid the action from everyone except the host, making the moderator branch unreachable. Visibility and the handler now share canSetTurnOrder().
This commit is contained in:
parent
e945b73e3a
commit
16a2e70039
2 changed files with 23 additions and 4 deletions
|
|
@ -634,7 +634,7 @@ void TabGame::actConcede()
|
|||
|
||||
void TabGame::actTurnOrder()
|
||||
{
|
||||
if (!game->isHost() || game->getGameMetaInfo()->started()) {
|
||||
if (!canSetTurnOrder()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -668,17 +668,35 @@ void TabGame::actTurnOrder()
|
|||
game->getGameEventHandler()->handleSetPlayerOrder(dlg.order(), dlg.isRandomizeRequested());
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the local user may change the seating order: only while the game has
|
||||
* not started, and only as the host or a moderator - the server allows both
|
||||
* (Server_AbstractParticipant::cmdSetPlayerOrder).
|
||||
*/
|
||||
bool TabGame::canSetTurnOrder() const
|
||||
{
|
||||
if (game->getGameMetaInfo()->started()) {
|
||||
return false;
|
||||
}
|
||||
if (game->isHost()) {
|
||||
return true;
|
||||
}
|
||||
const ServerInfo_User *userInfo = tabSupervisor->getUserInfo();
|
||||
return userInfo != nullptr && (userInfo->user_level() & ServerInfo_User::IsModerator);
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the turn order action only when it can actually change anything: the
|
||||
* player must be host and the game must not have started yet. Called whenever
|
||||
* either condition may have changed (game start/stop, host change).
|
||||
* player must be allowed to set the order and the game must not have started.
|
||||
* Called whenever either condition may have changed (game start/stop, host
|
||||
* change).
|
||||
*/
|
||||
void TabGame::updateTurnOrderAction()
|
||||
{
|
||||
if (aTurnOrder == nullptr) {
|
||||
return;
|
||||
}
|
||||
aTurnOrder->setVisible(game->isHost() && !game->getGameMetaInfo()->started());
|
||||
aTurnOrder->setVisible(canSetTurnOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ private:
|
|||
|
||||
PlayerLogic *setActivePlayer(int id);
|
||||
void setActivePhase(int phase);
|
||||
bool canSetTurnOrder() const;
|
||||
void createMenuItems();
|
||||
void createReplayMenuItems();
|
||||
void createViewMenuItems();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue