AlwaysRevealTopCard done, issue #31 fixed

This commit is contained in:
Max-Wilhelm Bruker 2012-04-01 11:45:01 +02:00
parent 840b577f42
commit c835a827b0
6 changed files with 20 additions and 5 deletions

View file

@ -37,6 +37,7 @@ QRectF AbstractCardItem::boundingRect() const
void AbstractCardItem::pixmapUpdated() void AbstractCardItem::pixmapUpdated()
{ {
update(); update();
emit sigPixmapUpdated();
} }
void AbstractCardItem::cardInfoUpdated() void AbstractCardItem::cardInfoUpdated()

View file

@ -34,6 +34,7 @@ signals:
void showCardInfoPopup(QPoint pos, QString cardName); void showCardInfoPopup(QPoint pos, QString cardName);
void deleteCardInfoPopup(QString cardName); void deleteCardInfoPopup(QString cardName);
void updateCardMenu(AbstractCardItem *card); void updateCardMenu(AbstractCardItem *card);
void sigPixmapUpdated();
public: public:
enum { Type = typeCard }; enum { Type = typeCard };
int type() const { return Type; } int type() const { return Type; }

View file

@ -39,11 +39,15 @@ void PileZone::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*optio
void PileZone::addCardImpl(CardItem *card, int x, int /*y*/) void PileZone::addCardImpl(CardItem *card, int x, int /*y*/)
{ {
connect(card, SIGNAL(sigPixmapUpdated()), this, SLOT(callUpdate()));
cards.insert(x, card); cards.insert(x, card);
card->setPos(0, 0); card->setPos(0, 0);
if (!contentsKnown()) { if (!contentsKnown()) {
card->setName(QString()); card->setName(QString());
card->setId(-1); card->setId(-1);
// If we obscure a previously revealed card, its name has to be forgotten
if (cards.size() > x + 1)
cards.at(x + 1)->setName(QString());
} }
card->setVisible(false); card->setVisible(false);
card->resetState(); card->resetState();

View file

@ -5,6 +5,8 @@
class PileZone : public CardZone { class PileZone : public CardZone {
Q_OBJECT Q_OBJECT
private slots:
void callUpdate() { update(); }
public: public:
PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent = 0); PileZone(Player *_p, const QString &_name, bool _isShufflable, bool _contentsKnown, QGraphicsItem *parent = 0);
QRectF boundingRect() const; QRectF boundingRect() const;

View file

@ -1297,12 +1297,19 @@ void Player::eventRevealCards(const Event_RevealCards &event)
emit logRevealCards(this, zone, cardList.at(i)->id(), cardName, this, true); emit logRevealCards(this, zone, cardList.at(i)->id(), cardName, this, true);
} }
} else { } else {
if (!cardList.isEmpty()) bool showZoneView = true;
QString cardName;
if (cardList.size() == 1) {
cardName = QString::fromStdString(cardList.first()->name());
if ((event.card_id() == 0) && dynamic_cast<PileZone *>(zone)) {
zone->getCards().first()->setName(cardName);
zone->update();
showZoneView = false;
}
}
if (showZoneView && !cardList.isEmpty())
static_cast<GameScene *>(scene())->addRevealedZoneView(this, zone, cardList, event.grant_write_access()); 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, false); emit logRevealCards(this, zone, event.card_id(), cardName, otherPlayer, false);
} }
} }

View file

@ -1582,7 +1582,7 @@ Response::ResponseCode Server_Player::cmdChangeZoneProperties(const Command_Chan
ges.enqueueGameEvent(event, playerId); ges.enqueueGameEvent(event, playerId);
if (!zone->cards.isEmpty()) { if (!zone->cards.isEmpty() && cmd.always_reveal_top_card()) {
Event_RevealCards revealEvent; Event_RevealCards revealEvent;
revealEvent.set_zone_name(zone->getName().toStdString()); revealEvent.set_zone_name(zone->getName().toStdString());
revealEvent.set_card_id(0); revealEvent.set_card_id(0);