mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-12 09:04:53 -07:00
new code
This commit is contained in:
parent
6c93b1e9b7
commit
0d4717f40b
28 changed files with 591 additions and 375 deletions
|
|
@ -76,6 +76,7 @@ void ProtocolItem::initializeHash()
|
|||
|
||||
itemNameHash.insert("generic_eventlist_games", Event_ListGames::newItem);
|
||||
itemNameHash.insert("generic_eventlist_chat_channels", Event_ListChatChannels::newItem);
|
||||
itemNameHash.insert("generic_eventgame_joined", Event_GameJoined::newItem);
|
||||
itemNameHash.insert("chat_eventchat_list_players", Event_ChatListPlayers::newItem);
|
||||
}
|
||||
|
||||
|
|
@ -210,57 +211,6 @@ void ProtocolResponse::initializeHash()
|
|||
responseHash.insert("spectators_not_allowed", RespSpectatorsNotAllowed);
|
||||
}
|
||||
|
||||
bool DeckList_File::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isEndElement())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeckList_File::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("file");
|
||||
xml->writeAttribute("name", name);
|
||||
xml->writeAttribute("id", QString::number(id));
|
||||
xml->writeAttribute("upload_time", QString::number(uploadTime.toTime_t()));
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
DeckList_Directory::~DeckList_Directory()
|
||||
{
|
||||
for (int i = 0; i < size(); ++i)
|
||||
delete at(i);
|
||||
}
|
||||
|
||||
bool DeckList_Directory::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (currentItem) {
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return false;
|
||||
}
|
||||
if (xml->isStartElement() && (xml->name() == "directory")) {
|
||||
currentItem = new DeckList_Directory(xml->attributes().value("name").toString());
|
||||
append(currentItem);
|
||||
} else if (xml->isStartElement() && (xml->name() == "file")) {
|
||||
currentItem = new DeckList_File(xml->attributes().value("name").toString(), xml->attributes().value("id").toString().toInt(), QDateTime::fromTime_t(xml->attributes().value("upload_time").toString().toUInt()));
|
||||
append(currentItem);
|
||||
} else if (xml->isEndElement() && (xml->name() == "directory"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeckList_Directory::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("directory");
|
||||
xml->writeAttribute("name", name);
|
||||
for (int i = 0; i < size(); ++i)
|
||||
at(i)->writeElement(xml);
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
Response_DeckList::Response_DeckList(int _cmdId, ResponseCode _responseCode, DeckList_Directory *_root)
|
||||
: ProtocolResponse(_cmdId, _responseCode, "deck_list"), root(_root), readFinished(false)
|
||||
{
|
||||
|
|
@ -420,7 +370,7 @@ void Event_ListChatChannels::writeElement(QXmlStreamWriter *xml)
|
|||
bool Event_ChatListPlayers::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isStartElement() && ((xml->name() == "player"))) {
|
||||
playerList.append(ServerPlayerInfo(
|
||||
playerList.append(ServerChatUserInfo(
|
||||
xml->attributes().value("name").toString()
|
||||
));
|
||||
return true;
|
||||
|
|
@ -470,3 +420,50 @@ void Event_ListGames::writeElement(QXmlStreamWriter *xml)
|
|||
xml->writeEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
Event_GameJoined::Event_GameJoined(int _gameId, int _playerId, bool _spectator, const QList<ServerInfo_Player *> &_playerList)
|
||||
: GenericEvent("game_joined"), currentItem(0), readFinished(false), gameId(_gameId), playerId(_playerId), spectator(_spectator), playerList(_playerList)
|
||||
{
|
||||
setParameter("game_id", gameId);
|
||||
setParameter("player_id", playerId);
|
||||
setParameter("spectator", spectator);
|
||||
}
|
||||
|
||||
Event_GameJoined::~Event_GameJoined()
|
||||
{
|
||||
for (int i = 0; i < playerList.size(); ++i)
|
||||
delete playerList[i];
|
||||
}
|
||||
|
||||
void Event_GameJoined::extractParameters()
|
||||
{
|
||||
GenericEvent::extractParameters();
|
||||
gameId = parameters["game_id"].toInt();
|
||||
playerId = parameters["player_id"].toInt();
|
||||
spectator = (parameters["spectator"] == "1");
|
||||
}
|
||||
|
||||
bool Event_GameJoined::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (currentItem) {
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return true;
|
||||
}
|
||||
if (xml->isStartElement() && (xml->name() == "player")) {
|
||||
ServerInfo_Player *player = new ServerInfo_Player;
|
||||
playerList.append(player);
|
||||
currentItem = player;
|
||||
} else
|
||||
return false;
|
||||
if (currentItem)
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Event_GameJoined::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
for (int i = 0; i < playerList.size(); ++i)
|
||||
playerList[i]->writeElement(xml);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ enum ItemId {
|
|||
ItemId_Event_ListChatChannels = ItemId_Other + 200,
|
||||
ItemId_Event_ChatListPlayers = ItemId_Other + 201,
|
||||
ItemId_Event_ListGames = ItemId_Other + 202,
|
||||
ItemId_Event_GameJoined = ItemId_Other + 203,
|
||||
ItemId_Response_DeckList = ItemId_Other + 300,
|
||||
ItemId_Response_DeckDownload = ItemId_Other + 301,
|
||||
ItemId_Response_DeckUpload = ItemId_Other + 302
|
||||
|
|
@ -297,16 +298,16 @@ public:
|
|||
class Event_ChatListPlayers : public ChatEvent {
|
||||
Q_OBJECT
|
||||
private:
|
||||
QList<ServerPlayerInfo> playerList;
|
||||
QList<ServerChatUserInfo> playerList;
|
||||
public:
|
||||
Event_ChatListPlayers(const QString &_channel = QString()) : ChatEvent("chat_list_players", _channel) { }
|
||||
int getItemId() const { return ItemId_Event_ChatListPlayers; }
|
||||
static ProtocolItem *newItem() { return new Event_ChatListPlayers; }
|
||||
void addPlayer(const QString &_name)
|
||||
{
|
||||
playerList.append(ServerPlayerInfo(_name));
|
||||
playerList.append(ServerChatUserInfo(_name));
|
||||
}
|
||||
const QList<ServerPlayerInfo> &getPlayerList() const { return playerList; }
|
||||
const QList<ServerChatUserInfo> &getPlayerList() const { return playerList; }
|
||||
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
|
|
@ -330,4 +331,29 @@ public:
|
|||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
class Event_GameJoined : public GenericEvent {
|
||||
Q_OBJECT
|
||||
private:
|
||||
SerializableItem *currentItem;
|
||||
bool readFinished;
|
||||
int gameId;
|
||||
int playerId;
|
||||
bool spectator;
|
||||
QList<ServerInfo_Player *> playerList;
|
||||
protected:
|
||||
void extractParameters();
|
||||
public:
|
||||
Event_GameJoined(int _gameId = -1, int _playerId = -1, bool _spectator = false, const QList<ServerInfo_Player *> &_playerList = QList<ServerInfo_Player *>());
|
||||
~Event_GameJoined();
|
||||
int getGameId() const { return gameId; }
|
||||
int getPlayerId() const { return playerId; }
|
||||
bool getSpectator() const { return spectator; }
|
||||
const QList<ServerInfo_Player *> &getPlayerList() const { return playerList; }
|
||||
static ProtocolItem *newItem() { return new Event_GameJoined; }
|
||||
int getItemId() const { return ItemId_Event_GameJoined; }
|
||||
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
257
common/protocol_datastructures.cpp
Normal file
257
common/protocol_datastructures.cpp
Normal file
|
|
@ -0,0 +1,257 @@
|
|||
#include "protocol_datastructures.h"
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
class ColorConverter {
|
||||
public:
|
||||
static int colorToInt(const QColor &color)
|
||||
{
|
||||
return color.red() * 65536 + color.green() * 256 + color.blue();
|
||||
}
|
||||
static QColor colorFromInt(int colorValue)
|
||||
{
|
||||
return QColor(colorValue / 65536, (colorValue % 65536) / 256, colorValue % 256);
|
||||
}
|
||||
};
|
||||
|
||||
ServerInfo_Player::~ServerInfo_Player()
|
||||
{
|
||||
for (int i = 0; i < zoneList.size(); ++i)
|
||||
delete zoneList[i];
|
||||
for (int i = 0; i < arrowList.size(); ++i)
|
||||
delete arrowList[i];
|
||||
for (int i = 0; i < counterList.size(); ++i)
|
||||
delete counterList[i];
|
||||
}
|
||||
|
||||
ServerInfo_Zone::~ServerInfo_Zone()
|
||||
{
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
delete cardList[i];
|
||||
}
|
||||
|
||||
bool ServerInfo_Arrow::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isStartElement() && (xml->name() == "arrow")) {
|
||||
id = xml->attributes().value("id").toString().toInt();
|
||||
startPlayerId = xml->attributes().value("start_player_id").toString().toInt();
|
||||
startZone = xml->attributes().value("start_zone").toString();
|
||||
startCardId = xml->attributes().value("start_card_id").toString().toInt();
|
||||
targetPlayerId = xml->attributes().value("target_player_id").toString().toInt();
|
||||
targetZone = xml->attributes().value("target_zone").toString();
|
||||
targetCardId = xml->attributes().value("target_card_id").toString().toInt();
|
||||
color = ColorConverter::colorFromInt(xml->attributes().value("color").toString().toInt());
|
||||
} else if (xml->isEndElement() && (xml->name() == "arrow"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerInfo_Arrow::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("arrow");
|
||||
xml->writeAttribute("id", QString::number(id));
|
||||
xml->writeAttribute("start_player_id", QString::number(startPlayerId));
|
||||
xml->writeAttribute("start_zone", startZone);
|
||||
xml->writeAttribute("start_card_id", QString::number(startCardId));
|
||||
xml->writeAttribute("target_player_id", QString::number(targetPlayerId));
|
||||
xml->writeAttribute("target_zone", targetZone);
|
||||
xml->writeAttribute("target_card_id", QString::number(targetCardId));
|
||||
xml->writeAttribute("color", QString::number(ColorConverter::colorToInt(color)));
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
bool ServerInfo_Counter::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isStartElement() && (xml->name() == "counter")) {
|
||||
id = xml->attributes().value("id").toString().toInt();
|
||||
name = xml->attributes().value("name").toString();
|
||||
color = ColorConverter::colorFromInt(xml->attributes().value("color").toString().toInt());
|
||||
radius = xml->attributes().value("radius").toString().toInt();
|
||||
count = xml->attributes().value("count").toString().toInt();
|
||||
} else if (xml->isEndElement() && (xml->name() == "counter"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerInfo_Counter::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("counter");
|
||||
xml->writeAttribute("id", QString::number(id));
|
||||
xml->writeAttribute("name", name);
|
||||
xml->writeAttribute("color", QString::number(ColorConverter::colorToInt(color)));
|
||||
xml->writeAttribute("radius", QString::number(radius));
|
||||
xml->writeAttribute("count", QString::number(count));
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
bool ServerInfo_Card::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isStartElement() && (xml->name() == "card")) {
|
||||
id = xml->attributes().value("id").toString().toInt();
|
||||
name = xml->attributes().value("name").toString();
|
||||
x = xml->attributes().value("x").toString().toInt();
|
||||
y = xml->attributes().value("y").toString().toInt();
|
||||
counters = xml->attributes().value("counters").toString().toInt();
|
||||
tapped = xml->attributes().value("tapped").toString().toInt();
|
||||
attacking = xml->attributes().value("attacking").toString().toInt();
|
||||
annotation = xml->attributes().value("annotation").toString();
|
||||
} else if (xml->isEndElement() && (xml->name() == "card"))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerInfo_Card::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("card");
|
||||
xml->writeAttribute("id", QString::number(id));
|
||||
xml->writeAttribute("name", name);
|
||||
xml->writeAttribute("x", QString::number(x));
|
||||
xml->writeAttribute("y", QString::number(y));
|
||||
xml->writeAttribute("counters", QString::number(counters));
|
||||
xml->writeAttribute("tapped", tapped ? "1" : "0");
|
||||
xml->writeAttribute("attacking", attacking ? "1" : "0");
|
||||
xml->writeAttribute("annotation", annotation);
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
bool ServerInfo_Zone::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (currentItem) {
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return false;
|
||||
}
|
||||
if (xml->isStartElement() && (xml->name() == "zone")) {
|
||||
name = xml->attributes().value("name").toString();
|
||||
type = (ZoneType) xml->attributes().value("type").toString().toInt();
|
||||
hasCoords = xml->attributes().value("has_coords").toString().toInt();
|
||||
cardCount = xml->attributes().value("card_count").toString().toInt();
|
||||
} else if (xml->isStartElement() && (xml->name() == "card")) {
|
||||
ServerInfo_Card *card = new ServerInfo_Card;
|
||||
cardList.append(card);
|
||||
currentItem = card;
|
||||
} else if (xml->isEndElement() && (xml->name() == "zone"))
|
||||
return true;
|
||||
|
||||
if (currentItem)
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
void ServerInfo_Zone::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("zone");
|
||||
xml->writeAttribute("name", name);
|
||||
QString typeStr;
|
||||
switch (type) {
|
||||
case PrivateZone: typeStr = "private"; break;
|
||||
case HiddenZone: typeStr = "hidden"; break;
|
||||
case PublicZone: typeStr = "public"; break;
|
||||
}
|
||||
xml->writeAttribute("type", typeStr);
|
||||
xml->writeAttribute("has_coords", hasCoords ? "1" : "0");
|
||||
xml->writeAttribute("card_count", QString::number(cardCount));
|
||||
for (int i = 0; i < cardList.size(); ++i)
|
||||
cardList[i]->writeElement(xml);
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
bool ServerInfo_Player::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (currentItem) {
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return false;
|
||||
}
|
||||
if (xml->isStartElement() && (xml->name() == "player")) {
|
||||
playerId = xml->attributes().value("player_id").toString().toInt();
|
||||
name = xml->attributes().value("name").toString();
|
||||
} else if (xml->isStartElement() && (xml->name() == "zone")) {
|
||||
ServerInfo_Zone *zone = new ServerInfo_Zone;
|
||||
zoneList.append(zone);
|
||||
currentItem = zone;
|
||||
} else if (xml->isStartElement() && (xml->name() == "counter")) {
|
||||
ServerInfo_Counter *counter = new ServerInfo_Counter;
|
||||
counterList.append(counter);
|
||||
currentItem = counter;
|
||||
} else if (xml->isStartElement() && (xml->name() == "arrow")) {
|
||||
ServerInfo_Arrow *arrow = new ServerInfo_Arrow;
|
||||
arrowList.append(arrow);
|
||||
currentItem = arrow;
|
||||
} else if (xml->isEndElement() && (xml->name() == "player"))
|
||||
return true;
|
||||
|
||||
if (currentItem)
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return false;
|
||||
}
|
||||
|
||||
void ServerInfo_Player::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("player");
|
||||
xml->writeAttribute("player_id", QString::number(playerId));
|
||||
xml->writeAttribute("name", name);
|
||||
for (int i = 0; i < zoneList.size(); ++i)
|
||||
zoneList[i]->writeElement(xml);
|
||||
for (int i = 0; i < counterList.size(); ++i)
|
||||
counterList[i]->writeElement(xml);
|
||||
for (int i = 0; i < arrowList.size(); ++i)
|
||||
arrowList[i]->writeElement(xml);
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
bool DeckList_File::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (xml->isEndElement())
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeckList_File::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("file");
|
||||
xml->writeAttribute("name", name);
|
||||
xml->writeAttribute("id", QString::number(id));
|
||||
xml->writeAttribute("upload_time", QString::number(uploadTime.toTime_t()));
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
||||
DeckList_Directory::~DeckList_Directory()
|
||||
{
|
||||
for (int i = 0; i < size(); ++i)
|
||||
delete at(i);
|
||||
}
|
||||
|
||||
bool DeckList_Directory::readElement(QXmlStreamReader *xml)
|
||||
{
|
||||
if (currentItem) {
|
||||
if (currentItem->readElement(xml))
|
||||
currentItem = 0;
|
||||
return false;
|
||||
}
|
||||
if (xml->isStartElement() && (xml->name() == "directory")) {
|
||||
DeckList_Directory *newItem = new DeckList_Directory(xml->attributes().value("name").toString());
|
||||
append(newItem);
|
||||
currentItem = newItem;
|
||||
} else if (xml->isStartElement() && (xml->name() == "file")) {
|
||||
DeckList_File *newItem = new DeckList_File(xml->attributes().value("name").toString(), xml->attributes().value("id").toString().toInt(), QDateTime::fromTime_t(xml->attributes().value("upload_time").toString().toUInt()));
|
||||
append(newItem);
|
||||
currentItem = newItem;
|
||||
} else if (xml->isEndElement() && (xml->name() == "directory"))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void DeckList_Directory::writeElement(QXmlStreamWriter *xml)
|
||||
{
|
||||
xml->writeStartElement("directory");
|
||||
xml->writeAttribute("name", name);
|
||||
for (int i = 0; i < size(); ++i)
|
||||
at(i)->writeElement(xml);
|
||||
xml->writeEndElement();
|
||||
}
|
||||
|
|
@ -10,6 +10,25 @@ class QXmlStreamWriter;
|
|||
|
||||
enum ResponseCode { RespNothing, RespOk, RespInvalidCommand, RespInvalidData, RespNameNotFound, RespLoginNeeded, RespContextError, RespWrongPassword, RespSpectatorsNotAllowed };
|
||||
|
||||
// PrivateZone: Contents of the zone are always visible to the owner,
|
||||
// but not to anyone else.
|
||||
// PublicZone: Contents of the zone are always visible to anyone.
|
||||
// HiddenZone: Contents of the zone are never visible to anyone.
|
||||
// However, the owner of the zone can issue a dump_zone command,
|
||||
// setting beingLookedAt to true.
|
||||
// Cards in a zone with the type HiddenZone are referenced by their
|
||||
// list index, whereas cards in any other zone are referenced by their ids.
|
||||
enum ZoneType { PrivateZone, PublicZone, HiddenZone };
|
||||
|
||||
class SerializableItem {
|
||||
protected:
|
||||
SerializableItem *currentItem;
|
||||
public:
|
||||
SerializableItem() : currentItem(0) { }
|
||||
virtual bool readElement(QXmlStreamReader *xml) = 0;
|
||||
virtual void writeElement(QXmlStreamWriter *xml) = 0;
|
||||
};
|
||||
|
||||
class ServerChatChannelInfo {
|
||||
private:
|
||||
QString name;
|
||||
|
|
@ -25,11 +44,11 @@ public:
|
|||
bool getAutoJoin() const { return autoJoin; }
|
||||
};
|
||||
|
||||
class ServerPlayerInfo {
|
||||
class ServerChatUserInfo {
|
||||
private:
|
||||
QString name;
|
||||
public:
|
||||
ServerPlayerInfo(const QString &_name)
|
||||
ServerChatUserInfo(const QString &_name)
|
||||
: name(_name) { }
|
||||
QString getName() const { return name; }
|
||||
};
|
||||
|
|
@ -57,23 +76,8 @@ public:
|
|||
int getSpectatorCount() const { return spectatorCount; }
|
||||
};
|
||||
|
||||
class ServerPlayer {
|
||||
class ServerInfo_Card : public SerializableItem {
|
||||
private:
|
||||
int PlayerId;
|
||||
QString name;
|
||||
bool local;
|
||||
public:
|
||||
ServerPlayer(int _PlayerId, const QString &_name, bool _local)
|
||||
: PlayerId(_PlayerId), name(_name), local(_local) { }
|
||||
int getPlayerId() const { return PlayerId; }
|
||||
QString getName() const { return name; }
|
||||
bool getLocal() const { return local; }
|
||||
};
|
||||
|
||||
class ServerZoneCard {
|
||||
private:
|
||||
int playerId;
|
||||
QString zoneName;
|
||||
int id;
|
||||
QString name;
|
||||
int x, y;
|
||||
|
|
@ -82,10 +86,8 @@ private:
|
|||
bool attacking;
|
||||
QString annotation;
|
||||
public:
|
||||
ServerZoneCard(int _playerId, const QString &_zoneName, int _id, const QString &_name, int _x, int _y, int _counters, bool _tapped, bool _attacking, const QString &_annotation)
|
||||
: playerId(_playerId), zoneName(_zoneName), id(_id), name(_name), x(_x), y(_y), counters(_counters), tapped(_tapped), attacking(_attacking), annotation(_annotation) { }
|
||||
int getPlayerId() const { return playerId; }
|
||||
QString getZoneName() const { return zoneName; }
|
||||
ServerInfo_Card(int _id = -1, const QString &_name = QString(), int _x = -1, int _y = -1, int _counters = -1, bool _tapped = false, bool _attacking = false, const QString &_annotation = QString())
|
||||
: id(_id), name(_name), x(_x), y(_y), counters(_counters), tapped(_tapped), attacking(_attacking), annotation(_annotation) { }
|
||||
int getId() const { return id; }
|
||||
QString getName() const { return name; }
|
||||
int getX() const { return x; }
|
||||
|
|
@ -94,50 +96,53 @@ public:
|
|||
bool getTapped() const { return tapped; }
|
||||
bool getAttacking() const { return attacking; }
|
||||
QString getAnnotation() const { return annotation; }
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
class ServerZone {
|
||||
public:
|
||||
enum ZoneType { PrivateZone, PublicZone, HiddenZone };
|
||||
class ServerInfo_Zone : public SerializableItem {
|
||||
private:
|
||||
int playerId;
|
||||
QString name;
|
||||
ZoneType type;
|
||||
bool hasCoords;
|
||||
int cardCount;
|
||||
QList<ServerInfo_Card *> cardList;
|
||||
public:
|
||||
ServerZone(int _playerId, const QString &_name, ZoneType _type, bool _hasCoords, int _cardCount)
|
||||
: playerId(_playerId), name(_name), type(_type), hasCoords(_hasCoords), cardCount(_cardCount) { }
|
||||
int getPlayerId() const { return playerId; }
|
||||
ServerInfo_Zone(const QString &_name = QString(), ZoneType _type = PrivateZone, bool _hasCoords = false, int _cardCount = -1, const QList<ServerInfo_Card *> &_cardList = QList<ServerInfo_Card *>())
|
||||
: name(_name), type(_type), hasCoords(_hasCoords), cardCount(_cardCount), cardList(_cardList) { }
|
||||
~ServerInfo_Zone();
|
||||
QString getName() const { return name; }
|
||||
ZoneType getType() const { return type; }
|
||||
bool getHasCoords() const { return hasCoords; }
|
||||
int getCardCount() const { return cardCount; }
|
||||
const QList<ServerInfo_Card *> &getCardList() const { return cardList; }
|
||||
void addCard(ServerInfo_Card *card) { cardList.append(card); ++cardCount; }
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
class ServerCounter {
|
||||
class ServerInfo_Counter : public SerializableItem {
|
||||
private:
|
||||
int playerId;
|
||||
int id;
|
||||
QString name;
|
||||
QColor color;
|
||||
int radius;
|
||||
int count;
|
||||
public:
|
||||
ServerCounter(int _playerId, int _id, const QString &_name, QColor _color, int _radius, int _count)
|
||||
: playerId(_playerId), id(_id), name(_name), color(_color), radius(_radius), count(_count) { }
|
||||
int getPlayerId() const { return playerId; }
|
||||
ServerInfo_Counter(int _id = -1, const QString &_name = QString(), const QColor &_color = QColor(), int _radius = -1, int _count = -1)
|
||||
: id(_id), name(_name), color(_color), radius(_radius), count(_count) { }
|
||||
int getId() const { return id; }
|
||||
QString getName() const { return name; }
|
||||
QColor getColor() const { return color; }
|
||||
int getRadius() const { return radius; }
|
||||
int getCount() const { return count; }
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
class ServerArrow {
|
||||
class ServerInfo_Arrow : public SerializableItem {
|
||||
private:
|
||||
int id;
|
||||
int playerId;
|
||||
int startPlayerId;
|
||||
QString startZone;
|
||||
int startCardId;
|
||||
|
|
@ -146,10 +151,9 @@ private:
|
|||
int targetCardId;
|
||||
QColor color;
|
||||
public:
|
||||
ServerArrow(int _playerId, int _id, int _startPlayerId, const QString &_startZone, int _startCardId, int _targetPlayerId, const QString &_targetZone, int _targetCardId, const QColor &_color)
|
||||
: id(_id), playerId(_playerId), startPlayerId(_startPlayerId), startZone(_startZone), startCardId(_startCardId), targetPlayerId(_targetPlayerId), targetZone(_targetZone), targetCardId(_targetCardId), color(_color) { }
|
||||
ServerInfo_Arrow(int _id = -1, int _startPlayerId = -1, const QString &_startZone = QString(), int _startCardId = -1, int _targetPlayerId = -1, const QString &_targetZone = QString(), int _targetCardId = -1, const QColor &_color = QColor())
|
||||
: id(_id), startPlayerId(_startPlayerId), startZone(_startZone), startCardId(_startCardId), targetPlayerId(_targetPlayerId), targetZone(_targetZone), targetCardId(_targetCardId), color(_color) { }
|
||||
int getId() const { return id; }
|
||||
int getPlayerId() const { return playerId; }
|
||||
int getStartPlayerId() const { return startPlayerId; }
|
||||
QString getStartZone() const { return startZone; }
|
||||
int getStartCardId() const { return startCardId; }
|
||||
|
|
@ -157,9 +161,34 @@ public:
|
|||
QString getTargetZone() const { return targetZone; }
|
||||
int getTargetCardId() const { return targetCardId; }
|
||||
QColor getColor() const { return color; }
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
class DeckList_TreeItem {
|
||||
class ServerInfo_Player : public SerializableItem {
|
||||
private:
|
||||
int playerId;
|
||||
QString name;
|
||||
QList<ServerInfo_Zone *> zoneList;
|
||||
QList<ServerInfo_Counter *> counterList;
|
||||
QList<ServerInfo_Arrow *> arrowList;
|
||||
public:
|
||||
ServerInfo_Player(int _playerId = -1, const QString &_name = QString(), const QList<ServerInfo_Zone *> &_zoneList = QList<ServerInfo_Zone *>(), const QList<ServerInfo_Counter *> &_counterList = QList<ServerInfo_Counter *>(), const QList<ServerInfo_Arrow *> &_arrowList = QList<ServerInfo_Arrow *>())
|
||||
: playerId(_playerId), name(_name), zoneList(_zoneList), counterList(_counterList), arrowList(_arrowList) { }
|
||||
~ServerInfo_Player();
|
||||
int getPlayerId() const { return playerId; }
|
||||
QString getName() const { return name; }
|
||||
const QList<ServerInfo_Zone *> &getZoneList() const { return zoneList; }
|
||||
const QList<ServerInfo_Counter *> &getCounterList() const { return counterList; }
|
||||
const QList<ServerInfo_Arrow *> &getArrowList() const { return arrowList; }
|
||||
void addZone(ServerInfo_Zone *zone) { zoneList.append(zone); }
|
||||
void addCounter(ServerInfo_Counter *counter) { counterList.append(counter); }
|
||||
void addArrow(ServerInfo_Arrow *arrow) { arrowList.append(arrow); }
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
};
|
||||
|
||||
class DeckList_TreeItem : public SerializableItem {
|
||||
protected:
|
||||
QString name;
|
||||
int id;
|
||||
|
|
@ -167,8 +196,6 @@ public:
|
|||
DeckList_TreeItem(const QString &_name, int _id) : name(_name), id(_id) { }
|
||||
QString getName() const { return name; }
|
||||
int getId() const { return id; }
|
||||
virtual bool readElement(QXmlStreamReader *xml) = 0;
|
||||
virtual void writeElement(QXmlStreamWriter *xml) = 0;
|
||||
};
|
||||
class DeckList_File : public DeckList_TreeItem {
|
||||
private:
|
||||
|
|
@ -180,10 +207,8 @@ public:
|
|||
QDateTime getUploadTime() const { return uploadTime; }
|
||||
};
|
||||
class DeckList_Directory : public DeckList_TreeItem, public QList<DeckList_TreeItem *> {
|
||||
private:
|
||||
DeckList_TreeItem *currentItem;
|
||||
public:
|
||||
DeckList_Directory(const QString &_name = QString(), int _id = 0) : DeckList_TreeItem(_name, _id), currentItem(0) { }
|
||||
DeckList_Directory(const QString &_name = QString(), int _id = 0) : DeckList_TreeItem(_name, _id) { }
|
||||
~DeckList_Directory();
|
||||
bool readElement(QXmlStreamReader *xml);
|
||||
void writeElement(QXmlStreamWriter *xml);
|
||||
|
|
|
|||
|
|
@ -56,9 +56,8 @@ ItemId_Event_SetActivePhase = 1054,
|
|||
ItemId_Event_DumpZone = 1055,
|
||||
ItemId_Event_StopDumpZone = 1056,
|
||||
ItemId_Event_ServerMessage = 1057,
|
||||
ItemId_Event_GameJoined = 1058,
|
||||
ItemId_Event_ChatJoinChannel = 1059,
|
||||
ItemId_Event_ChatLeaveChannel = 1060,
|
||||
ItemId_Event_ChatSay = 1061,
|
||||
ItemId_Other = 1062
|
||||
ItemId_Event_ChatJoinChannel = 1058,
|
||||
ItemId_Event_ChatLeaveChannel = 1059,
|
||||
ItemId_Event_ChatSay = 1060,
|
||||
ItemId_Other = 1061
|
||||
};
|
||||
|
|
|
|||
|
|
@ -613,18 +613,6 @@ void Event_ServerMessage::extractParameters()
|
|||
GenericEvent::extractParameters();
|
||||
message = parameters["message"];
|
||||
}
|
||||
Event_GameJoined::Event_GameJoined(int _gameId, bool _spectator)
|
||||
: GenericEvent("game_joined"), gameId(_gameId), spectator(_spectator)
|
||||
{
|
||||
setParameter("game_id", gameId);
|
||||
setParameter("spectator", spectator);
|
||||
}
|
||||
void Event_GameJoined::extractParameters()
|
||||
{
|
||||
GenericEvent::extractParameters();
|
||||
gameId = parameters["game_id"].toInt();
|
||||
spectator = (parameters["spectator"] == "1");
|
||||
}
|
||||
Event_ChatJoinChannel::Event_ChatJoinChannel(const QString &_channel, const QString &_playerName)
|
||||
: ChatEvent("chat_join_channel", _channel), playerName(_playerName)
|
||||
{
|
||||
|
|
@ -716,7 +704,6 @@ void ProtocolItem::initializeHashAuto()
|
|||
itemNameHash.insert("game_eventdump_zone", Event_DumpZone::newItem);
|
||||
itemNameHash.insert("game_eventstop_dump_zone", Event_StopDumpZone::newItem);
|
||||
itemNameHash.insert("generic_eventserver_message", Event_ServerMessage::newItem);
|
||||
itemNameHash.insert("generic_eventgame_joined", Event_GameJoined::newItem);
|
||||
itemNameHash.insert("chat_eventchat_join_channel", Event_ChatJoinChannel::newItem);
|
||||
itemNameHash.insert("chat_eventchat_leave_channel", Event_ChatLeaveChannel::newItem);
|
||||
itemNameHash.insert("chat_eventchat_say", Event_ChatSay::newItem);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@
|
|||
3:dump_zone:i,zone_owner_id:s,zone:i,number_cards
|
||||
3:stop_dump_zone:i,zone_owner_id:s,zone
|
||||
4:server_message:s,message
|
||||
4:game_joined:i,game_id:b,spectator
|
||||
5:chat_join_channel:s,player_name
|
||||
5:chat_leave_channel:s,player_name
|
||||
5:chat_say:s,player_name:s,message
|
||||
|
|
@ -759,20 +759,6 @@ public:
|
|||
protected:
|
||||
void extractParameters();
|
||||
};
|
||||
class Event_GameJoined : public GenericEvent {
|
||||
Q_OBJECT
|
||||
private:
|
||||
int gameId;
|
||||
bool spectator;
|
||||
public:
|
||||
Event_GameJoined(int _gameId = -1, bool _spectator = false);
|
||||
int getGameId() const { return gameId; }
|
||||
bool getSpectator() const { return spectator; }
|
||||
static ProtocolItem *newItem() { return new Event_GameJoined; }
|
||||
int getItemId() const { return ItemId_Event_GameJoined; }
|
||||
protected:
|
||||
void extractParameters();
|
||||
};
|
||||
class Event_ChatJoinChannel : public ChatEvent {
|
||||
Q_OBJECT
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -22,21 +22,12 @@
|
|||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include "protocol_datastructures.h"
|
||||
|
||||
class Server_Card;
|
||||
class Server_Player;
|
||||
|
||||
class Server_CardZone {
|
||||
public:
|
||||
// PrivateZone: Contents of the zone are always visible to the owner,
|
||||
// but not to anyone else.
|
||||
// PublicZone: Contents of the zone are always visible to anyone.
|
||||
// HiddenZone: Contents of the zone are never visible to anyone.
|
||||
// However, the owner of the zone can issue a dump_zone command,
|
||||
// setting beingLookedAt to true.
|
||||
// Cards in a zone with the type HiddenZone are referenced by their
|
||||
// list index, whereas cards in any other zone are referenced by their ids.
|
||||
enum ZoneType { PrivateZone, PublicZone, HiddenZone };
|
||||
private:
|
||||
Server_Player *player;
|
||||
QString name;
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@
|
|||
#include "server_game.h"
|
||||
#include "server_protocolhandler.h"
|
||||
#include "server_arrow.h"
|
||||
#include "server_card.h"
|
||||
#include "server_cardzone.h"
|
||||
#include "server_counter.h"
|
||||
#include <QSqlQuery>
|
||||
|
||||
Server_Game::Server_Game(Server_ProtocolHandler *_creator, int _gameId, const QString &_description, const QString &_password, int _maxPlayers, bool _spectatorsAllowed, QObject *parent)
|
||||
|
|
@ -157,6 +160,54 @@ void Server_Game::setActivePhase(int _activePhase)
|
|||
sendGameEvent(new Event_SetActivePhase(-1, -1, activePhase));
|
||||
}
|
||||
|
||||
QList<ServerInfo_Player *> Server_Game::getGameState() const
|
||||
{
|
||||
QList<ServerInfo_Player *> result;
|
||||
QMapIterator<int, Server_Player *> playerIterator(players);
|
||||
while (playerIterator.hasNext()) {
|
||||
Server_Player *player = playerIterator.next().value();
|
||||
|
||||
QList<ServerInfo_Arrow *> arrowList;
|
||||
QMapIterator<int, Server_Arrow *> arrowIterator(player->getArrows());
|
||||
while (arrowIterator.hasNext()) {
|
||||
Server_Arrow *arrow = arrowIterator.next().value();
|
||||
arrowList.append(new ServerInfo_Arrow(
|
||||
arrow->getId(),
|
||||
arrow->getStartCard()->getZone()->getPlayer()->getPlayerId(),
|
||||
arrow->getStartCard()->getZone()->getName(),
|
||||
arrow->getStartCard()->getId(),
|
||||
arrow->getTargetCard()->getZone()->getPlayer()->getPlayerId(),
|
||||
arrow->getTargetCard()->getZone()->getName(),
|
||||
arrow->getTargetCard()->getId(),
|
||||
arrow->getColor()
|
||||
));
|
||||
}
|
||||
|
||||
QList<ServerInfo_Counter *> counterList;
|
||||
QMapIterator<int, Server_Counter *> counterIterator(player->getCounters());
|
||||
while (counterIterator.hasNext()) {
|
||||
Server_Counter *counter = counterIterator.next().value();
|
||||
counterList.append(new ServerInfo_Counter(counter->getId(), counter->getName(), counter->getColor(), counter->getRadius(), counter->getCount()));
|
||||
}
|
||||
|
||||
QList<ServerInfo_Zone *> zoneList;
|
||||
QMapIterator<QString, Server_CardZone *> zoneIterator(player->getZones());
|
||||
while (zoneIterator.hasNext()) {
|
||||
Server_CardZone *zone = zoneIterator.next().value();
|
||||
QList<ServerInfo_Card *> cardList;
|
||||
QListIterator<Server_Card *> cardIterator(zone->cards);
|
||||
while (cardIterator.hasNext()) {
|
||||
Server_Card *card = cardIterator.next();
|
||||
cardList.append(new ServerInfo_Card(card->getId(), card->getName(), card->getX(), card->getY(), card->getCounters(), card->getTapped(), card->getAttacking(), card->getAnnotation()));
|
||||
}
|
||||
zoneList.append(new ServerInfo_Zone(zone->getName(), zone->getType(), zone->hasCoords(), zone->cards.size(), cardList));
|
||||
}
|
||||
|
||||
result.append(new ServerInfo_Player(player->getPlayerId(), player->getPlayerName(), zoneList, counterList, arrowList));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
void Server_Game::sendGameEvent(GameEvent *event)
|
||||
{
|
||||
event->setGameId(gameId);
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@ public:
|
|||
void setActivePlayer(int _activePlayer);
|
||||
void setActivePhase(int _activePhase);
|
||||
|
||||
QList<ServerInfo_Player *> getGameState() const;
|
||||
void sendGameEvent(GameEvent *event);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -52,14 +52,14 @@ void Server_Player::setupZones()
|
|||
// ------------------------------------------------------------------
|
||||
|
||||
// Create zones
|
||||
Server_CardZone *deckZone = new Server_CardZone(this, "deck", false, Server_CardZone::HiddenZone);
|
||||
Server_CardZone *deckZone = new Server_CardZone(this, "deck", false, HiddenZone);
|
||||
addZone(deckZone);
|
||||
Server_CardZone *sbZone = new Server_CardZone(this, "sb", false, Server_CardZone::HiddenZone);
|
||||
Server_CardZone *sbZone = new Server_CardZone(this, "sb", false, HiddenZone);
|
||||
addZone(sbZone);
|
||||
addZone(new Server_CardZone(this, "table", true, Server_CardZone::PublicZone));
|
||||
addZone(new Server_CardZone(this, "hand", false, Server_CardZone::PrivateZone));
|
||||
addZone(new Server_CardZone(this, "grave", false, Server_CardZone::PublicZone));
|
||||
addZone(new Server_CardZone(this, "rfg", false, Server_CardZone::PublicZone));
|
||||
addZone(new Server_CardZone(this, "table", true, PublicZone));
|
||||
addZone(new Server_CardZone(this, "hand", false, PrivateZone));
|
||||
addZone(new Server_CardZone(this, "grave", false, PublicZone));
|
||||
addZone(new Server_CardZone(this, "rfg", false, PublicZone));
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -220,7 +220,7 @@ ResponseCode Server_ProtocolHandler::cmdCreateGame(Command_CreateGame *cmd)
|
|||
Server_Game *game = server->createGame(cmd->getDescription(), cmd->getPassword(), cmd->getMaxPlayers(), cmd->getSpectatorsAllowed(), this);
|
||||
games.insert(game->getGameId(), QPair<Server_Game *, Server_Player *>(game, game->getCreator()));
|
||||
|
||||
enqueueProtocolItem(new Event_GameJoined(game->getGameId(), false));
|
||||
enqueueProtocolItem(new Event_GameJoined(game->getGameId(), game->getCreator()->getPlayerId(), false, game->getGameState()));
|
||||
return RespOk;
|
||||
}
|
||||
|
||||
|
|
@ -234,8 +234,8 @@ ResponseCode Server_ProtocolHandler::cmdJoinGame(Command_JoinGame *cmd)
|
|||
if (result == RespOk) {
|
||||
Server_Player *player = g->addPlayer(this, cmd->getSpectator());
|
||||
games.insert(cmd->getGameId(), QPair<Server_Game *, Server_Player *>(g, player));
|
||||
enqueueProtocolItem(new Event_GameJoined(cmd->getGameId(), player->getPlayerId(), cmd->getSpectator(), g->getGameState()));
|
||||
}
|
||||
enqueueProtocolItem(new Event_GameJoined(cmd->getGameId(), cmd->getSpectator()));
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -326,13 +326,13 @@ ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, Server_G
|
|||
|
||||
targetzone->insertCard(card, x, y);
|
||||
|
||||
bool targetBeingLookedAt = (targetzone->getType() != Server_CardZone::HiddenZone) || (targetzone->getCardsBeingLookedAt() > x) || (targetzone->getCardsBeingLookedAt() == -1);
|
||||
bool sourceBeingLookedAt = (startzone->getType() != Server_CardZone::HiddenZone) || (startzone->getCardsBeingLookedAt() > position) || (startzone->getCardsBeingLookedAt() == -1);
|
||||
bool targetBeingLookedAt = (targetzone->getType() != HiddenZone) || (targetzone->getCardsBeingLookedAt() > x) || (targetzone->getCardsBeingLookedAt() == -1);
|
||||
bool sourceBeingLookedAt = (startzone->getType() != HiddenZone) || (startzone->getCardsBeingLookedAt() > position) || (startzone->getCardsBeingLookedAt() == -1);
|
||||
|
||||
bool targetHiddenToPlayer = facedown || !targetBeingLookedAt;
|
||||
bool targetHiddenToOthers = facedown || (targetzone->getType() != Server_CardZone::PublicZone);
|
||||
bool targetHiddenToOthers = facedown || (targetzone->getType() != PublicZone);
|
||||
bool sourceHiddenToPlayer = card->getFaceDown() || !sourceBeingLookedAt;
|
||||
bool sourceHiddenToOthers = card->getFaceDown() || (startzone->getType() != Server_CardZone::PublicZone);
|
||||
bool sourceHiddenToOthers = card->getFaceDown() || (startzone->getType() != PublicZone);
|
||||
|
||||
QString privateCardName, publicCardName;
|
||||
if (!(sourceHiddenToPlayer && targetHiddenToPlayer))
|
||||
|
|
@ -363,9 +363,9 @@ ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, Server_G
|
|||
// Other players do not get to see the start and/or target position of the card if the respective
|
||||
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
|
||||
// all cards are equal.
|
||||
if ((startzone->getType() == Server_CardZone::HiddenZone) && ((startzone->getCardsBeingLookedAt() > position) || (startzone->getCardsBeingLookedAt() == -1)))
|
||||
if ((startzone->getType() == HiddenZone) && ((startzone->getCardsBeingLookedAt() > position) || (startzone->getCardsBeingLookedAt() == -1)))
|
||||
position = -1;
|
||||
if ((targetzone->getType() == Server_CardZone::HiddenZone) && ((targetzone->getCardsBeingLookedAt() > x) || (targetzone->getCardsBeingLookedAt() == -1)))
|
||||
if ((targetzone->getType() == HiddenZone) && ((targetzone->getCardsBeingLookedAt() > x) || (targetzone->getCardsBeingLookedAt() == -1)))
|
||||
x = -1;
|
||||
|
||||
/* if ((startzone->getType() == Server_CardZone::PublicZone) || (targetzone->getType() == Server_CardZone::PublicZone))
|
||||
|
|
@ -565,10 +565,10 @@ ResponseCode Server_ProtocolHandler::cmdDumpZone(Command_DumpZone *cmd, Server_G
|
|||
Server_CardZone *zone = otherPlayer->getZones().value(cmd->getZoneName());
|
||||
if (!zone)
|
||||
return RespNameNotFound;
|
||||
if (!((zone->getType() == Server_CardZone::PublicZone) || (player == otherPlayer)))
|
||||
if (!((zone->getType() == PublicZone) || (player == otherPlayer)))
|
||||
return RespContextError;
|
||||
|
||||
if (zone->getType() == Server_CardZone::HiddenZone) {
|
||||
if (zone->getType() == HiddenZone) {
|
||||
// game->broadcastEvent(QString("dump_zone|%1|%2|%3").arg(player_id).arg(zone->getName()).arg(number_cards), player);
|
||||
}
|
||||
// remsg->sendList(dumpZoneHelper(otherPlayer, zone, number_cards));
|
||||
|
|
@ -584,7 +584,7 @@ ResponseCode Server_ProtocolHandler::cmdStopDumpZone(Command_StopDumpZone *cmd,
|
|||
if (!zone)
|
||||
return RespNameNotFound;
|
||||
|
||||
if (zone->getType() == Server_CardZone::HiddenZone) {
|
||||
if (zone->getType() == HiddenZone) {
|
||||
zone->setCardsBeingLookedAt(0);
|
||||
game->sendGameEvent(new Event_StopDumpZone(-1, player->getPlayerId(), cmd->getPlayerId(), zone->getName()));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue