cipt code
This commit is contained in:
parent
888a64b0fd
commit
388e9255c7
10 changed files with 73 additions and 41 deletions
|
@ -173,8 +173,11 @@ void CardItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if (tz)
|
if (tz)
|
||||||
tz->toggleTapped();
|
tz->toggleTapped();
|
||||||
else {
|
else {
|
||||||
|
bool faceDown = event->modifiers().testFlag(Qt::ShiftModifier);
|
||||||
|
bool tapped = info->getCipt();
|
||||||
|
|
||||||
TableZone *table = zone->getPlayer()->getTable();
|
TableZone *table = zone->getPlayer()->getTable();
|
||||||
QPoint gridPoint = table->getFreeGridPoint(info->getTableRow());
|
QPoint gridPoint = table->getFreeGridPoint(info->getTableRow());
|
||||||
table->handleDropEventByGrid(id, zone, gridPoint, false);
|
table->handleDropEventByGrid(id, zone, gridPoint, faceDown, tapped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,9 +66,9 @@ void TableZone::handleDropEvent(int cardId, CardZone *startZone, const QPoint &d
|
||||||
handleDropEventByGrid(cardId, startZone, mapToGrid(dropPoint), faceDown);
|
handleDropEventByGrid(cardId, startZone, mapToGrid(dropPoint), faceDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::handleDropEventByGrid(int cardId, CardZone *startZone, const QPoint &gridPoint, bool faceDown)
|
void TableZone::handleDropEventByGrid(int cardId, CardZone *startZone, const QPoint &gridPoint, bool faceDown, bool tapped)
|
||||||
{
|
{
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), cardId, getName(), gridPoint.x(), gridPoint.y(), faceDown));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), cardId, getName(), gridPoint.x(), gridPoint.y(), faceDown, tapped));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::reorganizeCards()
|
void TableZone::reorganizeCards()
|
||||||
|
|
|
@ -21,8 +21,8 @@ public:
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void toggleTapped();
|
void toggleTapped();
|
||||||
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(int cardId, CardZone *startZone, const QPoint &dropPoint, bool faceDown = false);
|
||||||
void handleDropEventByGrid(int cardId, CardZone *startZone, const QPoint &gridPoint, bool faceDown);
|
void handleDropEventByGrid(int cardId, CardZone *startZone, const QPoint &gridPoint, bool faceDown = false, bool tapped = false);
|
||||||
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
||||||
QPointF mapFromGrid(const QPoint &gridPoint) const;
|
QPointF mapFromGrid(const QPoint &gridPoint) const;
|
||||||
QPoint mapToGrid(const QPointF &mapPoint) const;
|
QPoint mapToGrid(const QPointF &mapPoint) const;
|
||||||
|
|
|
@ -100,7 +100,7 @@ void Command::processResponse(ProtocolResponse *response)
|
||||||
}
|
}
|
||||||
|
|
||||||
CommandContainer::CommandContainer(const QList<Command *> &_commandList, int _cmdId)
|
CommandContainer::CommandContainer(const QList<Command *> &_commandList, int _cmdId)
|
||||||
: ProtocolItem("container", "cmd"), ticks(0), resp(0), gameEventQueue(0)
|
: ProtocolItem("container", "cmd"), ticks(0), resp(0), gameEventQueuePublic(0), gameEventQueuePrivate(0)
|
||||||
{
|
{
|
||||||
if (_cmdId == -1)
|
if (_cmdId == -1)
|
||||||
_cmdId = lastCmdId++;
|
_cmdId = lastCmdId++;
|
||||||
|
@ -126,11 +126,18 @@ void CommandContainer::setResponse(ProtocolResponse *_resp)
|
||||||
resp = _resp;
|
resp = _resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandContainer::enqueueGameEvent(GameEvent *event, int gameId)
|
void CommandContainer::enqueueGameEventPublic(GameEvent *event, int gameId)
|
||||||
{
|
{
|
||||||
if (!gameEventQueue)
|
if (!gameEventQueuePublic)
|
||||||
gameEventQueue = new GameEventContainer(QList<GameEvent *>(), gameId);
|
gameEventQueuePublic = new GameEventContainer(QList<GameEvent *>(), gameId);
|
||||||
gameEventQueue->appendItem(event);
|
gameEventQueuePublic->appendItem(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CommandContainer::enqueueGameEventPrivate(GameEvent *event, int gameId)
|
||||||
|
{
|
||||||
|
if (!gameEventQueuePrivate)
|
||||||
|
gameEventQueuePrivate = new GameEventContainer(QList<GameEvent *>(), gameId);
|
||||||
|
gameEventQueuePrivate->appendItem(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_DeckUpload::Command_DeckUpload(DeckList *_deck, const QString &_path)
|
Command_DeckUpload::Command_DeckUpload(DeckList *_deck, const QString &_path)
|
||||||
|
|
|
@ -99,7 +99,8 @@ private:
|
||||||
// These are only for processing inside the server.
|
// These are only for processing inside the server.
|
||||||
ProtocolResponse *resp;
|
ProtocolResponse *resp;
|
||||||
QList<ProtocolItem *> itemQueue;
|
QList<ProtocolItem *> itemQueue;
|
||||||
GameEventContainer *gameEventQueue;
|
GameEventContainer *gameEventQueuePublic;
|
||||||
|
GameEventContainer *gameEventQueuePrivate;
|
||||||
public:
|
public:
|
||||||
CommandContainer(const QList<Command *> &_commandList = QList<Command *>(), int _cmdId = -1);
|
CommandContainer(const QList<Command *> &_commandList = QList<Command *>(), int _cmdId = -1);
|
||||||
static SerializableItem *newItem() { return new CommandContainer; }
|
static SerializableItem *newItem() { return new CommandContainer; }
|
||||||
|
@ -113,8 +114,10 @@ public:
|
||||||
void setResponse(ProtocolResponse *_resp);
|
void setResponse(ProtocolResponse *_resp);
|
||||||
const QList<ProtocolItem *> &getItemQueue() const { return itemQueue; }
|
const QList<ProtocolItem *> &getItemQueue() const { return itemQueue; }
|
||||||
void enqueueItem(ProtocolItem *item) { itemQueue.append(item); }
|
void enqueueItem(ProtocolItem *item) { itemQueue.append(item); }
|
||||||
GameEventContainer *getGameEventQueue() const { return gameEventQueue; }
|
GameEventContainer *getGameEventQueuePublic() const { return gameEventQueuePublic; }
|
||||||
void enqueueGameEvent(GameEvent *event, int gameId);
|
void enqueueGameEventPublic(GameEvent *event, int gameId);
|
||||||
|
GameEventContainer *getGameEventQueuePrivate() const { return gameEventQueuePrivate; }
|
||||||
|
void enqueueGameEventPrivate(GameEvent *event, int gameId);
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChatCommand : public Command {
|
class ChatCommand : public Command {
|
||||||
|
|
|
@ -100,7 +100,7 @@ Command_DrawCards::Command_DrawCards(int _gameId, int _number)
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_Int("number", _number));
|
insertItem(new SerializableItem_Int("number", _number));
|
||||||
}
|
}
|
||||||
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, int _cardId, const QString &_targetZone, int _x, int _y, bool _faceDown)
|
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, int _cardId, const QString &_targetZone, int _x, int _y, bool _faceDown, bool _tapped)
|
||||||
: GameCommand("move_card", _gameId)
|
: GameCommand("move_card", _gameId)
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_String("start_zone", _startZone));
|
insertItem(new SerializableItem_String("start_zone", _startZone));
|
||||||
|
@ -109,6 +109,7 @@ Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, int _
|
||||||
insertItem(new SerializableItem_Int("x", _x));
|
insertItem(new SerializableItem_Int("x", _x));
|
||||||
insertItem(new SerializableItem_Int("y", _y));
|
insertItem(new SerializableItem_Int("y", _y));
|
||||||
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
insertItem(new SerializableItem_Bool("face_down", _faceDown));
|
||||||
|
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
||||||
}
|
}
|
||||||
Command_CreateToken::Command_CreateToken(int _gameId, const QString &_zone, const QString &_cardName, const QString &_pt, int _x, int _y)
|
Command_CreateToken::Command_CreateToken(int _gameId, const QString &_zone, const QString &_cardName, const QString &_pt, int _x, int _y)
|
||||||
: GameCommand("create_token", _gameId)
|
: GameCommand("create_token", _gameId)
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
2:mulligan
|
2:mulligan
|
||||||
2:roll_die:i,sides
|
2:roll_die:i,sides
|
||||||
2:draw_cards:i,number
|
2:draw_cards:i,number
|
||||||
2:move_card:s,start_zone:i,card_id:s,target_zone:i,x:i,y:b,face_down
|
2:move_card:s,start_zone:i,card_id:s,target_zone:i,x:i,y:b,face_down:b,tapped
|
||||||
2:create_token:s,zone:s,card_name:s,pt:i,x:i,y
|
2:create_token:s,zone:s,card_name:s,pt:i,x:i,y
|
||||||
2:create_arrow:i,start_player_id:s,start_zone:i,start_card_id:i,target_player_id:s,target_zone:i,target_card_id:c,color
|
2:create_arrow:i,start_player_id:s,start_zone:i,start_card_id:i,target_player_id:s,target_zone:i,target_card_id:c,color
|
||||||
2:delete_arrow:i,arrow_id
|
2:delete_arrow:i,arrow_id
|
||||||
|
|
|
@ -165,13 +165,14 @@ public:
|
||||||
class Command_MoveCard : public GameCommand {
|
class Command_MoveCard : public GameCommand {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Command_MoveCard(int _gameId = -1, const QString &_startZone = QString(), int _cardId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1, bool _faceDown = false);
|
Command_MoveCard(int _gameId = -1, const QString &_startZone = QString(), int _cardId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1, bool _faceDown = false, bool _tapped = false);
|
||||||
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); };
|
QString getStartZone() const { return static_cast<SerializableItem_String *>(itemMap.value("start_zone"))->getData(); };
|
||||||
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
|
int getCardId() const { return static_cast<SerializableItem_Int *>(itemMap.value("card_id"))->getData(); };
|
||||||
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); };
|
QString getTargetZone() const { return static_cast<SerializableItem_String *>(itemMap.value("target_zone"))->getData(); };
|
||||||
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); };
|
int getX() const { return static_cast<SerializableItem_Int *>(itemMap.value("x"))->getData(); };
|
||||||
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); };
|
int getY() const { return static_cast<SerializableItem_Int *>(itemMap.value("y"))->getData(); };
|
||||||
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("face_down"))->getData(); };
|
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("face_down"))->getData(); };
|
||||||
|
bool getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); };
|
||||||
static SerializableItem *newItem() { return new Command_MoveCard; }
|
static SerializableItem *newItem() { return new Command_MoveCard; }
|
||||||
int getItemId() const { return ItemId_Command_MoveCard; }
|
int getItemId() const { return ItemId_Command_MoveCard; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,10 +142,16 @@ void Server_ProtocolHandler::processCommandContainer(CommandContainer *cont)
|
||||||
if (!pr)
|
if (!pr)
|
||||||
pr = new ProtocolResponse(cont->getCmdId(), finalResponseCode);
|
pr = new ProtocolResponse(cont->getCmdId(), finalResponseCode);
|
||||||
|
|
||||||
GameEventContainer *gQ = cont->getGameEventQueue();
|
GameEventContainer *gQPublic = cont->getGameEventQueuePublic();
|
||||||
if (gQ) {
|
if (gQPublic) {
|
||||||
Server_Game *game = games.value(gQ->getGameId()).first;
|
Server_Game *game = games.value(gQPublic->getGameId()).first;
|
||||||
game->sendGameEventContainer(gQ);
|
Server_Player *player = games.value(gQPublic->getGameId()).second;
|
||||||
|
GameEventContainer *gQPrivate = cont->getGameEventQueuePrivate();
|
||||||
|
if (gQPrivate) {
|
||||||
|
game->sendGameEventContainer(gQPublic, player);
|
||||||
|
player->sendProtocolItem(gQPrivate);
|
||||||
|
} else
|
||||||
|
game->sendGameEventContainer(gQPublic);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QList<ProtocolItem *> &iQ = cont->getItemQueue();
|
const QList<ProtocolItem *> &iQ = cont->getItemQueue();
|
||||||
|
@ -391,12 +397,13 @@ ResponseCode Server_ProtocolHandler::cmdMulligan(Command_Mulligan * /*cmd*/, Com
|
||||||
|
|
||||||
Server_CardZone *hand = player->getZones().value("hand");
|
Server_CardZone *hand = player->getZones().value("hand");
|
||||||
while (!hand->cards.isEmpty())
|
while (!hand->cards.isEmpty())
|
||||||
moveCard(game, player, "hand", hand->cards.first()->getId(), "deck", 0, 0, false);
|
moveCard(game, player, cont, "hand", hand->cards.first()->getId(), "deck", 0, 0, false, false);
|
||||||
|
|
||||||
player->getZones().value("deck")->shuffle();
|
player->getZones().value("deck")->shuffle();
|
||||||
game->sendGameEvent(new Event_Shuffle(player->getPlayerId()));
|
cont->enqueueGameEventPrivate(new Event_Shuffle(player->getPlayerId()), game->getGameId());
|
||||||
|
cont->enqueueGameEventPublic(new Event_Shuffle(player->getPlayerId()), game->getGameId());
|
||||||
|
|
||||||
drawCards(game, player, number);
|
drawCards(game, player, cont, number);
|
||||||
player->setInitialCards(number - 1);
|
player->setInitialCards(number - 1);
|
||||||
|
|
||||||
return RespOk;
|
return RespOk;
|
||||||
|
@ -408,7 +415,7 @@ ResponseCode Server_ProtocolHandler::cmdRollDie(Command_RollDie *cmd, CommandCon
|
||||||
return RespOk;
|
return RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::drawCards(Server_Game *game, Server_Player *player, int number)
|
ResponseCode Server_ProtocolHandler::drawCards(Server_Game *game, Server_Player *player, CommandContainer *cont, int number)
|
||||||
{
|
{
|
||||||
if (!game->getGameStarted())
|
if (!game->getGameStarted())
|
||||||
return RespGameNotStarted;
|
return RespGameNotStarted;
|
||||||
|
@ -425,8 +432,8 @@ ResponseCode Server_ProtocolHandler::drawCards(Server_Game *game, Server_Player
|
||||||
cardList.append(new ServerInfo_Card(card->getId(), card->getName()));
|
cardList.append(new ServerInfo_Card(card->getId(), card->getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
player->sendProtocolItem(GameEventContainer::makeNew(new Event_DrawCards(player->getPlayerId(), cardList.size(), cardList), game->getGameId()));
|
cont->enqueueGameEventPrivate(new Event_DrawCards(player->getPlayerId(), cardList.size(), cardList), game->getGameId());
|
||||||
game->sendGameEvent(new Event_DrawCards(player->getPlayerId(), cardList.size()), player);
|
cont->enqueueGameEventPublic(new Event_DrawCards(player->getPlayerId(), cardList.size()), game->getGameId());
|
||||||
|
|
||||||
return RespOk;
|
return RespOk;
|
||||||
}
|
}
|
||||||
|
@ -434,10 +441,10 @@ ResponseCode Server_ProtocolHandler::drawCards(Server_Game *game, Server_Player
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdDrawCards(Command_DrawCards *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::cmdDrawCards(Command_DrawCards *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
{
|
{
|
||||||
return drawCards(game, player, cmd->getNumber());
|
return drawCards(game, player, cont, cmd->getNumber());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *player, const QString &_startZone, int _cardId, const QString &_targetZone, int x, int y, bool faceDown)
|
ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *player, CommandContainer *cont, const QString &_startZone, int _cardId, const QString &_targetZone, int x, int y, bool faceDown, bool tapped)
|
||||||
{
|
{
|
||||||
if (!game->getGameStarted())
|
if (!game->getGameStarted())
|
||||||
return RespGameNotStarted;
|
return RespGameNotStarted;
|
||||||
|
@ -489,7 +496,7 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *
|
||||||
int privatePosition = -1;
|
int privatePosition = -1;
|
||||||
if (startzone->getType() == HiddenZone)
|
if (startzone->getType() == HiddenZone)
|
||||||
privatePosition = position;
|
privatePosition = position;
|
||||||
player->sendProtocolItem(GameEventContainer::makeNew(new Event_MoveCard(player->getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getName(), x, y, privateNewCardId, faceDown), game->getGameId()));
|
cont->enqueueGameEventPrivate(new Event_MoveCard(player->getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getName(), x, y, privateNewCardId, faceDown), game->getGameId());
|
||||||
|
|
||||||
// Other players do not get to see the start and/or target position of the card if the respective
|
// 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,
|
// part of the zone is being looked at. The information is not needed anyway because in hidden zones,
|
||||||
|
@ -503,9 +510,12 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *
|
||||||
x = -1;
|
x = -1;
|
||||||
|
|
||||||
if ((startzone->getType() == PublicZone) || (targetzone->getType() == PublicZone))
|
if ((startzone->getType() == PublicZone) || (targetzone->getType() == PublicZone))
|
||||||
game->sendGameEvent(new Event_MoveCard(player->getPlayerId(), oldCardId, publicCardName, startzone->getName(), position, targetzone->getName(), x, y, card->getId(), faceDown), player);
|
cont->enqueueGameEventPublic(new Event_MoveCard(player->getPlayerId(), oldCardId, publicCardName, startzone->getName(), position, targetzone->getName(), x, y, card->getId(), faceDown), game->getGameId());
|
||||||
else
|
else
|
||||||
game->sendGameEvent(new Event_MoveCard(player->getPlayerId(), -1, QString(), startzone->getName(), position, targetzone->getName(), x, y, -1, false), player);
|
cont->enqueueGameEventPublic(new Event_MoveCard(player->getPlayerId(), -1, QString(), startzone->getName(), position, targetzone->getName(), x, y, -1, false), game->getGameId());
|
||||||
|
|
||||||
|
if (tapped)
|
||||||
|
setCardAttrHelper(cont, game, player, targetzone->getName(), card->getId(), "tapped", "1");
|
||||||
|
|
||||||
// If the card was moved to another zone, delete all arrows from and to the card
|
// If the card was moved to another zone, delete all arrows from and to the card
|
||||||
if (startzone != targetzone) {
|
if (startzone != targetzone) {
|
||||||
|
@ -528,7 +538,7 @@ ResponseCode Server_ProtocolHandler::moveCard(Server_Game *game, Server_Player *
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
{
|
{
|
||||||
return moveCard(game, player, cmd->getStartZone(), cmd->getCardId(), cmd->getTargetZone(), cmd->getX(), cmd->getY(), cmd->getFaceDown());
|
return moveCard(game, player, cont, cmd->getStartZone(), cmd->getCardId(), cmd->getTargetZone(), cmd->getX(), cmd->getY(), cmd->getFaceDown(), cmd->getTapped());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::cmdCreateToken(Command_CreateToken *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
|
@ -599,33 +609,39 @@ ResponseCode Server_ProtocolHandler::cmdDeleteArrow(Command_DeleteArrow *cmd, Co
|
||||||
return RespOk;
|
return RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdSetCardAttr(Command_SetCardAttr *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::setCardAttrHelper(CommandContainer *cont, Server_Game *game, Server_Player *player, const QString &zoneName, int cardId, const QString &attrName, const QString &attrValue)
|
||||||
{
|
{
|
||||||
if (!game->getGameStarted())
|
if (!game->getGameStarted())
|
||||||
return RespGameNotStarted;
|
return RespGameNotStarted;
|
||||||
|
|
||||||
// zone, card id, attr name, attr value
|
// zone, card id, attr name, attr value
|
||||||
// card id = -1 => affects all cards in the specified zone
|
// card id = -1 => affects all cards in the specified zone
|
||||||
Server_CardZone *zone = player->getZones().value(cmd->getZone());
|
Server_CardZone *zone = player->getZones().value(zoneName);
|
||||||
if (!zone)
|
if (!zone)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
|
|
||||||
if (cmd->getCardId() == -1) {
|
if (cardId == -1) {
|
||||||
QListIterator<Server_Card *> CardIterator(zone->cards);
|
QListIterator<Server_Card *> CardIterator(zone->cards);
|
||||||
while (CardIterator.hasNext())
|
while (CardIterator.hasNext())
|
||||||
if (!CardIterator.next()->setAttribute(cmd->getAttrName(), cmd->getAttrValue(), true))
|
if (!CardIterator.next()->setAttribute(attrName, attrValue, true))
|
||||||
return RespInvalidCommand;
|
return RespInvalidCommand;
|
||||||
} else {
|
} else {
|
||||||
Server_Card *card = zone->getCard(cmd->getCardId(), false);
|
Server_Card *card = zone->getCard(cardId, false);
|
||||||
if (!card)
|
if (!card)
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
if (!card->setAttribute(cmd->getAttrName(), cmd->getAttrValue(), false))
|
if (!card->setAttribute(attrName, attrValue, false))
|
||||||
return RespInvalidCommand;
|
return RespInvalidCommand;
|
||||||
}
|
}
|
||||||
cont->enqueueGameEvent(new Event_SetCardAttr(player->getPlayerId(), zone->getName(), cmd->getCardId(), cmd->getAttrName(), cmd->getAttrValue()), game->getGameId());
|
cont->enqueueGameEventPrivate(new Event_SetCardAttr(player->getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId());
|
||||||
|
cont->enqueueGameEventPublic(new Event_SetCardAttr(player->getPlayerId(), zone->getName(), cardId, attrName, attrValue), game->getGameId());
|
||||||
return RespOk;
|
return RespOk;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResponseCode Server_ProtocolHandler::cmdSetCardAttr(Command_SetCardAttr *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
|
{
|
||||||
|
return setCardAttrHelper(cont, game, player, cmd->getZone(), cmd->getCardId(), cmd->getAttrName(), cmd->getAttrValue());
|
||||||
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdIncCounter(Command_IncCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::cmdIncCounter(Command_IncCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
{
|
{
|
||||||
if (!game->getGameStarted())
|
if (!game->getGameStarted())
|
||||||
|
|
|
@ -56,13 +56,14 @@ private:
|
||||||
ResponseCode cmdMulligan(Command_Mulligan *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdMulligan(Command_Mulligan *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode cmdRollDie(Command_RollDie *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdRollDie(Command_RollDie *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
// XXX Maybe the following function and others belong into Server_Player
|
// XXX Maybe the following function and others belong into Server_Player
|
||||||
ResponseCode drawCards(Server_Game *game, Server_Player *player, int number);
|
ResponseCode drawCards(Server_Game *game, Server_Player *player, CommandContainer *cont, int number);
|
||||||
ResponseCode cmdDrawCards(Command_DrawCards *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdDrawCards(Command_DrawCards *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode moveCard(Server_Game *game, Server_Player *player, const QString &_startZone, int _cardId, const QString &_targetZone, int _x, int _y, bool _faceDown);
|
ResponseCode moveCard(Server_Game *game, Server_Player *player, CommandContainer *cont, const QString &_startZone, int _cardId, const QString &_targetZone, int _x, int _y, bool _faceDown, bool _tapped);
|
||||||
ResponseCode cmdMoveCard(Command_MoveCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdMoveCard(Command_MoveCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode cmdCreateToken(Command_CreateToken *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdCreateToken(Command_CreateToken *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode cmdCreateArrow(Command_CreateArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdCreateArrow(Command_CreateArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode cmdDeleteArrow(Command_DeleteArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdDeleteArrow(Command_DeleteArrow *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
|
ResponseCode setCardAttrHelper(CommandContainer *cont, Server_Game *game, Server_Player *player, const QString &zone, int cardId, const QString &attrName, const QString &attrValue);
|
||||||
ResponseCode cmdSetCardAttr(Command_SetCardAttr *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdSetCardAttr(Command_SetCardAttr *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode cmdIncCounter(Command_IncCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdIncCounter(Command_IncCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
ResponseCode cmdCreateCounter(Command_CreateCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
ResponseCode cmdCreateCounter(Command_CreateCounter *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player);
|
||||||
|
|
Loading…
Reference in a new issue