mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
implemented game types
This commit is contained in:
parent
7116382a96
commit
04742f6fb9
23 changed files with 249 additions and 127 deletions
|
|
@ -3,8 +3,8 @@
|
|||
#include "server_game.h"
|
||||
#include <QDebug>
|
||||
|
||||
Server_Room::Server_Room(int _id, const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage, Server *parent)
|
||||
: QObject(parent), id(_id), name(_name), description(_description), autoJoin(_autoJoin), joinMessage(_joinMessage)
|
||||
Server_Room::Server_Room(int _id, const QString &_name, const QString &_description, bool _autoJoin, const QString &_joinMessage, const QStringList &_gameTypes, Server *parent)
|
||||
: QObject(parent), id(_id), name(_name), description(_description), autoJoin(_autoJoin), joinMessage(_joinMessage), gameTypes(_gameTypes)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -17,6 +17,7 @@ ServerInfo_Room *Server_Room::getInfo(bool complete) const
|
|||
{
|
||||
QList<ServerInfo_Game *> gameList;
|
||||
QList<ServerInfo_User *> userList;
|
||||
QList<ServerInfo_GameType *> gameTypeList;
|
||||
if (complete) {
|
||||
QMapIterator<int, Server_Game *> gameIterator(games);
|
||||
while (gameIterator.hasNext())
|
||||
|
|
@ -24,9 +25,12 @@ ServerInfo_Room *Server_Room::getInfo(bool complete) const
|
|||
|
||||
for (int i = 0; i < size(); ++i)
|
||||
userList.append(new ServerInfo_User(at(i)->getUserInfo(), false));
|
||||
|
||||
for (int i = 0; i < gameTypes.size(); ++i)
|
||||
gameTypeList.append(new ServerInfo_GameType(i, gameTypes[i]));
|
||||
}
|
||||
|
||||
return new ServerInfo_Room(id, name, description, games.size(), size(), autoJoin, gameList, userList);
|
||||
return new ServerInfo_Room(id, name, description, games.size(), size(), autoJoin, gameList, userList, gameTypeList);
|
||||
}
|
||||
|
||||
void Server_Room::addClient(Server_ProtocolHandler *client)
|
||||
|
|
@ -64,9 +68,9 @@ void Server_Room::broadcastGameListUpdate(Server_Game *game)
|
|||
delete event;
|
||||
}
|
||||
|
||||
Server_Game *Server_Room::createGame(const QString &description, const QString &password, int maxPlayers, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator)
|
||||
Server_Game *Server_Room::createGame(const QString &description, const QString &password, int maxPlayers, const QList<int> &gameTypes, bool spectatorsAllowed, bool spectatorsNeedPassword, bool spectatorsCanTalk, bool spectatorsSeeEverything, Server_ProtocolHandler *creator)
|
||||
{
|
||||
Server_Game *newGame = new Server_Game(creator, static_cast<Server *>(parent())->getNextGameId(), description, password, maxPlayers, spectatorsAllowed, spectatorsNeedPassword, spectatorsCanTalk, spectatorsSeeEverything, this);
|
||||
Server_Game *newGame = new Server_Game(creator, static_cast<Server *>(parent())->getNextGameId(), description, password, maxPlayers, gameTypes, spectatorsAllowed, spectatorsNeedPassword, spectatorsCanTalk, spectatorsSeeEverything, this);
|
||||
games.insert(newGame->getGameId(), newGame);
|
||||
connect(newGame, SIGNAL(gameClosing()), this, SLOT(removeGame()));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue