Unconcede (#3515)
This commit is contained in:
parent
0dcf97d29d
commit
7cd9b9c0c8
13 changed files with 82 additions and 7 deletions
|
@ -40,7 +40,7 @@ void GameScene::addPlayer(Player *player)
|
||||||
players << player;
|
players << player;
|
||||||
addItem(player);
|
addItem(player);
|
||||||
connect(player, SIGNAL(sizeChanged()), this, SLOT(rearrange()));
|
connect(player, SIGNAL(sizeChanged()), this, SLOT(rearrange()));
|
||||||
connect(player, SIGNAL(gameConceded()), this, SLOT(rearrange()));
|
connect(player, SIGNAL(playerCountChanged()), this, SLOT(rearrange()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameScene::removePlayer(Player *player)
|
void GameScene::removePlayer(Player *player)
|
||||||
|
|
|
@ -169,6 +169,12 @@ void MessageLogWidget::logConcede(Player *player)
|
||||||
appendHtmlServerMessage(tr("%1 has conceded the game.").arg(sanitizeHtml(player->getName())), true);
|
appendHtmlServerMessage(tr("%1 has conceded the game.").arg(sanitizeHtml(player->getName())), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MessageLogWidget::logUnconcede(Player *player)
|
||||||
|
{
|
||||||
|
soundEngine->playSound("player_concede");
|
||||||
|
appendHtmlServerMessage(tr("%1 has unconceded the game.").arg(sanitizeHtml(player->getName())), true);
|
||||||
|
}
|
||||||
|
|
||||||
void MessageLogWidget::logConnectionStateChanged(Player *player, bool connectionState)
|
void MessageLogWidget::logConnectionStateChanged(Player *player, bool connectionState)
|
||||||
{
|
{
|
||||||
if (connectionState) {
|
if (connectionState) {
|
||||||
|
|
|
@ -57,6 +57,7 @@ public slots:
|
||||||
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
||||||
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
||||||
void logConcede(Player *player);
|
void logConcede(Player *player);
|
||||||
|
void logUnconcede(Player *player);
|
||||||
void logConnectionStateChanged(Player *player, bool connectionState);
|
void logConnectionStateChanged(Player *player, bool connectionState);
|
||||||
void logCreateArrow(Player *player,
|
void logCreateArrow(Player *player,
|
||||||
Player *startPlayer,
|
Player *startPlayer,
|
||||||
|
|
|
@ -3037,8 +3037,8 @@ void Player::setConceded(bool _conceded)
|
||||||
setVisible(!conceded);
|
setVisible(!conceded);
|
||||||
if (conceded) {
|
if (conceded) {
|
||||||
clear();
|
clear();
|
||||||
emit gameConceded();
|
|
||||||
}
|
}
|
||||||
|
emit playerCountChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setMirrored(bool _mirrored)
|
void Player::setMirrored(bool _mirrored)
|
||||||
|
|
|
@ -137,7 +137,7 @@ signals:
|
||||||
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
||||||
|
|
||||||
void sizeChanged();
|
void sizeChanged();
|
||||||
void gameConceded();
|
void playerCountChanged();
|
||||||
public slots:
|
public slots:
|
||||||
void actUntapAll();
|
void actUntapAll();
|
||||||
void actRollDie();
|
void actRollDie();
|
||||||
|
|
|
@ -620,11 +620,23 @@ void TabGame::actGameInfo()
|
||||||
|
|
||||||
void TabGame::actConcede()
|
void TabGame::actConcede()
|
||||||
{
|
{
|
||||||
|
Player *player = players.value(localPlayerId, nullptr);
|
||||||
|
if (player == nullptr)
|
||||||
|
return;
|
||||||
|
if (!player->getConceded()) {
|
||||||
if (QMessageBox::question(this, tr("Concede"), tr("Are you sure you want to concede this game?"),
|
if (QMessageBox::question(this, tr("Concede"), tr("Are you sure you want to concede this game?"),
|
||||||
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sendGameCommand(Command_Concede());
|
sendGameCommand(Command_Concede());
|
||||||
|
} else {
|
||||||
|
if (QMessageBox::question(this, tr("Unconcede"),
|
||||||
|
tr("You have already conceded. Do you want to return to this game?"),
|
||||||
|
QMessageBox::Yes | QMessageBox::No, QMessageBox::No) != QMessageBox::Yes)
|
||||||
|
return;
|
||||||
|
|
||||||
|
sendGameCommand(Command_Unconcede());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabGame::actLeaveGame()
|
void TabGame::actLeaveGame()
|
||||||
|
@ -1051,6 +1063,16 @@ void TabGame::eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case GameEventContext::UNCONCEDE: {
|
||||||
|
messageLog->logUnconcede(player);
|
||||||
|
player->setConceded(false);
|
||||||
|
|
||||||
|
QMapIterator<int, Player *> playerIterator(players);
|
||||||
|
while (playerIterator.hasNext())
|
||||||
|
playerIterator.next().value()->updateZones();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
case GameEventContext::DECK_SELECT: {
|
case GameEventContext::DECK_SELECT: {
|
||||||
Context_DeckSelect deckSelect = context.GetExtension(Context_DeckSelect::ext);
|
Context_DeckSelect deckSelect = context.GetExtension(Context_DeckSelect::ext);
|
||||||
messageLog->logDeckSelect(player, QString::fromStdString(deckSelect.deck_hash()),
|
messageLog->logDeckSelect(player, QString::fromStdString(deckSelect.deck_hash()),
|
||||||
|
|
|
@ -5,3 +5,10 @@ message Command_Concede {
|
||||||
optional Command_Concede ext = 1017;
|
optional Command_Concede ext = 1017;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message Command_Unconcede {
|
||||||
|
extend GameCommand {
|
||||||
|
optional Command_Unconcede ext = 1032;
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,3 +6,9 @@ message Context_Concede {
|
||||||
optional Context_Concede ext = 1001;
|
optional Context_Concede ext = 1001;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message Context_Unconcede {
|
||||||
|
extend GameEventContext {
|
||||||
|
optional Context_Unconcede ext = 1009;
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,8 @@ message GameCommand {
|
||||||
DECK_SELECT = 1029;
|
DECK_SELECT = 1029;
|
||||||
SET_SIDEBOARD_LOCK = 1030;
|
SET_SIDEBOARD_LOCK = 1030;
|
||||||
CHANGE_ZONE_PROPERTIES = 1031;
|
CHANGE_ZONE_PROPERTIES = 1031;
|
||||||
|
UNCONCEDE = 1032;
|
||||||
|
|
||||||
}
|
}
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ message GameEventContext {
|
||||||
PING_CHANGED = 1006;
|
PING_CHANGED = 1006;
|
||||||
CONNECTION_STATE_CHANGED = 1007;
|
CONNECTION_STATE_CHANGED = 1007;
|
||||||
SET_SIDEBOARD_LOCK = 1008;
|
SET_SIDEBOARD_LOCK = 1008;
|
||||||
|
UNCONCEDE = 1009;
|
||||||
}
|
}
|
||||||
extensions 100 to max;
|
extensions 100 to max;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,7 +77,6 @@ private:
|
||||||
Server_Player *playerWhosAsking,
|
Server_Player *playerWhosAsking,
|
||||||
bool omniscient,
|
bool omniscient,
|
||||||
bool withUserInfo);
|
bool withUserInfo);
|
||||||
void sendGameStateToPlayers();
|
|
||||||
void storeGameInformation();
|
void storeGameInformation();
|
||||||
signals:
|
signals:
|
||||||
void sigStartGameIfReady();
|
void sigStartGameIfReady();
|
||||||
|
@ -192,6 +191,7 @@ public:
|
||||||
prepareGameEvent(const ::google::protobuf::Message &gameEvent, int playerId, GameEventContext *context = 0);
|
prepareGameEvent(const ::google::protobuf::Message &gameEvent, int playerId, GameEventContext *context = 0);
|
||||||
GameEventContext prepareGameEventContext(const ::google::protobuf::Message &gameEventContext);
|
GameEventContext prepareGameEventContext(const ::google::protobuf::Message &gameEventContext);
|
||||||
|
|
||||||
|
void sendGameStateToPlayers();
|
||||||
void sendGameEventContainer(GameEventContainer *cont,
|
void sendGameEventContainer(GameEventContainer *cont,
|
||||||
GameEventStorageItem::EventRecipients recipients = GameEventStorageItem::SendToPrivate |
|
GameEventStorageItem::EventRecipients recipients = GameEventStorageItem::SendToPrivate |
|
||||||
GameEventStorageItem::SendToOthers,
|
GameEventStorageItem::SendToOthers,
|
||||||
|
|
|
@ -776,6 +776,30 @@ Server_Player::cmdConcede(const Command_Concede & /*cmd*/, ResponseContainer & /
|
||||||
return Response::RespOk;
|
return Response::RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Response::ResponseCode
|
||||||
|
Server_Player::cmdUnconcede(const Command_Unconcede & /*cmd*/, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||||
|
{
|
||||||
|
if (spectator)
|
||||||
|
return Response::RespFunctionNotAllowed;
|
||||||
|
if (!game->getGameStarted())
|
||||||
|
return Response::RespGameNotStarted;
|
||||||
|
if (!conceded)
|
||||||
|
return Response::RespContextError;
|
||||||
|
|
||||||
|
setConceded(false);
|
||||||
|
|
||||||
|
Event_PlayerPropertiesChanged event;
|
||||||
|
event.mutable_player_properties()->set_conceded(false);
|
||||||
|
ges.enqueueGameEvent(event, playerId);
|
||||||
|
ges.setGameEventContext(Context_Unconcede());
|
||||||
|
|
||||||
|
setupZones();
|
||||||
|
|
||||||
|
game->sendGameStateToPlayers();
|
||||||
|
|
||||||
|
return Response::RespOk;
|
||||||
|
}
|
||||||
|
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
Server_Player::cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
Server_Player::cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer & /*rc*/, GameEventStorage &ges)
|
||||||
{
|
{
|
||||||
|
@ -1826,6 +1850,10 @@ Server_Player::processGameCommand(const GameCommand &command, ResponseContainer
|
||||||
case GameCommand::CHANGE_ZONE_PROPERTIES:
|
case GameCommand::CHANGE_ZONE_PROPERTIES:
|
||||||
return cmdChangeZoneProperties(command.GetExtension(Command_ChangeZoneProperties::ext), rc, ges);
|
return cmdChangeZoneProperties(command.GetExtension(Command_ChangeZoneProperties::ext), rc, ges);
|
||||||
break;
|
break;
|
||||||
|
case GameCommand::UNCONCEDE:
|
||||||
|
return cmdUnconcede(command.GetExtension(Command_Unconcede::ext), rc, ges);
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return Response::RespInvalidCommand;
|
return Response::RespInvalidCommand;
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,7 @@ class Command_SetCardCounter;
|
||||||
class Command_IncCardCounter;
|
class Command_IncCardCounter;
|
||||||
class Command_ReadyStart;
|
class Command_ReadyStart;
|
||||||
class Command_Concede;
|
class Command_Concede;
|
||||||
|
class Command_Unconcede;
|
||||||
class Command_IncCounter;
|
class Command_IncCounter;
|
||||||
class Command_CreateCounter;
|
class Command_CreateCounter;
|
||||||
class Command_SetCounter;
|
class Command_SetCounter;
|
||||||
|
@ -190,6 +191,7 @@ public:
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
cmdKickFromGame(const Command_KickFromGame &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
cmdKickFromGame(const Command_KickFromGame &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdConcede(const Command_Concede &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdConcede(const Command_Concede &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
|
Response::ResponseCode cmdUnconcede(const Command_Unconcede &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdReadyStart(const Command_ReadyStart &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
Response::ResponseCode cmdDeckSelect(const Command_DeckSelect &cmd, ResponseContainer &rc, GameEventStorage &ges);
|
||||||
Response::ResponseCode
|
Response::ResponseCode
|
||||||
|
|
Loading…
Reference in a new issue