mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 18:13:55 -07:00
removed the need to refresh the game list
This commit is contained in:
parent
197bf0dc64
commit
c00027f988
21 changed files with 211 additions and 215 deletions
|
|
@ -42,24 +42,24 @@ void Card::resetState()
|
|||
|
||||
bool Card::setAttribute(const QString &aname, const QString &avalue, bool allCards)
|
||||
{
|
||||
if (!aname.compare("counters")) {
|
||||
if (aname == "counters") {
|
||||
bool ok;
|
||||
int tmp_int = avalue.toInt(&ok);
|
||||
if (!ok)
|
||||
return false;
|
||||
setCounters(tmp_int);
|
||||
} else if (!aname.compare("tapped")) {
|
||||
bool value = !avalue.compare("1");
|
||||
} else if (aname == "tapped") {
|
||||
bool value = avalue == "1";
|
||||
if (!(!value && allCards && doesntUntap))
|
||||
setTapped(value);
|
||||
} else if (!aname.compare("attacking")) {
|
||||
setAttacking(!avalue.compare("1"));
|
||||
} else if (!aname.compare("facedown")) {
|
||||
setFaceDown(!avalue.compare("1"));
|
||||
} else if (!aname.compare("annotation")) {
|
||||
} else if (aname == "attacking") {
|
||||
setAttacking(avalue == "1");
|
||||
} else if (aname == "facedown") {
|
||||
setFaceDown(avalue == "1");
|
||||
} else if (aname == "annotation") {
|
||||
setAnnotation(avalue);
|
||||
} else if (!aname.compare("doesnt_untap")) {
|
||||
setDoesntUntap(!avalue.compare("1"));
|
||||
} else if (aname == "doesnt_untap") {
|
||||
setDoesntUntap(avalue == "1");
|
||||
} else
|
||||
return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,16 +37,16 @@ public:
|
|||
Card(QString _name, int _id, int _coord_x, int _coord_y);
|
||||
~Card();
|
||||
|
||||
int getId() { return id; }
|
||||
int getX() { return coord_x; }
|
||||
int getY() { return coord_y; }
|
||||
QString getName() { return name; }
|
||||
int getCounters() { return counters; }
|
||||
bool getTapped() { return tapped; }
|
||||
bool getAttacking() { return attacking; }
|
||||
bool getFaceDown() { return facedown; }
|
||||
QString getAnnotation() { return annotation; }
|
||||
bool getDoesntUntap() { return doesntUntap; }
|
||||
int getId() const { return id; }
|
||||
int getX() const { return coord_x; }
|
||||
int getY() const { return coord_y; }
|
||||
QString getName() const { return name; }
|
||||
int getCounters() const { return counters; }
|
||||
bool getTapped() const { return tapped; }
|
||||
bool getAttacking() const { return attacking; }
|
||||
bool getFaceDown() const { return facedown; }
|
||||
QString getAnnotation() const { return annotation; }
|
||||
bool getDoesntUntap() const { return doesntUntap; }
|
||||
|
||||
void setId(int _id) { id = _id; }
|
||||
void setCoords(int x, int y) { coord_x = x; coord_y = y; }
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ protected:
|
|||
public:
|
||||
Counter(QString _name, int _color, int _count = 0) : name(_name), color(_color), count(_count) { }
|
||||
~Counter() { }
|
||||
int getCount() { return count; }
|
||||
int getCount() const { return count; }
|
||||
void setCount(int _count) { count = _count; }
|
||||
QString getName() const { return name; }
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,11 +1,6 @@
|
|||
#include "returnmessage.h"
|
||||
#include "serversocket.h"
|
||||
|
||||
void ReturnMessage::setMsgId(unsigned int _msg_id)
|
||||
{
|
||||
msg_id = _msg_id;
|
||||
}
|
||||
|
||||
bool ReturnMessage::send(ReturnCode code)
|
||||
{
|
||||
ServerSocket *s = qobject_cast<ServerSocket *>(parent());
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ public:
|
|||
enum ReturnCode { ReturnNothing, ReturnOk, ReturnLoginNeeded, ReturnSyntaxError, ReturnContextError, ReturnPasswordWrong, ReturnNameNotFound };
|
||||
ReturnMessage(QObject *parent = 0) : QObject(parent), msg_id(0) { }
|
||||
unsigned int getMsgId() const { return msg_id; }
|
||||
void setMsgId(unsigned int _msg_id);
|
||||
void setMsgId(unsigned int _msg_id) { msg_id = _msg_id; }
|
||||
void setCmd(const QString &_cmd) { cmd = _cmd; }
|
||||
bool send(ReturnCode code);
|
||||
bool sendList(const QStringList &args);
|
||||
|
|
|
|||
|
|
@ -71,10 +71,12 @@ bool Server::openDatabase()
|
|||
|
||||
void Server::addGame(const QString description, const QString password, const int maxPlayers, ServerSocket *creator)
|
||||
{
|
||||
ServerGame *newGame = new ServerGame(creator, nextGameId++, description, password, maxPlayers);
|
||||
ServerGame *newGame = new ServerGame(creator, nextGameId++, description, password, maxPlayers, this);
|
||||
games << newGame;
|
||||
connect(newGame, SIGNAL(gameClosing()), this, SLOT(gameClosing()));
|
||||
newGame->addPlayer(creator);
|
||||
|
||||
broadcastGameListUpdate(newGame);
|
||||
}
|
||||
|
||||
void Server::incomingConnection(int socketId)
|
||||
|
|
@ -83,7 +85,9 @@ void Server::incomingConnection(int socketId)
|
|||
socket->setSocketDescriptor(socketId);
|
||||
connect(socket, SIGNAL(createGame(const QString, const QString, const int, ServerSocket *)), this, SLOT(addGame(const QString, const QString, const int, ServerSocket *)));
|
||||
connect(socket, SIGNAL(joinGame(int, ServerSocket *)), this, SLOT(addClientToGame(int, ServerSocket *)));
|
||||
connect(socket, SIGNAL(destroyed(QObject *)), this, SLOT(socketDestroyed(QObject *)));
|
||||
socket->initConnection();
|
||||
players << socket;
|
||||
}
|
||||
|
||||
AuthenticationResult Server::checkUserPassword(const QString &user, const QString &password)
|
||||
|
|
@ -118,7 +122,7 @@ ServerGame *Server::getGame(int gameId)
|
|||
QListIterator<ServerGame *> i(games);
|
||||
while (i.hasNext()) {
|
||||
ServerGame *tmp = i.next();
|
||||
if ((tmp->gameId == gameId) && !tmp->getGameStarted())
|
||||
if ((tmp->getGameId() == gameId) && !tmp->getGameStarted())
|
||||
return tmp;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -131,7 +135,7 @@ QList<ServerGame *> Server::listOpenGames()
|
|||
while (i.hasNext()) {
|
||||
ServerGame *tmp = i.next();
|
||||
if ((!tmp->getGameStarted())
|
||||
&& (tmp->getPlayerCount() < tmp->maxPlayers))
|
||||
&& (tmp->getPlayerCount() < tmp->getMaxPlayers()))
|
||||
result.append(tmp);
|
||||
}
|
||||
return result;
|
||||
|
|
@ -141,23 +145,35 @@ bool Server::checkGamePassword(int gameId, const QString &password)
|
|||
{
|
||||
ServerGame *tmp;
|
||||
if ((tmp = getGame(gameId))) {
|
||||
if ((!tmp->getGameStarted())
|
||||
&& (!tmp->password.compare(password, Qt::CaseSensitive))
|
||||
&& (tmp->getPlayerCount() < tmp->maxPlayers))
|
||||
if ((!tmp->getGameStarted()) && (tmp->getPassword() == password) && (tmp->getPlayerCount() < tmp->getMaxPlayers()))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Server::broadcastGameListUpdate(ServerGame *game)
|
||||
{
|
||||
QString line = game->getGameListLine();
|
||||
for (int i = 0; i < players.size(); i++)
|
||||
if (players[i]->getAcceptsGameListChanges())
|
||||
players[i]->msg(line);
|
||||
}
|
||||
|
||||
void Server::addClientToGame(int gameId, ServerSocket *client)
|
||||
{
|
||||
ServerGame *tmp = getGame(gameId);
|
||||
tmp->addPlayer(client);
|
||||
ServerGame *game = getGame(gameId);
|
||||
game->addPlayer(client);
|
||||
broadcastGameListUpdate(game);
|
||||
}
|
||||
|
||||
void Server::gameClosing()
|
||||
{
|
||||
qDebug("Server::gameClosing");
|
||||
ServerGame *g = qobject_cast<ServerGame *>(sender());
|
||||
games.removeAt(games.indexOf(g));
|
||||
games.removeAt(games.indexOf(static_cast<ServerGame *>(sender())));
|
||||
}
|
||||
|
||||
void Server::socketDestroyed(QObject *obj)
|
||||
{
|
||||
players.removeAt(players.indexOf(static_cast<ServerSocket *>(obj)));
|
||||
qDebug(QString("Server::socketDestroyed: %1 players left").arg(players.size()).toLatin1());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ private slots:
|
|||
void addGame(const QString description, const QString password, const int maxPlayers, ServerSocket *creator);
|
||||
void addClientToGame(int gameId, ServerSocket *client);
|
||||
void gameClosing();
|
||||
void socketDestroyed(QObject *obj);
|
||||
public:
|
||||
Server(QObject *parent = 0);
|
||||
~Server();
|
||||
|
|
@ -47,9 +48,11 @@ public:
|
|||
QList<ServerGame *> listOpenGames();
|
||||
ServerGame *getGame(int gameId);
|
||||
AbstractRNG *getRNG() const { return rng; }
|
||||
void broadcastGameListUpdate(ServerGame *game);
|
||||
private:
|
||||
void incomingConnection(int SocketId);
|
||||
QList<ServerGame *> games;
|
||||
QList<ServerSocket *> players;
|
||||
int nextGameId;
|
||||
AbstractRNG *rng;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@
|
|||
* Free Software Foundation, Inc., *
|
||||
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
|
||||
***************************************************************************/
|
||||
#include "server.h"
|
||||
#include "servergame.h"
|
||||
#include "serversocket.h"
|
||||
#include <QSqlQuery>
|
||||
|
||||
ServerGame::ServerGame(ServerSocket *_creator, int _gameId, QString _description, QString _password, int _maxPlayers, QObject *parent)
|
||||
: QObject(parent), gameStarted(false), creator(_creator), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers)
|
||||
ServerGame::ServerGame(ServerSocket *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, QObject *parent)
|
||||
: QObject(parent), creator(_creator), gameStarted(false), gameId(_gameId), description(_description), password(_password), maxPlayers(_maxPlayers)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -32,23 +33,23 @@ ServerGame::~ServerGame()
|
|||
qDebug("ServerGame destructor");
|
||||
}
|
||||
|
||||
bool ServerGame::getGameStarted()
|
||||
QString ServerGame::getGameListLine() const
|
||||
{
|
||||
return gameStarted;
|
||||
return QString("list_games|%1|%2|%3|%4|%5|%6").arg(gameId)
|
||||
.arg(description)
|
||||
.arg(password.isEmpty() ? 0 : 1)
|
||||
.arg(players.size())
|
||||
.arg(maxPlayers)
|
||||
.arg(creator->getPlayerName());
|
||||
}
|
||||
|
||||
int ServerGame::getPlayerCount()
|
||||
{
|
||||
return players.size();
|
||||
}
|
||||
|
||||
QStringList ServerGame::getPlayerNames()
|
||||
QStringList ServerGame::getPlayerNames() const
|
||||
{
|
||||
QStringList result;
|
||||
QListIterator<ServerSocket *> i(players);
|
||||
while (i.hasNext()) {
|
||||
ServerSocket *tmp = i.next();
|
||||
result << QString("%1|%2").arg(tmp->getPlayerId()).arg(tmp->PlayerName);
|
||||
result << QString("%1|%2").arg(tmp->getPlayerId()).arg(tmp->getPlayerName());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
|
@ -74,7 +75,7 @@ void ServerGame::msg(const QString &s)
|
|||
void ServerGame::broadcastEvent(const QString &cmd, ServerSocket *player)
|
||||
{
|
||||
if (player)
|
||||
msg(QString("public|%1|%2|%3").arg(player->getPlayerId()).arg(player->PlayerName).arg(cmd));
|
||||
msg(QString("public|%1|%2|%3").arg(player->getPlayerId()).arg(player->getPlayerName()).arg(cmd));
|
||||
else
|
||||
msg(QString("public|||%1").arg(cmd));
|
||||
}
|
||||
|
|
@ -97,7 +98,7 @@ void ServerGame::startGameIfReady()
|
|||
for (int i = 0; i < players.size(); i++) {
|
||||
query.prepare("insert into games_players (id_game, player) values(:id, :player)");
|
||||
query.bindValue(":id", gameId);
|
||||
query.bindValue(":player", players.at(i)->PlayerName);
|
||||
query.bindValue(":player", players.at(i)->getPlayerName());
|
||||
query.exec();
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +123,7 @@ void ServerGame::addPlayer(ServerSocket *player)
|
|||
player->setPlayerId(max + 1);
|
||||
|
||||
player->setGame(this);
|
||||
player->msg(QString("private|||player_id|%1|%2").arg(max + 1).arg(player->PlayerName));
|
||||
player->msg(QString("private|||player_id|%1|%2").arg(max + 1).arg(player->getPlayerName()));
|
||||
broadcastEvent("join", player);
|
||||
|
||||
players << player;
|
||||
|
|
@ -136,6 +137,8 @@ void ServerGame::removePlayer(ServerSocket *player)
|
|||
broadcastEvent("leave", player);
|
||||
if (!players.size())
|
||||
deleteLater();
|
||||
if (!gameStarted)
|
||||
qobject_cast<Server *>(parent())->broadcastGameListUpdate(this);
|
||||
}
|
||||
|
||||
void ServerGame::setActivePlayer(int _activePlayer)
|
||||
|
|
|
|||
|
|
@ -27,32 +27,37 @@ class ServerSocket;
|
|||
class ServerGame : public QObject {
|
||||
Q_OBJECT
|
||||
private:
|
||||
ServerSocket *creator;
|
||||
QList<ServerSocket *> players;
|
||||
bool gameStarted;
|
||||
int activePlayer;
|
||||
int activePhase;
|
||||
int gameId;
|
||||
QString description;
|
||||
QString password;
|
||||
int maxPlayers;
|
||||
int activePlayer, activePhase;
|
||||
signals:
|
||||
void gameClosing();
|
||||
public slots:
|
||||
void broadcastEvent(const QString &event, ServerSocket *player);
|
||||
public:
|
||||
ServerSocket *creator;
|
||||
int gameId;
|
||||
QString description;
|
||||
QString password;
|
||||
int maxPlayers;
|
||||
ServerGame(ServerSocket *_creator, int _gameId, QString _description, QString _password, int _maxPlayers, QObject *parent = 0);
|
||||
ServerGame(ServerSocket *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, QObject *parent = 0);
|
||||
~ServerGame();
|
||||
bool getGameStarted();
|
||||
int getPlayerCount();
|
||||
QStringList getPlayerNames();
|
||||
ServerSocket *getCreator() const { return creator; }
|
||||
bool getGameStarted() const { return gameStarted; }
|
||||
int getPlayerCount() const { return players.size(); }
|
||||
int getGameId() const { return gameId; }
|
||||
QString getDescription() const { return description; }
|
||||
QString getPassword() const { return password; }
|
||||
int getMaxPlayers() const { return maxPlayers; }
|
||||
QString getGameListLine() const;
|
||||
QStringList getPlayerNames() const;
|
||||
ServerSocket *getPlayer(int player_id);
|
||||
void addPlayer(ServerSocket *player);
|
||||
void removePlayer(ServerSocket *player);
|
||||
void startGameIfReady();
|
||||
void msg(const QString &s);
|
||||
int getActivePlayer() { return activePlayer; }
|
||||
int getActivePhase() { return activePhase; }
|
||||
int getActivePlayer() const { return activePlayer; }
|
||||
int getActivePhase() const { return activePhase; }
|
||||
void setActivePlayer(int _activePlayer);
|
||||
void setActivePhase(int _activePhase);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -30,14 +30,13 @@
|
|||
#include "abstractrng.h"
|
||||
|
||||
ServerSocket::ServerSocket(Server *_server, QObject *parent)
|
||||
: QTcpSocket(parent), server(_server), game(0), authState(PasswordWrong)
|
||||
: QTcpSocket(parent), server(_server), game(0), PlayerStatus(StatusNormal), authState(PasswordWrong), acceptsGameListChanges(false)
|
||||
{
|
||||
remsg = new ReturnMessage(this);
|
||||
connect(this, SIGNAL(readyRead()), this, SLOT(readClient()));
|
||||
connect(this, SIGNAL(disconnected()), this, SLOT(deleteLater()));
|
||||
connect(this, SIGNAL(error(QAbstractSocket::SocketError)), this, SLOT(catchSocketError(QAbstractSocket::SocketError)));
|
||||
setTextModeEnabled(true);
|
||||
PlayerStatus = StatusNormal;
|
||||
}
|
||||
|
||||
ServerSocket::~ServerSocket()
|
||||
|
|
@ -52,29 +51,23 @@ int ServerSocket::newCardId()
|
|||
return nextCardId++;
|
||||
}
|
||||
|
||||
void ServerSocket::setName(const QString &name)
|
||||
{
|
||||
emit broadcastEvent(QString("name|%1|%2").arg(PlayerName).arg(name), this);
|
||||
PlayerName = name;
|
||||
}
|
||||
|
||||
PlayerZone *ServerSocket::getZone(const QString &name)
|
||||
PlayerZone *ServerSocket::getZone(const QString &name) const
|
||||
{
|
||||
QListIterator<PlayerZone *> ZoneIterator(zones);
|
||||
while (ZoneIterator.hasNext()) {
|
||||
PlayerZone *temp = ZoneIterator.next();
|
||||
if (!temp->getName().compare(name))
|
||||
if (temp->getName() == name)
|
||||
return temp;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Counter *ServerSocket::getCounter(const QString &name)
|
||||
Counter *ServerSocket::getCounter(const QString &name) const
|
||||
{
|
||||
QListIterator<Counter *> CounterIterator(counters);
|
||||
while (CounterIterator.hasNext()) {
|
||||
Counter *temp = CounterIterator.next();
|
||||
if (!temp->getName().compare(name))
|
||||
if (temp->getName() == name)
|
||||
return temp;
|
||||
}
|
||||
return NULL;
|
||||
|
|
@ -137,7 +130,6 @@ void ServerSocket::leaveGame()
|
|||
game = 0;
|
||||
PlayerStatus = StatusNormal;
|
||||
clearZones();
|
||||
moveToThread(server->thread());
|
||||
}
|
||||
|
||||
void ServerSocket::readClient()
|
||||
|
|
@ -156,7 +148,7 @@ void ServerSocket::readClient()
|
|||
break;
|
||||
case StatusSubmitDeck:
|
||||
QString card = line;
|
||||
if (!card.compare(".")) {
|
||||
if (card == ".") {
|
||||
PlayerStatus = StatusNormal;
|
||||
remsg->send(ReturnMessage::ReturnOk);
|
||||
} else if (card.startsWith("SB:"))
|
||||
|
|
@ -229,27 +221,19 @@ ReturnMessage::ReturnCode ServerSocket::cmdLogin(const QList<QVariant> ¶ms)
|
|||
authState = server->checkUserPassword(params[0].toString(), params[1].toString());
|
||||
if (authState == PasswordWrong)
|
||||
return ReturnMessage::ReturnPasswordWrong;
|
||||
PlayerName = params[0].toString();
|
||||
playerName = params[0].toString();
|
||||
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdListGames(const QList<QVariant> ¶ms)
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdListGames(const QList<QVariant> &/*params*/)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
QList<ServerGame *> gameList = server->listOpenGames();
|
||||
QListIterator<ServerGame *> gameListIterator(gameList);
|
||||
QStringList result;
|
||||
while (gameListIterator.hasNext()) {
|
||||
ServerGame *tmp = gameListIterator.next();
|
||||
result << QString("%1|%2|%3|%4|%5|%6").arg(tmp->gameId)
|
||||
.arg(tmp->description)
|
||||
.arg(tmp->password == "" ? 0 : 1)
|
||||
.arg(tmp->getPlayerCount())
|
||||
.arg(tmp->maxPlayers)
|
||||
.arg(tmp->creator->PlayerName);
|
||||
}
|
||||
remsg->sendList(result);
|
||||
while (gameListIterator.hasNext())
|
||||
msg(gameListIterator.next()->getGameListLine());
|
||||
|
||||
acceptsGameListChanges = true;
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
|
|
@ -260,6 +244,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdCreateGame(const QList<QVariant> &par
|
|||
int maxPlayers = params[2].toInt();
|
||||
leaveGame();
|
||||
emit createGame(description, password, maxPlayers, this);
|
||||
acceptsGameListChanges = false;
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
|
|
@ -271,19 +256,18 @@ ReturnMessage::ReturnCode ServerSocket::cmdJoinGame(const QList<QVariant> ¶m
|
|||
return ReturnMessage::ReturnPasswordWrong;
|
||||
leaveGame();
|
||||
emit joinGame(gameId, this);
|
||||
acceptsGameListChanges = false;
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdLeaveGame(const QList<QVariant> ¶ms)
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdLeaveGame(const QList<QVariant> &/*params*/)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
leaveGame();
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdListPlayers(const QList<QVariant> ¶ms)
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdListPlayers(const QList<QVariant> &/*params*/)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
remsg->sendList(game->getPlayerNames());
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
|
@ -294,27 +278,24 @@ ReturnMessage::ReturnCode ServerSocket::cmdSay(const QList<QVariant> ¶ms)
|
|||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdSubmitDeck(const QList<QVariant> ¶ms)
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdSubmitDeck(const QList<QVariant> &/*params*/)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
PlayerStatus = StatusSubmitDeck;
|
||||
DeckList.clear();
|
||||
SideboardList.clear();
|
||||
return ReturnMessage::ReturnNothing;
|
||||
}
|
||||
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdReadyStart(const QList<QVariant> ¶ms)
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdReadyStart(const QList<QVariant> &/*params*/)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
PlayerStatus = StatusReadyStart;
|
||||
emit broadcastEvent(QString("ready_start"), this);
|
||||
game->startGameIfReady();
|
||||
return ReturnMessage::ReturnOk;
|
||||
}
|
||||
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdShuffle(const QList<QVariant> ¶ms)
|
||||
ReturnMessage::ReturnCode ServerSocket::cmdShuffle(const QList<QVariant> &/*params*/)
|
||||
{
|
||||
Q_UNUSED(params);
|
||||
getZone("deck")->shuffle(server->getRNG());
|
||||
emit broadcastEvent("shuffle", this);
|
||||
return ReturnMessage::ReturnOk;
|
||||
|
|
@ -545,7 +526,7 @@ ReturnMessage::ReturnCode ServerSocket::cmdDumpZone(const QList<QVariant> ¶m
|
|||
PlayerZone *zone = player->getZone(params[1].toString());
|
||||
if (!zone)
|
||||
return ReturnMessage::ReturnContextError;
|
||||
if (!(zone->isPublic() || (player_id == PlayerId)))
|
||||
if (!(zone->isPublic() || (player_id == playerId)))
|
||||
return ReturnMessage::ReturnContextError;
|
||||
|
||||
QListIterator<Card *> card_iterator(zone->cards);
|
||||
|
|
|
|||
|
|
@ -91,20 +91,20 @@ private:
|
|||
QList<QString> SideboardList;
|
||||
QList<PlayerZone *> zones;
|
||||
QList<Counter *> counters;
|
||||
int PlayerId;
|
||||
int playerId;
|
||||
QString playerName;
|
||||
int nextCardId;
|
||||
int newCardId();
|
||||
PlayerZone *getZone(const QString &name);
|
||||
Counter *getCounter(const QString &name);
|
||||
void setName(const QString &name);
|
||||
PlayerZone *getZone(const QString &name) const;
|
||||
Counter *getCounter(const QString &name) const;
|
||||
void clearZones();
|
||||
void leaveGame();
|
||||
bool parseCommand(QString line);
|
||||
PlayerStatusEnum PlayerStatus;
|
||||
ReturnMessage *remsg;
|
||||
AuthenticationResult authState;
|
||||
bool acceptsGameListChanges;
|
||||
public:
|
||||
QString PlayerName;
|
||||
ServerSocket(Server *_server, QObject *parent = 0);
|
||||
~ServerSocket();
|
||||
void msg(const QString &s);
|
||||
|
|
@ -112,8 +112,10 @@ public:
|
|||
PlayerStatusEnum getStatus();
|
||||
void setStatus(PlayerStatusEnum status);
|
||||
void initConnection();
|
||||
int getPlayerId() { return PlayerId; }
|
||||
void setPlayerId(int _id) { PlayerId = _id; }
|
||||
int getPlayerId() const { return playerId; }
|
||||
void setPlayerId(int _id) { playerId = _id; }
|
||||
QString getPlayerName() const { return playerName; }
|
||||
bool getAcceptsGameListChanges() const { return acceptsGameListChanges; }
|
||||
QStringList listCounters();
|
||||
QStringList listZones();
|
||||
void setupZones();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue