diff --git a/cockatrice/src/game.cpp b/cockatrice/src/game.cpp index 437e02e1..25686862 100644 --- a/cockatrice/src/game.cpp +++ b/cockatrice/src/game.cpp @@ -144,7 +144,7 @@ void Game::initSayMenu() Player *Game::addPlayer(int playerId, const QString &playerName, QPointF base, bool local) { - Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene); + Player *newPlayer = new Player(playerName, playerId, base, local, db, client, scene, this); connect(newPlayer, SIGNAL(hoverCard(QString)), this, SIGNAL(hoverCard(QString))); connect(newPlayer, SIGNAL(sigShowCardMenu(QPoint)), this, SLOT(showCardMenu(QPoint))); @@ -346,7 +346,8 @@ void Game::actTap() QListIterator i(scene->selectedItems()); while (i.hasNext()) { CardItem *temp = (CardItem *) i.next(); - client->setCardAttr(qgraphicsitem_cast(temp->parentItem())->getName(), temp->getId(), "tapped", "1"); + if (!temp->getTapped()) + client->setCardAttr(qgraphicsitem_cast(temp->parentItem())->getName(), temp->getId(), "tapped", "1"); } } @@ -355,7 +356,8 @@ void Game::actUntap() QListIterator i(scene->selectedItems()); while (i.hasNext()) { CardItem *temp = (CardItem *) i.next(); - client->setCardAttr(qgraphicsitem_cast(temp->parentItem())->getName(), temp->getId(), "tapped", "0"); + if (temp->getTapped()) + client->setCardAttr(qgraphicsitem_cast(temp->parentItem())->getName(), temp->getId(), "tapped", "0"); } } diff --git a/cockatrice/src/game.h b/cockatrice/src/game.h index 66d675bd..f244d15d 100644 --- a/cockatrice/src/game.h +++ b/cockatrice/src/game.h @@ -40,8 +40,6 @@ private slots: void actEditMessages(); void showCardMenu(QPoint p); - void actTap(); - void actUntap(); void actDoesntUntap(); void actFlip(); void actAddCounter(); @@ -54,6 +52,9 @@ private slots: void gameEvent(const ServerEventData &msg); void playerListReceived(QList playerList); void readyStart(); +public slots: + void actTap(); + void actUntap(); signals: void submitDecklist(); void hoverCard(QString name); diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index 8cd365bd..d7aa4eda 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -4,11 +4,12 @@ #include "playerarea.h" #include "counter.h" #include "zoneviewzone.h" +#include "game.h" #include #include -Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene) - : QObject(), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client) +Player::Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent) + : QObject(_parent), defaultNumberTopCards(3), name(_name), id(_id), base(_base), local(_local), db(_db), client(_client) { area = new PlayerArea(this); area->setPos(_base); diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index 77029fab..760ccf1b 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -12,6 +12,7 @@ class QMenu; class QAction; class PlayerArea; class ZoneViewZone; +class Game; class Player : public QObject { Q_OBJECT @@ -57,7 +58,7 @@ public: PlayerArea *area; Client *client; void addZone(CardZone *z); - Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene); + Player(const QString &_name, int _id, QPointF _base, bool _local, CardDatabase *_db, Client *_client, QGraphicsScene *_scene, Game *_parent); ~Player(); QMenu *getPlayerMenu() const { return playerMenu; } int getId() const { return id; } diff --git a/cockatrice/src/tablezone.cpp b/cockatrice/src/tablezone.cpp index 99d549a7..49f5636a 100644 --- a/cockatrice/src/tablezone.cpp +++ b/cockatrice/src/tablezone.cpp @@ -55,9 +55,15 @@ void TableZone::reorganizeCards() void TableZone::toggleTapped() { - QListIterator i(scene()->selectedItems()); - while (i.hasNext()) { - CardItem *temp = (CardItem *) i.next(); - setCardAttr(temp->getId(), "tapped", temp->getTapped() ? "0" : "1"); + QList selectedItems = scene()->selectedItems(); + bool tapAll = false; + for (int i = 0; i < selectedItems.size(); i++) + if (!qgraphicsitem_cast(selectedItems[i])->getTapped()) { + tapAll = true; + break; + } + for (int i = 0; i < selectedItems.size(); i++) { + CardItem *temp = qgraphicsitem_cast(selectedItems[i]); + setCardAttr(temp->getId(), "tapped", (!temp->getTapped() || tapAll) ? "1" : "0"); } }