added peeking at facedown cards, fixing issue #7
This commit is contained in:
parent
662df6d972
commit
5ff1fd8ec6
12 changed files with 134 additions and 76 deletions
|
@ -11,8 +11,8 @@
|
|||
#include "gamescene.h"
|
||||
#include <QDebug>
|
||||
|
||||
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, QGraphicsItem *parent)
|
||||
: ArrowTarget(_owner, parent), infoWidget(0), name(_name), tapped(false), tapAngle(0), isHovered(false), realZValue(0)
|
||||
AbstractCardItem::AbstractCardItem(const QString &_name, Player *_owner, int _id, QGraphicsItem *parent)
|
||||
: ArrowTarget(_owner, parent), infoWidget(0), id(_id), name(_name), tapped(false), facedown(false), tapAngle(0), isHovered(false), realZValue(0)
|
||||
{
|
||||
setCursor(Qt::OpenHandCursor);
|
||||
setFlag(ItemIsSelectable);
|
||||
|
@ -86,7 +86,8 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
{
|
||||
qreal scaleFactor = translatedSize.width() / boundingRect().width();
|
||||
|
||||
QPixmap *translatedPixmap = info->getPixmap(translatedSize.toSize());
|
||||
CardInfo *imageSource = facedown ? db->getCard() : info;
|
||||
QPixmap *translatedPixmap = imageSource->getPixmap(translatedSize.toSize());
|
||||
painter->save();
|
||||
QColor bgColor = Qt::transparent;
|
||||
if (translatedPixmap) {
|
||||
|
@ -124,13 +125,18 @@ void AbstractCardItem::paintPicture(QPainter *painter, const QSizeF &translatedS
|
|||
painter->setPen(pen);
|
||||
painter->drawRect(QRectF(1, 1, CARD_WIDTH - 2, CARD_HEIGHT - 2));
|
||||
|
||||
if (!translatedPixmap || settingsCache->getDisplayCardNames()) {
|
||||
if (!translatedPixmap || settingsCache->getDisplayCardNames() || facedown) {
|
||||
painter->save();
|
||||
transformPainter(painter, translatedSize, angle);
|
||||
painter->setPen(Qt::white);
|
||||
painter->setBackground(Qt::black);
|
||||
painter->setBackgroundMode(Qt::OpaqueMode);
|
||||
painter->drawText(QRectF(3 * scaleFactor, 3 * scaleFactor, translatedSize.width() - 6 * scaleFactor, translatedSize.height() - 6 * scaleFactor), Qt::AlignTop | Qt::AlignLeft | Qt::TextWrapAnywhere, name);
|
||||
QString nameStr;
|
||||
if (facedown)
|
||||
nameStr = "# " + QString::number(id);
|
||||
else
|
||||
nameStr = name;
|
||||
painter->drawText(QRectF(3 * scaleFactor, 3 * scaleFactor, translatedSize.width() - 6 * scaleFactor, translatedSize.height() - 6 * scaleFactor), Qt::AlignTop | Qt::AlignLeft | Qt::TextWrapAnywhere, nameStr);
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
|
@ -205,6 +211,13 @@ void AbstractCardItem::setTapped(bool _tapped, bool canAnimate)
|
|||
}
|
||||
}
|
||||
|
||||
void AbstractCardItem::setFaceDown(bool _facedown)
|
||||
{
|
||||
facedown = _facedown;
|
||||
update();
|
||||
emit updateCardMenu(this);
|
||||
}
|
||||
|
||||
void AbstractCardItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (!isSelected()) {
|
||||
|
|
|
@ -16,8 +16,10 @@ class AbstractCardItem : public ArrowTarget {
|
|||
protected:
|
||||
CardInfo *info;
|
||||
CardInfoWidget *infoWidget;
|
||||
int id;
|
||||
QString name;
|
||||
bool tapped;
|
||||
bool facedown;
|
||||
int tapAngle;
|
||||
QString color;
|
||||
private:
|
||||
|
@ -31,17 +33,19 @@ signals:
|
|||
void hovered(AbstractCardItem *card);
|
||||
void showCardInfoPopup(QPoint pos, QString cardName);
|
||||
void deleteCardInfoPopup(QString cardName);
|
||||
void updateCardMenu(AbstractCardItem *card, QMenu *cardMenu, QMenu *ptMenu, QMenu *moveMenu);
|
||||
void updateCardMenu(AbstractCardItem *card);
|
||||
public:
|
||||
enum { Type = typeCard };
|
||||
int type() const { return Type; }
|
||||
AbstractCardItem(const QString &_name = QString(), Player *_owner = 0, QGraphicsItem *parent = 0);
|
||||
AbstractCardItem(const QString &_name = QString(), Player *_owner = 0, int _id = -1, QGraphicsItem *parent = 0);
|
||||
~AbstractCardItem();
|
||||
QRectF boundingRect() const;
|
||||
QSizeF getTranslatedSize(QPainter *painter) const;
|
||||
void paintPicture(QPainter *painter, const QSizeF &translatedSize, int angle);
|
||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||
CardInfo *getInfo() const { return info; }
|
||||
int getId() const { return id; }
|
||||
void setId(int _id) { id = _id; }
|
||||
QString getName() const { return name; }
|
||||
void setName(const QString &_name = QString());
|
||||
qreal getRealZValue() const { return realZValue; }
|
||||
|
@ -51,6 +55,8 @@ public:
|
|||
void setColor(const QString &_color);
|
||||
bool getTapped() const { return tapped; }
|
||||
void setTapped(bool _tapped, bool canAnimate = false);
|
||||
bool getFaceDown() const { return facedown; }
|
||||
void setFaceDown(bool _facedown);
|
||||
void processHoverEvent();
|
||||
void deleteCardInfoPopup() { emit deleteCardInfoPopup(name); }
|
||||
protected:
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "pb/serverinfo_card.pb.h"
|
||||
|
||||
CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _revealedCard, QGraphicsItem *parent)
|
||||
: AbstractCardItem(_name, _owner, parent), zone(0), id(_cardid), revealedCard(_revealedCard), attacking(false), facedown(false), destroyOnZoneChange(false), doesntUntap(false), dragItem(0), attachedTo(0)
|
||||
: AbstractCardItem(_name, _owner, _cardid, parent), zone(0), revealedCard(_revealedCard), attacking(false), destroyOnZoneChange(false), doesntUntap(false), dragItem(0), attachedTo(0)
|
||||
{
|
||||
owner->addCard(this);
|
||||
|
||||
|
@ -27,7 +27,7 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _reve
|
|||
moveMenu = new QMenu;
|
||||
|
||||
retranslateUi();
|
||||
emit updateCardMenu(this, cardMenu, ptMenu, moveMenu);
|
||||
emit updateCardMenu(this);
|
||||
}
|
||||
|
||||
CardItem::~CardItem()
|
||||
|
@ -74,7 +74,7 @@ void CardItem::deleteLater()
|
|||
void CardItem::setZone(CardZone *_zone)
|
||||
{
|
||||
zone = _zone;
|
||||
emit updateCardMenu(this, cardMenu, ptMenu, moveMenu);
|
||||
emit updateCardMenu(this);
|
||||
}
|
||||
|
||||
void CardItem::retranslateUi()
|
||||
|
@ -135,14 +135,6 @@ void CardItem::setAttacking(bool _attacking)
|
|||
update();
|
||||
}
|
||||
|
||||
void CardItem::setFaceDown(bool _facedown)
|
||||
{
|
||||
facedown = _facedown;
|
||||
if (facedown)
|
||||
setName(QString());
|
||||
update();
|
||||
}
|
||||
|
||||
void CardItem::setCounter(int _id, int _value)
|
||||
{
|
||||
if (_value)
|
||||
|
@ -187,7 +179,7 @@ void CardItem::setAttachedTo(CardItem *_attachedTo)
|
|||
if (zone)
|
||||
zone->reorganizeCards();
|
||||
|
||||
emit updateCardMenu(this, cardMenu, ptMenu, moveMenu);
|
||||
emit updateCardMenu(this);
|
||||
}
|
||||
|
||||
void CardItem::resetState()
|
||||
|
|
|
@ -17,10 +17,8 @@ class CardItem : public AbstractCardItem {
|
|||
Q_OBJECT
|
||||
private:
|
||||
CardZone *zone;
|
||||
int id;
|
||||
bool revealedCard;
|
||||
bool attacking;
|
||||
bool facedown;
|
||||
QMap<int, int> counters;
|
||||
QString annotation;
|
||||
QString pt;
|
||||
|
@ -50,13 +48,9 @@ public:
|
|||
QPoint getGridPos() const { return gridPoint; }
|
||||
Player *getOwner() const { return owner; }
|
||||
void setOwner(Player *_owner) { owner = _owner; }
|
||||
int getId() const { return id; }
|
||||
void setId(int _id) { id = _id; }
|
||||
bool getRevealedCard() const { return revealedCard; }
|
||||
bool getAttacking() const { return attacking; }
|
||||
void setAttacking(bool _attacking);
|
||||
bool getFaceDown() const { return facedown; }
|
||||
void setFaceDown(bool _facedown);
|
||||
const QMap<int, int> &getCounters() const { return counters; }
|
||||
void setCounter(int _id, int _value);
|
||||
QString getAnnotation() const { return annotation; }
|
||||
|
@ -75,6 +69,10 @@ public:
|
|||
void resetState();
|
||||
void processCardInfo(const ServerInfo_Card &info);
|
||||
|
||||
QMenu *getCardMenu() const { return cardMenu; }
|
||||
QMenu *getPTMenu() const { return ptMenu; }
|
||||
QMenu *getMoveMenu() const { return moveMenu; }
|
||||
|
||||
bool animationEvent();
|
||||
CardDragItem *createDragItem(int _id, const QPointF &_pos, const QPointF &_scenePos, bool faceDown);
|
||||
void deleteDragItem();
|
||||
|
|
|
@ -62,7 +62,7 @@ void DeckViewCardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
}
|
||||
|
||||
DeckViewCard::DeckViewCard(const QString &_name, const QString &_originZone, QGraphicsItem *parent)
|
||||
: AbstractCardItem(_name, 0, parent), originZone(_originZone), dragItem(0)
|
||||
: AbstractCardItem(_name, 0, -1, parent), originZone(_originZone), dragItem(0)
|
||||
{
|
||||
setAcceptsHoverEvents(true);
|
||||
}
|
||||
|
|
|
@ -644,7 +644,7 @@ void MessageLogWidget::logStopDumpZone(Player *player, CardZone *zone)
|
|||
appendHtml(tr("%1 stops looking at %2.", "male").arg(sanitizeHtml(player->getName())).arg(zoneName));
|
||||
}
|
||||
|
||||
void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer)
|
||||
void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown)
|
||||
{
|
||||
QPair<QString, QString> temp = getFromStr(zone, cardName, cardId, false);
|
||||
bool cardNameContainsStartZone = false;
|
||||
|
@ -704,7 +704,21 @@ void MessageLogWidget::logRevealCards(Player *player, CardZone *zone, int cardId
|
|||
appendHtml(tr("%1 randomly reveals %2%3.", "male").arg(sanitizeHtml(player->getName())).arg(cardStr).arg(fromStr));
|
||||
}
|
||||
} else {
|
||||
if (otherPlayer) {
|
||||
if (faceDown && (player == otherPlayer)) {
|
||||
if (cardName.isEmpty()) {
|
||||
if (isFemale(player))
|
||||
str = tr("%1 peeks at face down card #%2.", "female");
|
||||
else
|
||||
str = tr("%1 peeks at face down card #%2.", "male");
|
||||
appendHtml(str.arg(sanitizeHtml(player->getName())).arg(cardId));
|
||||
} else {
|
||||
if (isFemale(player))
|
||||
str = tr("%1 peeks at face down card #%2: %3.", "female");
|
||||
else
|
||||
str = tr("%1 peeks at face down card #%2: %3.", "male");
|
||||
appendHtml(str.arg(sanitizeHtml(player->getName())).arg(cardId).arg(cardStr));
|
||||
}
|
||||
} else if (otherPlayer) {
|
||||
if (isFemale(player)) {
|
||||
if (isFemale(otherPlayer))
|
||||
str = tr("%1 reveals %2%3 to %4.", "p1 female, p2 female");
|
||||
|
@ -809,7 +823,7 @@ void MessageLogWidget::connectToPlayer(Player *player)
|
|||
connect(player, SIGNAL(logStopDumpZone(Player *, CardZone *)), this, SLOT(logStopDumpZone(Player *, CardZone *)));
|
||||
connect(player, SIGNAL(logDrawCards(Player *, int)), this, SLOT(logDrawCards(Player *, int)));
|
||||
connect(player, SIGNAL(logUndoDraw(Player *, QString)), this, SLOT(logUndoDraw(Player *, QString)));
|
||||
connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *)), this, SLOT(logRevealCards(Player *, CardZone *, int, QString, Player *)));
|
||||
connect(player, SIGNAL(logRevealCards(Player *, CardZone *, int, QString, Player *, bool)), this, SLOT(logRevealCards(Player *, CardZone *, int, QString, Player *, bool)));
|
||||
}
|
||||
|
||||
MessageLogWidget::MessageLogWidget(const QString &_ownName, bool _female, QWidget *parent)
|
||||
|
|
|
@ -75,7 +75,7 @@ public slots:
|
|||
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
|
||||
void logSetActivePlayer(Player *player);
|
||||
void logSetActivePhase(int phase);
|
||||
void containerProcessingStarted(const GameEventContext &context);
|
||||
|
|
|
@ -323,13 +323,13 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
}
|
||||
|
||||
aTap = new QAction(this);
|
||||
aTap->setData(0);
|
||||
aTap->setData(cmTap);
|
||||
connect(aTap, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
aUntap = new QAction(this);
|
||||
aUntap->setData(1);
|
||||
aUntap->setData(cmUntap);
|
||||
connect(aUntap, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
aDoesntUntap = new QAction(this);
|
||||
aDoesntUntap->setData(2);
|
||||
aDoesntUntap->setData(cmDoesntUntap);
|
||||
connect(aDoesntUntap, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
aAttach = new QAction(this);
|
||||
connect(aAttach, SIGNAL(triggered()), this, SLOT(actAttach()));
|
||||
|
@ -354,19 +354,22 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare
|
|||
aSetAnnotation = new QAction(this);
|
||||
connect(aSetAnnotation, SIGNAL(triggered()), this, SLOT(actSetAnnotation()));
|
||||
aFlip = new QAction(this);
|
||||
aFlip->setData(3);
|
||||
aFlip->setData(cmFlip);
|
||||
connect(aFlip, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
aPeek = new QAction(this);
|
||||
aPeek->setData(cmPeek);
|
||||
connect(aPeek, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
aClone = new QAction(this);
|
||||
aClone->setData(4);
|
||||
aClone->setData(cmClone);
|
||||
connect(aClone, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
aMoveToTopLibrary = new QAction(this);
|
||||
aMoveToTopLibrary->setData(5);
|
||||
aMoveToTopLibrary->setData(cmMoveToTopLibrary);
|
||||
aMoveToBottomLibrary = new QAction(this);
|
||||
aMoveToBottomLibrary->setData(6);
|
||||
aMoveToBottomLibrary->setData(cmMoveToBottomLibrary);
|
||||
aMoveToGraveyard = new QAction(this);
|
||||
aMoveToGraveyard->setData(7);
|
||||
aMoveToGraveyard->setData(cmMoveToGraveyard);
|
||||
aMoveToExile = new QAction(this);
|
||||
aMoveToExile->setData(8);
|
||||
aMoveToExile->setData(cmMoveToExile);
|
||||
connect(aMoveToTopLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
connect(aMoveToBottomLibrary, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
connect(aMoveToGraveyard, SIGNAL(triggered()), this, SLOT(cardMenuAction()));
|
||||
|
@ -608,6 +611,7 @@ void Player::retranslateUi()
|
|||
aUntap->setText(tr("&Untap"));
|
||||
aDoesntUntap->setText(tr("Toggle &normal untapping"));
|
||||
aFlip->setText(tr("&Flip"));
|
||||
aPeek->setText(tr("&Peek at card face"));
|
||||
aClone->setText(tr("&Clone"));
|
||||
aClone->setShortcut(tr("Ctrl+H"));
|
||||
aAttach->setText(tr("&Attach to card..."));
|
||||
|
@ -1094,6 +1098,7 @@ void Player::eventMoveCard(const Event_MoveCard &event, const GameEventContext &
|
|||
return;
|
||||
if (startZone != targetZone)
|
||||
card->deleteCardInfoPopup();
|
||||
if (event.has_card_name())
|
||||
card->setName(QString::fromStdString(event.card_name()));
|
||||
|
||||
if (card->getAttachedTo() && (startZone != targetZone)) {
|
||||
|
@ -1256,19 +1261,34 @@ void Player::eventRevealCards(const Event_RevealCards &event)
|
|||
return;
|
||||
}
|
||||
|
||||
bool peeking = false;
|
||||
QList<const ServerInfo_Card *> cardList;
|
||||
const int cardListSize = event.cards_size();
|
||||
for (int i = 0; i < cardListSize; ++i) {
|
||||
const ServerInfo_Card *temp = &event.cards(i);
|
||||
if (temp->face_down())
|
||||
peeking = true;
|
||||
cardList.append(temp);
|
||||
}
|
||||
|
||||
if (peeking) {
|
||||
for (int i = 0; i < cardList.size(); ++i) {
|
||||
QString cardName = QString::fromStdString(cardList.at(i)->name());
|
||||
CardItem *card = zone->getCard(cardList.at(i)->id(), QString());
|
||||
if (!card)
|
||||
continue;
|
||||
card->setName(cardName);
|
||||
emit logRevealCards(this, zone, cardList.at(i)->id(), cardName, this, true);
|
||||
}
|
||||
} else {
|
||||
if (!cardList.isEmpty())
|
||||
static_cast<GameScene *>(scene())->addRevealedZoneView(this, zone, cardList, event.grant_write_access());
|
||||
|
||||
QString cardName;
|
||||
if (cardList.size() == 1)
|
||||
cardName = QString::fromStdString(cardList.first()->name());
|
||||
emit logRevealCards(this, zone, event.card_id(), cardName, otherPlayer);
|
||||
emit logRevealCards(this, zone, event.card_id(), cardName, otherPlayer, false);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context)
|
||||
|
@ -1602,8 +1622,8 @@ void Player::cardMenuAction()
|
|||
if (a->data().toInt() <= 4)
|
||||
for (int i = 0; i < cardList.size(); ++i) {
|
||||
CardItem *card = cardList[i];
|
||||
switch (a->data().toInt()) {
|
||||
case 0:
|
||||
switch (static_cast<CardMenuActionType>(a->data().toInt())) {
|
||||
case cmTap:
|
||||
if (!card->getTapped()) {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
|
@ -1613,7 +1633,7 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
case cmUntap:
|
||||
if (card->getTapped()) {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
|
@ -1623,7 +1643,7 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
}
|
||||
break;
|
||||
case 2: {
|
||||
case cmDoesntUntap: {
|
||||
Command_SetCardAttr *cmd = new Command_SetCardAttr;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
|
@ -1632,7 +1652,7 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case cmFlip: {
|
||||
Command_FlipCard *cmd = new Command_FlipCard;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
|
@ -1640,7 +1660,15 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case cmPeek: {
|
||||
Command_RevealCards *cmd = new Command_RevealCards;
|
||||
cmd->set_zone_name(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_id(card->getId());
|
||||
cmd->set_player_id(id);
|
||||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case cmClone: {
|
||||
Command_CreateToken *cmd = new Command_CreateToken;
|
||||
cmd->set_zone(card->getZone()->getName().toStdString());
|
||||
cmd->set_card_name(card->getName().toStdString());
|
||||
|
@ -1662,8 +1690,8 @@ void Player::cardMenuAction()
|
|||
int startPlayerId = cardList[0]->getZone()->getPlayer()->getId();
|
||||
QString startZone = cardList[0]->getZone()->getName();
|
||||
|
||||
switch (a->data().toInt()) {
|
||||
case 5: {
|
||||
switch (static_cast<CardMenuActionType>(a->data().toInt())) {
|
||||
case cmMoveToTopLibrary: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_player_id(startPlayerId);
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
|
@ -1675,7 +1703,7 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
case cmMoveToBottomLibrary: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_player_id(startPlayerId);
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
|
@ -1687,7 +1715,7 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 7: {
|
||||
case cmMoveToGraveyard: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_player_id(startPlayerId);
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
|
@ -1699,7 +1727,7 @@ void Player::cardMenuAction()
|
|||
commandList.append(cmd);
|
||||
break;
|
||||
}
|
||||
case 8: {
|
||||
case cmMoveToExile: {
|
||||
Command_MoveCard *cmd = new Command_MoveCard;
|
||||
cmd->set_start_player_id(startPlayerId);
|
||||
cmd->set_start_zone(startZone.toStdString());
|
||||
|
@ -1924,8 +1952,12 @@ void Player::actHide()
|
|||
game->getActiveCard()->getZone()->removeCard(game->getActiveCard());
|
||||
}
|
||||
|
||||
void Player::updateCardMenu(CardItem *card, QMenu *cardMenu, QMenu *ptMenu, QMenu *moveMenu)
|
||||
void Player::updateCardMenu(CardItem *card)
|
||||
{
|
||||
QMenu *cardMenu = card->getCardMenu();
|
||||
QMenu *ptMenu = card->getPTMenu();
|
||||
QMenu *moveMenu = card->getMoveMenu();
|
||||
|
||||
cardMenu->clear();
|
||||
|
||||
bool revealedCard = false;
|
||||
|
@ -1970,6 +2002,8 @@ void Player::updateCardMenu(CardItem *card, QMenu *cardMenu, QMenu *ptMenu, QMen
|
|||
cardMenu->addAction(aUntap);
|
||||
cardMenu->addAction(aDoesntUntap);
|
||||
cardMenu->addAction(aFlip);
|
||||
if (card->getFaceDown())
|
||||
cardMenu->addAction(aPeek);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addAction(aAttach);
|
||||
if (card->getAttachedTo())
|
||||
|
|
|
@ -97,7 +97,7 @@ signals:
|
|||
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation);
|
||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
||||
void logStopDumpZone(Player *player, CardZone *zone);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer);
|
||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
|
||||
|
||||
void sizeChanged();
|
||||
void gameConceded();
|
||||
|
@ -165,7 +165,7 @@ private:
|
|||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
QAction *aPlay,
|
||||
*aHide,
|
||||
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aClone,
|
||||
*aTap, *aUntap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToGraveyard, *aMoveToExile;
|
||||
|
||||
bool shortcutsActive;
|
||||
|
@ -223,6 +223,7 @@ private:
|
|||
void eventRevealCards(const Event_RevealCards &event);
|
||||
public:
|
||||
static const int counterAreaWidth = 55;
|
||||
enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToGraveyard, cmMoveToExile };
|
||||
|
||||
enum { Type = typeOther };
|
||||
int type() const { return Type; }
|
||||
|
@ -261,7 +262,7 @@ public:
|
|||
const QMap<int, ArrowItem *> &getArrows() const { return arrows; }
|
||||
void setCardMenu(QMenu *menu);
|
||||
QMenu *getCardMenu() const;
|
||||
void updateCardMenu(CardItem *card, QMenu *cardMenu, QMenu *ptMenu, QMenu *moveMenu);
|
||||
void updateCardMenu(CardItem *card);
|
||||
bool getActive() const { return active; }
|
||||
void setActive(bool _active);
|
||||
void setShortcutsActive();
|
||||
|
|
|
@ -1065,7 +1065,7 @@ void TabGame::newCardAdded(AbstractCardItem *card)
|
|||
connect(card, SIGNAL(hovered(AbstractCardItem *)), cardInfo, SLOT(setCard(AbstractCardItem *)));
|
||||
connect(card, SIGNAL(showCardInfoPopup(QPoint, QString)), this, SLOT(showCardInfoPopup(QPoint, QString)));
|
||||
connect(card, SIGNAL(deleteCardInfoPopup(QString)), this, SLOT(deleteCardInfoPopup(QString)));
|
||||
connect(card, SIGNAL(updateCardMenu(AbstractCardItem*,QMenu*,QMenu*,QMenu*)), this, SLOT(updateCardMenu(AbstractCardItem*,QMenu*,QMenu*,QMenu*)));
|
||||
connect(card, SIGNAL(updateCardMenu(AbstractCardItem *)), this, SLOT(updateCardMenu(AbstractCardItem *)));
|
||||
}
|
||||
|
||||
CardItem *TabGame::getCard(int playerId, const QString &zoneName, int cardId) const
|
||||
|
@ -1105,16 +1105,13 @@ Player *TabGame::getActiveLocalPlayer() const
|
|||
|
||||
return 0;
|
||||
}
|
||||
#include <QDebug>
|
||||
void TabGame::updateCardMenu(AbstractCardItem *card, QMenu *cardMenu, QMenu *ptMenu, QMenu *moveMenu)
|
||||
|
||||
void TabGame::updateCardMenu(AbstractCardItem *card)
|
||||
{
|
||||
Player *p;
|
||||
if ((clients.size() > 1) || !players.contains(localPlayerId)) {
|
||||
qDebug("BUG");
|
||||
if ((clients.size() > 1) || !players.contains(localPlayerId))
|
||||
p = card->getOwner();
|
||||
} else {
|
||||
else
|
||||
p = players.value(localPlayerId);
|
||||
qDebug() << "GEFUNDEN" << localPlayerId << p->getName();
|
||||
}
|
||||
p->updateCardMenu(static_cast<CardItem *>(card), cardMenu, ptMenu, moveMenu);
|
||||
p->updateCardMenu(static_cast<CardItem *>(card));
|
||||
}
|
||||
|
|
|
@ -178,7 +178,7 @@ private slots:
|
|||
void incrementGameTime();
|
||||
void adminLockChanged(bool lock);
|
||||
void newCardAdded(AbstractCardItem *card);
|
||||
void updateCardMenu(AbstractCardItem *card, QMenu *cardMenu, QMenu *ptMenu, QMenu *moveMenu);
|
||||
void updateCardMenu(AbstractCardItem *card);
|
||||
|
||||
void actConcede();
|
||||
void actLeaveGame();
|
||||
|
|
|
@ -477,7 +477,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
|||
publicCardName = card->getName();
|
||||
|
||||
int oldCardId = card->getId();
|
||||
if (faceDown || (targetzone->getPlayer() != startzone->getPlayer()))
|
||||
if ((faceDown && (startzone != targetzone)) || (targetzone->getPlayer() != startzone->getPlayer()))
|
||||
card->setId(targetzone->getPlayer()->newCardId());
|
||||
card->setFaceDown(faceDown);
|
||||
|
||||
|
@ -506,6 +506,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
|||
|
||||
Event_MoveCard eventPrivate(eventOthers);
|
||||
eventPrivate.set_card_id(privateOldCardId);
|
||||
if (!privateCardName.isEmpty())
|
||||
eventPrivate.set_card_name(privateCardName.toStdString());
|
||||
eventPrivate.set_position(privatePosition);
|
||||
eventPrivate.set_new_card_id(privateNewCardId);
|
||||
|
@ -524,6 +525,7 @@ Response::ResponseCode Server_Player::moveCard(GameEventStorage &ges, Server_Car
|
|||
eventOthers.set_position(position);
|
||||
if ((startzone->getType() == ServerInfo_Zone::PublicZone) || (targetzone->getType() == ServerInfo_Zone::PublicZone)) {
|
||||
eventOthers.set_card_id(oldCardId);
|
||||
if (!publicCardName.isEmpty())
|
||||
eventOthers.set_card_name(publicCardName.toStdString());
|
||||
eventOthers.set_new_card_id(card->getId());
|
||||
}
|
||||
|
@ -900,6 +902,7 @@ Response::ResponseCode Server_Player::cmdFlipCard(const Command_FlipCard &cmd, R
|
|||
Event_FlipCard event;
|
||||
event.set_zone_name(zone->getName().toStdString());
|
||||
event.set_card_id(card->getId());
|
||||
if (!faceDown)
|
||||
event.set_card_name(card->getName().toStdString());
|
||||
event.set_face_down(faceDown);
|
||||
ges.enqueueGameEvent(event, playerId);
|
||||
|
|
Loading…
Reference in a new issue