mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-22 10:22:15 -07:00
Move game option value declarations to dlg_create_game.
This commit is contained in:
parent
3b2421f695
commit
59b6fef512
10 changed files with 52 additions and 16 deletions
|
|
@ -38,6 +38,7 @@ message Command_CreateGame {
|
|||
repeated uint32 game_type_ids = 10;
|
||||
optional bool join_as_judge = 11;
|
||||
optional bool join_as_spectator = 12;
|
||||
optional uint32 starting_life_total = 13;
|
||||
}
|
||||
|
||||
message Command_JoinGame {
|
||||
|
|
|
|||
|
|
@ -61,14 +61,15 @@ Server_Game::Server_Game(const ServerInfo_User &_creatorInfo,
|
|||
bool _spectatorsNeedPassword,
|
||||
bool _spectatorsCanTalk,
|
||||
bool _spectatorsSeeEverything,
|
||||
int _startingLifeTotal,
|
||||
Server_Room *_room)
|
||||
: QObject(), room(_room), nextPlayerId(0), hostId(0), creatorInfo(new ServerInfo_User(_creatorInfo)),
|
||||
gameStarted(false), gameClosed(false), gameId(_gameId), password(_password), maxPlayers(_maxPlayers),
|
||||
gameTypes(_gameTypes), activePlayer(-1), activePhase(-1), onlyBuddies(_onlyBuddies),
|
||||
onlyRegistered(_onlyRegistered), spectatorsAllowed(_spectatorsAllowed),
|
||||
spectatorsNeedPassword(_spectatorsNeedPassword), spectatorsCanTalk(_spectatorsCanTalk),
|
||||
spectatorsSeeEverything(_spectatorsSeeEverything), inactivityCounter(0), startTimeOfThisGame(0),
|
||||
secondsElapsed(0), firstGameStarted(false), turnOrderReversed(false), startTime(QDateTime::currentDateTime()),
|
||||
spectatorsSeeEverything(_spectatorsSeeEverything), startingLifeTotal(_startingLifeTotal), inactivityCounter(0),
|
||||
startTimeOfThisGame(0), secondsElapsed(0), firstGameStarted(false), turnOrderReversed(false), startTime(QDateTime::currentDateTime()),
|
||||
pingClock(nullptr),
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
gameMutex()
|
||||
|
|
@ -323,7 +324,7 @@ void Server_Game::doStartGameIfReady()
|
|||
}
|
||||
for (Server_Player *player : players.values()) {
|
||||
if (!player->getSpectator())
|
||||
player->setupZones(room->getGameTypes());
|
||||
player->setupZones();
|
||||
}
|
||||
|
||||
gameStarted = true;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,7 @@ private:
|
|||
bool spectatorsNeedPassword;
|
||||
bool spectatorsCanTalk;
|
||||
bool spectatorsSeeEverything;
|
||||
int startingLifeTotal;
|
||||
int inactivityCounter;
|
||||
int startTimeOfThisGame, secondsElapsed;
|
||||
bool firstGameStarted;
|
||||
|
|
@ -105,6 +106,7 @@ public:
|
|||
bool _spectatorsNeedPassword,
|
||||
bool _spectatorsCanTalk,
|
||||
bool _spectatorsSeeEverything,
|
||||
int startingLifeTotal,
|
||||
Server_Room *parent);
|
||||
~Server_Game();
|
||||
Server_Room *getRoom() const
|
||||
|
|
@ -162,6 +164,10 @@ public:
|
|||
{
|
||||
return spectatorsSeeEverything;
|
||||
}
|
||||
int getStartingLifeTotal() const
|
||||
{
|
||||
return startingLifeTotal;
|
||||
}
|
||||
Response::ResponseCode
|
||||
checkJoin(ServerInfo_User *user, const QString &_password, bool spectator, bool overrideRestrictions, bool asJudge);
|
||||
bool containsUser(const QString &userName) const;
|
||||
|
|
|
|||
|
|
@ -162,7 +162,7 @@ int Server_Player::newArrowId() const
|
|||
return id + 1;
|
||||
}
|
||||
|
||||
void Server_Player::setupZones(const QStringList &gameTypes)
|
||||
void Server_Player::setupZones()
|
||||
{
|
||||
// This may need to be customized according to the game rules.
|
||||
// ------------------------------------------------------------------
|
||||
|
|
@ -178,11 +178,7 @@ void Server_Player::setupZones(const QStringList &gameTypes)
|
|||
addZone(new Server_CardZone(this, "grave", false, ServerInfo_Zone::PublicZone));
|
||||
addZone(new Server_CardZone(this, "rfg", false, ServerInfo_Zone::PublicZone));
|
||||
|
||||
if (gameTypes.contains(QString("Commander"))) {
|
||||
addCounter(new Server_Counter(0, "life", makeColor(255, 255, 255), 25, 40));
|
||||
} else {
|
||||
addCounter(new Server_Counter(0, "life", makeColor(255, 255, 255), 25, 20));
|
||||
}
|
||||
addCounter(new Server_Counter(0, "life", makeColor(255, 255, 255), 25, game->getStartingLifeTotal()));
|
||||
addCounter(new Server_Counter(1, "w", makeColor(255, 255, 150), 20, 0));
|
||||
addCounter(new Server_Counter(2, "u", makeColor(150, 150, 255), 20, 0));
|
||||
addCounter(new Server_Counter(3, "b", makeColor(150, 150, 150), 20, 0));
|
||||
|
|
@ -908,7 +904,7 @@ Server_Player::cmdUnconcede(const Command_Unconcede & /*cmd*/, ResponseContainer
|
|||
ges.enqueueGameEvent(event, playerId);
|
||||
ges.setGameEventContext(Context_Unconcede());
|
||||
|
||||
setupZones(game->getRoom()->getGameTypes());
|
||||
setupZones();
|
||||
|
||||
game->sendGameStateToPlayers();
|
||||
|
||||
|
|
|
|||
|
|
@ -169,7 +169,7 @@ public:
|
|||
void addCounter(Server_Counter *counter);
|
||||
|
||||
void clearZones();
|
||||
void setupZones(const QStringList &gameTypes);
|
||||
void setupZones();
|
||||
|
||||
Response::ResponseCode drawCards(GameEventStorage &ges, int number);
|
||||
Response::ResponseCode moveCard(GameEventStorage &ges,
|
||||
|
|
|
|||
|
|
@ -821,7 +821,7 @@ Server_ProtocolHandler::cmdCreateGame(const Command_CreateGame &cmd, Server_Room
|
|||
Server_Game *game = new Server_Game(
|
||||
copyUserInfo(false), gameId, description, QString::fromStdString(cmd.password()), cmd.max_players(), gameTypes,
|
||||
cmd.only_buddies(), onlyRegisteredUsers, cmd.spectators_allowed(), cmd.spectators_need_password(),
|
||||
cmd.spectators_can_talk(), cmd.spectators_see_everything(), room);
|
||||
cmd.spectators_can_talk(), cmd.spectators_see_everything(), cmd.starting_life_total(), room);
|
||||
|
||||
game->addPlayer(this, rc, asSpectator, asJudge, false);
|
||||
room->addGame(game);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue