improved facedown moving
This commit is contained in:
parent
1047ab08e8
commit
da467468d5
22 changed files with 54 additions and 53 deletions
|
@ -83,7 +83,7 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
sc->removeItem(c);
|
sc->removeItem(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
currentZone->handleDropEvent(dragItemList, startZone, (sp - currentZone->scenePos()).toPoint(), faceDown);
|
currentZone->handleDropEvent(dragItemList, startZone, (sp - currentZone->scenePos()).toPoint());
|
||||||
|
|
||||||
event->accept();
|
event->accept();
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ private:
|
||||||
public:
|
public:
|
||||||
CardDragItem(CardItem *_item, int _id, const QPointF &_hotSpot, bool _faceDown, AbstractCardDragItem *parentDrag = 0);
|
CardDragItem(CardItem *_item, int _id, const QPointF &_hotSpot, bool _faceDown, AbstractCardDragItem *parentDrag = 0);
|
||||||
int getId() const { return id; }
|
int getId() const { return id; }
|
||||||
|
bool getFaceDown() const { return faceDown; }
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void updatePosition(const QPointF &cursorScenePos);
|
void updatePosition(const QPointF &cursorScenePos);
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -471,7 +471,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
childPos = c->pos() - pos();
|
childPos = c->pos() - pos();
|
||||||
else
|
else
|
||||||
childPos = QPointF(j * CARD_WIDTH / 2, 0);
|
childPos = QPointF(j * CARD_WIDTH / 2, 0);
|
||||||
CardDragItem *drag = new CardDragItem(c, c->getId(), childPos, false, dragItem);
|
CardDragItem *drag = new CardDragItem(c, c->getId(), childPos, c->getFaceDown(), dragItem);
|
||||||
drag->setPos(dragItem->pos() + childPos);
|
drag->setPos(dragItem->pos() + childPos);
|
||||||
scene()->addItem(drag);
|
scene()->addItem(drag);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public slots:
|
||||||
public:
|
public:
|
||||||
enum { Type = typeZone };
|
enum { Type = typeZone };
|
||||||
int type() const { return Type; }
|
int type() const { return Type; }
|
||||||
virtual void handleDropEvent(const QList<CardDragItem *> &dragItem, CardZone *startZone, const QPoint &dropPoint, bool faceDown) = 0;
|
virtual void handleDropEvent(const QList<CardDragItem *> &dragItem, CardZone *startZone, const QPoint &dropPoint) = 0;
|
||||||
CardZone(Player *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent = 0, bool isView = false);
|
CardZone(Player *_player, const QString &_name, bool _hasCardAttr, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent = 0, bool isView = false);
|
||||||
~CardZone();
|
~CardZone();
|
||||||
void retranslateUi();
|
void retranslateUi();
|
||||||
|
|
|
@ -37,13 +37,13 @@ void HandZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
card->update();
|
card->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void HandZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||||
{
|
{
|
||||||
QList<CardToMove *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), cards.size(), -1, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), cards.size(), -1));
|
||||||
}
|
}
|
||||||
|
|
||||||
QRectF HandZone::boundingRect() const
|
QRectF HandZone::boundingRect() const
|
||||||
|
|
|
@ -14,7 +14,7 @@ public slots:
|
||||||
void updateOrientation();
|
void updateOrientation();
|
||||||
public:
|
public:
|
||||||
HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent = 0);
|
HandZone(Player *_p, bool _contentsKnown, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
|
|
|
@ -48,13 +48,13 @@ void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
card->setParentItem(this);
|
card->setParentItem(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void PileZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||||
{
|
{
|
||||||
QList<CardToMove *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PileZone::reorganizeCards()
|
void PileZone::reorganizeCards()
|
||||||
|
|
|
@ -9,7 +9,7 @@ public:
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||||
protected:
|
protected:
|
||||||
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
void mousePressEvent(QGraphicsSceneMouseEvent *event);
|
||||||
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
|
||||||
|
|
|
@ -615,7 +615,7 @@ void Player::actMoveTopCardsToGrave()
|
||||||
QList<CardToMove *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < number; ++i)
|
for (int i = 0; i < number; ++i)
|
||||||
idList.append(new CardToMove(i));
|
idList.append(new CardToMove(i));
|
||||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "grave", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "grave", 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actMoveTopCardsToExile()
|
void Player::actMoveTopCardsToExile()
|
||||||
|
@ -631,12 +631,12 @@ void Player::actMoveTopCardsToExile()
|
||||||
QList<CardToMove *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < number; ++i)
|
for (int i = 0; i < number; ++i)
|
||||||
idList.append(new CardToMove(i));
|
idList.append(new CardToMove(i));
|
||||||
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "rfg", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, "deck", idList, getId(), "rfg", 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actMoveTopCardToBottom()
|
void Player::actMoveTopCardToBottom()
|
||||||
{
|
{
|
||||||
sendGameCommand(new Command_MoveCard(-1, "deck", QList<CardToMove *>() << new CardToMove(0), getId(), "deck", -1, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, "deck", QList<CardToMove *>() << new CardToMove(0), getId(), "deck", -1, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::actUntapAll()
|
void Player::actUntapAll()
|
||||||
|
@ -1155,10 +1155,10 @@ void Player::playCard(CardItem *c, bool faceDown, bool tapped)
|
||||||
{
|
{
|
||||||
CardInfo *ci = c->getInfo();
|
CardInfo *ci = c->getInfo();
|
||||||
if (ci->getTableRow() == 3)
|
if (ci->getTableRow() == 3)
|
||||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId()), getId(), "stack", 0, 0, false));
|
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId()), getId(), "stack", 0, 0));
|
||||||
else {
|
else {
|
||||||
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
QPoint gridPoint = QPoint(-1, 2 - ci->getTableRow());
|
||||||
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId(), ci->getPowTough(), tapped), getId(), "table", gridPoint.x(), gridPoint.y(), faceDown));
|
sendGameCommand(new Command_MoveCard(-1, c->getZone()->getName(), QList<CardToMove *>() << new CardToMove(c->getId(), faceDown, ci->getPowTough(), tapped), getId(), "table", gridPoint.x(), gridPoint.y()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1374,16 +1374,16 @@ void Player::cardMenuAction(QAction *a)
|
||||||
|
|
||||||
switch (a->data().toInt()) {
|
switch (a->data().toInt()) {
|
||||||
case 5:
|
case 5:
|
||||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", 0, 0, false));
|
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", 0, 0));
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", -1, 0, false));
|
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "deck", -1, 0));
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "grave", 0, 0, false));
|
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "grave", 0, 0));
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "rfg", 0, 0, false));
|
commandList.append(new Command_MoveCard(-1, startZone, idList, getId(), "rfg", 0, 0));
|
||||||
break;
|
break;
|
||||||
default: ;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,7 @@ void StackZone::paint(QPainter *painter, const QStyleOptionGraphicsItem */*optio
|
||||||
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
painter->fillRect(boundingRect(), QBrush(bgPixmap));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||||
{
|
{
|
||||||
if (startZone == this)
|
if (startZone == this)
|
||||||
return;
|
return;
|
||||||
|
@ -61,7 +61,7 @@ void StackZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackZone::reorganizeCards()
|
void StackZone::reorganizeCards()
|
||||||
|
|
|
@ -12,7 +12,7 @@ private slots:
|
||||||
void updateBgPixmap();
|
void updateBgPixmap();
|
||||||
public:
|
public:
|
||||||
StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent = 0);
|
StackZone(Player *_p, int _zoneHeight, QGraphicsItem *parent = 0);
|
||||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void reorganizeCards();
|
void reorganizeCards();
|
||||||
|
|
|
@ -86,18 +86,18 @@ void TableZone::addCardImpl(CardItem *card, int _x, int _y)
|
||||||
card->update();
|
card->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown)
|
void TableZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint)
|
||||||
{
|
{
|
||||||
handleDropEventByGrid(dragItems, startZone, mapToGrid(dropPoint), faceDown);
|
handleDropEventByGrid(dragItems, startZone, mapToGrid(dropPoint));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint, bool faceDown, bool tapped)
|
void TableZone::handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint)
|
||||||
{
|
{
|
||||||
QList<CardToMove *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardToMove(dragItems[i]->getId(), startZone->getName() == name ? QString() : dragItems[i]->getItem()->getInfo()->getPowTough(), tapped));
|
idList.append(new CardToMove(dragItems[i]->getId(), dragItems[i]->getFaceDown(), startZone->getName() == name ? QString() : dragItems[i]->getItem()->getInfo()->getPowTough()));
|
||||||
|
|
||||||
startZone->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), gridPoint.x(), gridPoint.y(), faceDown));
|
startZone->getPlayer()->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), gridPoint.x(), gridPoint.y()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TableZone::reorganizeCards()
|
void TableZone::reorganizeCards()
|
||||||
|
|
|
@ -29,8 +29,8 @@ public:
|
||||||
QRectF boundingRect() const;
|
QRectF boundingRect() const;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
void toggleTapped();
|
void toggleTapped();
|
||||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown = false);
|
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||||
void handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint, bool faceDown = false, bool tapped = false);
|
void handleDropEventByGrid(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &gridPoint);
|
||||||
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
CardItem *getCardFromGrid(const QPoint &gridPoint) const;
|
||||||
CardItem *getCardFromCoords(const QPointF &point) const;
|
CardItem *getCardFromCoords(const QPointF &point) const;
|
||||||
QPointF mapFromGrid(QPoint gridPoint) const;
|
QPointF mapFromGrid(QPoint gridPoint) const;
|
||||||
|
|
|
@ -124,13 +124,13 @@ void ZoneViewZone::addCardImpl(CardItem *card, int x, int /*y*/)
|
||||||
card->update();
|
card->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/, bool /*faceDown*/)
|
void ZoneViewZone::handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &/*dropPoint*/)
|
||||||
{
|
{
|
||||||
QList<CardToMove *> idList;
|
QList<CardToMove *> idList;
|
||||||
for (int i = 0; i < dragItems.size(); ++i)
|
for (int i = 0; i < dragItems.size(); ++i)
|
||||||
idList.append(new CardToMove(dragItems[i]->getId()));
|
idList.append(new CardToMove(dragItems[i]->getId()));
|
||||||
|
|
||||||
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0, false));
|
player->sendGameCommand(new Command_MoveCard(-1, startZone->getName(), idList, player->getId(), getName(), 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ZoneViewZone::removeCard(int position)
|
void ZoneViewZone::removeCard(int position)
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ZoneViewZone : public SelectZone, public QGraphicsLayoutItem {
|
||||||
private:
|
private:
|
||||||
QRectF bRect, optimumRect;
|
QRectF bRect, optimumRect;
|
||||||
int minRows, numberCards;
|
int minRows, numberCards;
|
||||||
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint, bool faceDown);
|
void handleDropEvent(const QList<CardDragItem *> &dragItems, CardZone *startZone, const QPoint &dropPoint);
|
||||||
CardZone *origZone;
|
CardZone *origZone;
|
||||||
bool revealZone;
|
bool revealZone;
|
||||||
bool sortByName, sortByType;
|
bool sortByName, sortByType;
|
||||||
|
|
|
@ -230,7 +230,7 @@ QList<MoveCardToZone *> Command_SetSideboardPlan::getMoveList() const
|
||||||
return typecastItemList<MoveCardToZone *>();
|
return typecastItemList<MoveCardToZone *>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayerId, const QString &_targetZone, int _x, int _y, bool _faceDown)
|
Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayerId, const QString &_targetZone, int _x, int _y)
|
||||||
: GameCommand("move_card", _gameId)
|
: GameCommand("move_card", _gameId)
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_String("start_zone", _startZone));
|
insertItem(new SerializableItem_String("start_zone", _startZone));
|
||||||
|
@ -238,7 +238,6 @@ Command_MoveCard::Command_MoveCard(int _gameId, const QString &_startZone, const
|
||||||
insertItem(new SerializableItem_String("target_zone", _targetZone));
|
insertItem(new SerializableItem_String("target_zone", _targetZone));
|
||||||
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));
|
|
||||||
|
|
||||||
for (int i = 0; i < _cards.size(); ++i)
|
for (int i = 0; i < _cards.size(); ++i)
|
||||||
itemList.append(_cards[i]);
|
itemList.append(_cards[i]);
|
||||||
|
|
|
@ -236,14 +236,13 @@ 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(), const QList<CardToMove *> &_cards = QList<CardToMove *>(), int _targetPlayerId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1, bool _faceDown = false);
|
Command_MoveCard(int _gameId = -1, const QString &_startZone = QString(), const QList<CardToMove *> &_cards = QList<CardToMove *>(), int _targetPlayerId = -1, const QString &_targetZone = QString(), int _x = -1, int _y = -1);
|
||||||
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(); }
|
||||||
QList<CardToMove *> getCards() const { return typecastItemList<CardToMove *>(); }
|
QList<CardToMove *> getCards() const { return typecastItemList<CardToMove *>(); }
|
||||||
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_id"))->getData(); }
|
int getTargetPlayerId() const { return static_cast<SerializableItem_Int *>(itemMap.value("target_player_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(); }
|
|
||||||
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; }
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,10 +3,11 @@
|
||||||
#include <QXmlStreamReader>
|
#include <QXmlStreamReader>
|
||||||
#include <QXmlStreamWriter>
|
#include <QXmlStreamWriter>
|
||||||
|
|
||||||
CardToMove::CardToMove(int _cardId, const QString &_pt, bool _tapped)
|
CardToMove::CardToMove(int _cardId, bool _faceDown, const QString &_pt, bool _tapped)
|
||||||
: SerializableItem_Map("card_to_move")
|
: SerializableItem_Map("card_to_move")
|
||||||
{
|
{
|
||||||
insertItem(new SerializableItem_Int("card_id", _cardId));
|
insertItem(new SerializableItem_Int("card_id", _cardId));
|
||||||
|
insertItem(new SerializableItem_Bool("facedown", _faceDown));
|
||||||
insertItem(new SerializableItem_String("pt", _pt));
|
insertItem(new SerializableItem_String("pt", _pt));
|
||||||
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
insertItem(new SerializableItem_Bool("tapped", _tapped));
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,9 +22,10 @@ enum ZoneType { PrivateZone, PublicZone, HiddenZone };
|
||||||
|
|
||||||
class CardToMove : public SerializableItem_Map {
|
class CardToMove : public SerializableItem_Map {
|
||||||
public:
|
public:
|
||||||
CardToMove(int _cardId = -1, const QString &_pt = QString(), bool _tapped = false);
|
CardToMove(int _cardId = -1, bool _faceDown = false, const QString &_pt = QString(), bool _tapped = false);
|
||||||
static SerializableItem *newItem() { return new CardToMove; }
|
static SerializableItem *newItem() { return new CardToMove; }
|
||||||
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(); }
|
||||||
|
bool getFaceDown() const { return static_cast<SerializableItem_Bool *>(itemMap.value("facedown"))->getData(); }
|
||||||
QString getPT() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); }
|
QString getPT() const { return static_cast<SerializableItem_String *>(itemMap.value("pt"))->getData(); }
|
||||||
bool getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); }
|
bool getTapped() const { return static_cast<SerializableItem_Bool *>(itemMap.value("tapped"))->getData(); }
|
||||||
};
|
};
|
||||||
|
|
|
@ -278,12 +278,12 @@ ResponseCode Server_Player::undoDraw(CommandContainer *cont)
|
||||||
|
|
||||||
ResponseCode retVal;
|
ResponseCode retVal;
|
||||||
CardToMove *cardToMove = new CardToMove(lastDrawList.takeLast());
|
CardToMove *cardToMove = new CardToMove(lastDrawList.takeLast());
|
||||||
retVal = moveCard(cont, zones.value("hand"), QList<CardToMove *>() << cardToMove, zones.value("deck"), 0, 0, false, false, true);
|
retVal = moveCard(cont, zones.value("hand"), QList<CardToMove *>() << cardToMove, zones.value("deck"), 0, 0, false, true);
|
||||||
delete cardToMove;
|
delete cardToMove;
|
||||||
return retVal;
|
return retVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_startZone, const QList<CardToMove *> &_cards, int targetPlayerId, const QString &_targetZone, int x, int y, bool faceDown)
|
ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_startZone, const QList<CardToMove *> &_cards, int targetPlayerId, const QString &_targetZone, int x, int y)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&game->gameMutex);
|
QMutexLocker locker(&game->gameMutex);
|
||||||
|
|
||||||
|
@ -295,7 +295,7 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, const QString &_sta
|
||||||
if ((!startzone) || (!targetzone))
|
if ((!startzone) || (!targetzone))
|
||||||
return RespNameNotFound;
|
return RespNameNotFound;
|
||||||
|
|
||||||
return moveCard(cont, startzone, _cards, targetzone, x, y, faceDown);
|
return moveCard(cont, startzone, _cards, targetzone, x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
class Server_Player::MoveCardCompareFunctor {
|
class Server_Player::MoveCardCompareFunctor {
|
||||||
|
@ -319,7 +319,7 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool faceDown, bool fixFreeSpaces, bool undoingDraw)
|
ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool fixFreeSpaces, bool undoingDraw)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&game->gameMutex);
|
QMutexLocker locker(&game->gameMutex);
|
||||||
|
|
||||||
|
@ -417,8 +417,8 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
bool targetBeingLookedAt = (targetzone->getType() != HiddenZone) || (targetzone->getCardsBeingLookedAt() > newX) || (targetzone->getCardsBeingLookedAt() == -1);
|
bool targetBeingLookedAt = (targetzone->getType() != HiddenZone) || (targetzone->getCardsBeingLookedAt() > newX) || (targetzone->getCardsBeingLookedAt() == -1);
|
||||||
bool sourceBeingLookedAt = (startzone->getType() != HiddenZone) || (startzone->getCardsBeingLookedAt() > position) || (startzone->getCardsBeingLookedAt() == -1);
|
bool sourceBeingLookedAt = (startzone->getType() != HiddenZone) || (startzone->getCardsBeingLookedAt() > position) || (startzone->getCardsBeingLookedAt() == -1);
|
||||||
|
|
||||||
bool targetHiddenToPlayer = faceDown || !targetBeingLookedAt;
|
bool targetHiddenToPlayer = thisCardProperties->getFaceDown() || !targetBeingLookedAt;
|
||||||
bool targetHiddenToOthers = faceDown || (targetzone->getType() != PublicZone);
|
bool targetHiddenToOthers = thisCardProperties->getFaceDown() || (targetzone->getType() != PublicZone);
|
||||||
bool sourceHiddenToPlayer = card->getFaceDown() || !sourceBeingLookedAt;
|
bool sourceHiddenToPlayer = card->getFaceDown() || !sourceBeingLookedAt;
|
||||||
bool sourceHiddenToOthers = card->getFaceDown() || (startzone->getType() != PublicZone);
|
bool sourceHiddenToOthers = card->getFaceDown() || (startzone->getType() != PublicZone);
|
||||||
|
|
||||||
|
@ -429,9 +429,9 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
publicCardName = card->getName();
|
publicCardName = card->getName();
|
||||||
|
|
||||||
int oldCardId = card->getId();
|
int oldCardId = card->getId();
|
||||||
if (faceDown || (targetzone->getPlayer() != startzone->getPlayer()))
|
if (thisCardProperties->getFaceDown() || (targetzone->getPlayer() != startzone->getPlayer()))
|
||||||
card->setId(targetzone->getPlayer()->newCardId());
|
card->setId(targetzone->getPlayer()->newCardId());
|
||||||
card->setFaceDown(faceDown);
|
card->setFaceDown(thisCardProperties->getFaceDown());
|
||||||
|
|
||||||
// The player does not get to see which card he moved if it moves between two parts of hidden zones which
|
// The player does not get to see which card he moved if it moves between two parts of hidden zones which
|
||||||
// are not being looked at.
|
// are not being looked at.
|
||||||
|
@ -445,8 +445,8 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
int privatePosition = -1;
|
int privatePosition = -1;
|
||||||
if (startzone->getType() == HiddenZone)
|
if (startzone->getType() == HiddenZone)
|
||||||
privatePosition = position;
|
privatePosition = position;
|
||||||
cont->enqueueGameEventPrivate(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, faceDown), game->getGameId(), -1, undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
cont->enqueueGameEventPrivate(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, thisCardProperties->getFaceDown()), game->getGameId(), -1, undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
cont->enqueueGameEventOmniscient(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, faceDown), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
cont->enqueueGameEventOmniscient(new Event_MoveCard(getPlayerId(), privateOldCardId, privateCardName, startzone->getName(), privatePosition, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, privateNewCardId, thisCardProperties->getFaceDown()), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
|
|
||||||
// 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,
|
||||||
|
@ -460,13 +460,13 @@ ResponseCode Server_Player::moveCard(CommandContainer *cont, Server_CardZone *st
|
||||||
newX = -1;
|
newX = -1;
|
||||||
|
|
||||||
if ((startzone->getType() == PublicZone) || (targetzone->getType() == PublicZone))
|
if ((startzone->getType() == PublicZone) || (targetzone->getType() == PublicZone))
|
||||||
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), oldCardId, publicCardName, startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, card->getId(), faceDown), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), oldCardId, publicCardName, startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, card->getId(), thisCardProperties->getFaceDown()), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
else
|
else
|
||||||
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), -1, QString(), startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, -1, false), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
cont->enqueueGameEventPublic(new Event_MoveCard(getPlayerId(), -1, QString(), startzone->getName(), position, targetzone->getPlayer()->getPlayerId(), targetzone->getName(), newX, y, -1, false), game->getGameId(), undoingDraw ? static_cast<GameEventContext *>(new Context_UndoDraw) : static_cast<GameEventContext *>(new Context_MoveCard));
|
||||||
|
|
||||||
if (thisCardProperties->getTapped())
|
if (thisCardProperties->getTapped())
|
||||||
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "tapped", "1");
|
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "tapped", "1");
|
||||||
if (!thisCardProperties->getPT().isEmpty() && !faceDown)
|
if (!thisCardProperties->getPT().isEmpty() && !thisCardProperties->getFaceDown())
|
||||||
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "pt", thisCardProperties->getPT());
|
setCardAttrHelper(cont, targetzone->getName(), card->getId(), "pt", thisCardProperties->getPT());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,8 @@ public:
|
||||||
|
|
||||||
ResponseCode drawCards(CommandContainer *cont, int number);
|
ResponseCode drawCards(CommandContainer *cont, int number);
|
||||||
ResponseCode undoDraw(CommandContainer *cont);
|
ResponseCode undoDraw(CommandContainer *cont);
|
||||||
ResponseCode moveCard(CommandContainer *cont, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayer, const QString &_targetZone, int _x, int _y, bool _faceDown);
|
ResponseCode moveCard(CommandContainer *cont, const QString &_startZone, const QList<CardToMove *> &_cards, int _targetPlayer, const QString &_targetZone, int _x, int _y);
|
||||||
ResponseCode moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool faceDown, bool fixFreeSpaces = true, bool undoingDraw = false);
|
ResponseCode moveCard(CommandContainer *cont, Server_CardZone *startzone, const QList<CardToMove *> &_cards, Server_CardZone *targetzone, int x, int y, bool fixFreeSpaces = true, bool undoingDraw = false);
|
||||||
void unattachCard(CommandContainer *cont, Server_Card *card);
|
void unattachCard(CommandContainer *cont, Server_Card *card);
|
||||||
ResponseCode setCardAttrHelper(CommandContainer *cont, const QString &zone, int cardId, const QString &attrName, const QString &attrValue);
|
ResponseCode setCardAttrHelper(CommandContainer *cont, const QString &zone, int cardId, const QString &attrName, const QString &attrValue);
|
||||||
|
|
||||||
|
|
|
@ -762,7 +762,7 @@ ResponseCode Server_ProtocolHandler::cmdMoveCard(Command_MoveCard *cmd, CommandC
|
||||||
if (player->getConceded())
|
if (player->getConceded())
|
||||||
return RespContextError;
|
return RespContextError;
|
||||||
|
|
||||||
return player->moveCard(cont, cmd->getStartZone(), cmd->getCards(), cmd->getTargetPlayerId(), cmd->getTargetZone(), cmd->getX(), cmd->getY(), cmd->getFaceDown());
|
return player->moveCard(cont, cmd->getStartZone(), cmd->getCards(), cmd->getTargetPlayerId(), cmd->getTargetZone(), cmd->getX(), cmd->getY());
|
||||||
}
|
}
|
||||||
|
|
||||||
ResponseCode Server_ProtocolHandler::cmdFlipCard(Command_FlipCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
ResponseCode Server_ProtocolHandler::cmdFlipCard(Command_FlipCard *cmd, CommandContainer *cont, Server_Game *game, Server_Player *player)
|
||||||
|
|
Loading…
Reference in a new issue