mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
implemented conceding
This commit is contained in:
parent
207d10d3e2
commit
78c1851c52
18 changed files with 168 additions and 51 deletions
|
|
@ -64,6 +64,8 @@ void Server_Game::startGameIfReady()
|
|||
playerIterator.toFront();
|
||||
while (playerIterator.hasNext()) {
|
||||
Server_Player *player = playerIterator.next().value();
|
||||
player->setConceded(false);
|
||||
player->setReadyStart(false);
|
||||
player->sendProtocolItem(new Event_GameStateChanged(gameId, gameStarted, 0, 0, getGameState(player)));
|
||||
}
|
||||
|
||||
|
|
@ -87,6 +89,27 @@ void Server_Game::startGameIfReady()
|
|||
setActivePlayer(0);
|
||||
}
|
||||
|
||||
void Server_Game::stopGameIfFinished()
|
||||
{
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
int playing = 0;
|
||||
while (playerIterator.hasNext()) {
|
||||
Server_Player *p = playerIterator.next().value();
|
||||
if (!p->getConceded() && !p->getSpectator())
|
||||
++playing;
|
||||
}
|
||||
if (playing > 1)
|
||||
return;
|
||||
|
||||
gameStarted = false;
|
||||
playerIterator.toFront();
|
||||
while (playerIterator.hasNext()) {
|
||||
Server_Player *player = playerIterator.next().value();
|
||||
player->sendProtocolItem(new Event_GameStateChanged(gameId, gameStarted, -1, -1, getGameState(player)));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ResponseCode Server_Game::checkJoin(const QString &_password, bool spectator)
|
||||
{
|
||||
if (_password != password)
|
||||
|
|
@ -215,7 +238,7 @@ QList<ServerInfo_Player *> Server_Game::getGameState(Server_Player *playerWhosAs
|
|||
zoneList.append(new ServerInfo_Zone(zone->getName(), zone->getType(), zone->hasCoords(), zone->cards.size(), cardList));
|
||||
}
|
||||
|
||||
result.append(new ServerInfo_Player(player->getPlayerId(), player->getPlayerName(), player->getSpectator(), player->getDeck(), zoneList, counterList, arrowList));
|
||||
result.append(new ServerInfo_Player(player->getPlayerId(), player->getPlayerName(), player->getSpectator(), player->getConceded(), player == playerWhosAsking ? player->getDeck() : 0, zoneList, counterList, arrowList));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue