mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-15 11:38:49 -07:00
fixed direct chat, fixed in-game attachment bugs
This commit is contained in:
parent
c39539b73a
commit
92e842bb74
18 changed files with 127 additions and 96 deletions
|
|
@ -154,9 +154,9 @@ bool Server_CardZone::isColumnEmpty(int x, int y) const
|
|||
|
||||
void Server_CardZone::moveCard(CommandContainer *cont, QMap<int, Server_Card *> &coordMap, Server_Card *card, int x, int y)
|
||||
{
|
||||
coordMap.remove(card->getX());
|
||||
player->moveCard(cont, this, QList<int>() << card->getId(), this, x, y, card->getFaceDown(), false);
|
||||
coordMap.insert(x, card);
|
||||
coordMap.remove(card->getY() * 10000 + card->getX());
|
||||
player->moveCard(cont, this, QList<int>() << card->getId(), this, x, y, card->getFaceDown(), false, false);
|
||||
coordMap.insert(y * 10000 + x, card);
|
||||
}
|
||||
|
||||
void Server_CardZone::fixFreeSpaces(CommandContainer *cont)
|
||||
|
|
|
|||
|
|
@ -233,7 +233,7 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<int> &_cardIds, Server_CardZone *targetzone, int x, int y, bool faceDown, bool tapped)
|
||||
ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<int> &_cardIds, Server_CardZone *targetzone, int x, int y, bool faceDown, bool tapped, bool fixFreeSpaces)
|
||||
{
|
||||
// Disallow controller change to other zones than the table.
|
||||
if (((targetzone->getType() != PublicZone) || !targetzone->hasCoords()) && (startzone->getPlayer() != targetzone->getPlayer()))
|
||||
|
|
@ -302,7 +302,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
|||
}
|
||||
}
|
||||
|
||||
if (card->getDestroyOnZoneChange() && (startzone != targetzone)) {
|
||||
if (card->getDestroyOnZoneChange() && (startzone->getName() != targetzone->getName())) {
|
||||
cont->enqueueGameEventPrivate(new Event_DestroyCard(getPlayerId(), startzone->getName(), card->getId()), game->getGameId());
|
||||
cont->enqueueGameEventPublic(new Event_DestroyCard(getPlayerId(), startzone->getName(), card->getId()), game->getGameId());
|
||||
card->deleteLater();
|
||||
|
|
@ -369,7 +369,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
|||
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "tapped", "1");
|
||||
}
|
||||
}
|
||||
if (startzone->hasCoords())
|
||||
if (startzone->hasCoords() && fixFreeSpaces)
|
||||
startzone->fixFreeSpaces(cont);
|
||||
|
||||
return RespOk;
|
||||
|
|
@ -383,7 +383,7 @@ void Server_Player::unattachCard(CommandContainer *cont, Server_Card *card)
|
|||
cont->enqueueGameEventPrivate(new Event_AttachCard(getPlayerId(), zone->getName(), card->getId(), -1, QString(), -1), game->getGameId());
|
||||
cont->enqueueGameEventPublic(new Event_AttachCard(getPlayerId(), zone->getName(), card->getId(), -1, QString(), -1), game->getGameId());
|
||||
|
||||
moveCard(cont, zone, QList<int>() << card->getId(), zone, -1, card->getY(), card->getFaceDown(), card->getTapped());
|
||||
moveCard(cont, zone, QList<int>() << card->getId(), zone, -1, card->getY(), card->getFaceDown(), false);
|
||||
}
|
||||
|
||||
ResponseCode Server_Player::setCardAttrHelper(CommandContainer *cont, const QString &zoneName, int cardId, const QString &attrName, const QString &attrValue)
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public:
|
|||
void setupZones();
|
||||
|
||||
ResponseCode moveCard(CommandContainer *cont, const QString &_startZone, const QList<int> &_cardId, int _targetPlayer, const QString &_targetZone, int _x, int _y, bool _faceDown, bool _tapped);
|
||||
ResponseCode moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<int> &_cardId, Server_CardZone *targetzone, int x, int y, bool faceDown, bool tapped);
|
||||
ResponseCode moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<int> &_cardId, Server_CardZone *targetzone, int x, int y, bool faceDown, bool tapped, bool fixFreeSpaces = true);
|
||||
void unattachCard(CommandContainer *cont, Server_Card *card);
|
||||
ResponseCode setCardAttrHelper(CommandContainer *cont, const QString &zone, int cardId, const QString &attrName, const QString &attrValue);
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,6 @@ ResponseCode Server_ProtocolHandler::processCommandHelper(Command *command, Comm
|
|||
default: return RespInvalidCommand;
|
||||
}
|
||||
}
|
||||
qDebug() << "received generic Command";
|
||||
switch (command->getItemId()) {
|
||||
case ItemId_Command_Ping: return cmdPing(static_cast<Command_Ping *>(command), cont);
|
||||
case ItemId_Command_Login: return cmdLogin(static_cast<Command_Login *>(command), cont);
|
||||
|
|
@ -659,7 +658,8 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm
|
|||
|
||||
if (targetCard) {
|
||||
// Unattach all cards attached to the card being attached.
|
||||
const QList<Server_Card *> &attachedList = card->getAttachedCards();
|
||||
// Make a copy of the list because its contents change during the loop otherwise.
|
||||
QList<Server_Card *> attachedList = card->getAttachedCards();
|
||||
for (int i = 0; i < attachedList.size(); ++i)
|
||||
player->unattachCard(cont, attachedList[i]);
|
||||
|
||||
|
|
@ -670,6 +670,7 @@ ResponseCode Server_ProtocolHandler::cmdAttachCard(Command_AttachCard *cmd, Comm
|
|||
card->setCoords(-1, card->getY());
|
||||
cont->enqueueGameEventPrivate(new Event_AttachCard(player->getPlayerId(), startzone->getName(), card->getId(), targetPlayer->getPlayerId(), targetzone->getName(), targetCard->getId()), game->getGameId());
|
||||
cont->enqueueGameEventPublic(new Event_AttachCard(player->getPlayerId(), startzone->getName(), card->getId(), targetPlayer->getPlayerId(), targetzone->getName(), targetCard->getId()), game->getGameId());
|
||||
startzone->fixFreeSpaces(cont);
|
||||
} else
|
||||
player->unattachCard(cont, card);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue