From 7c1a18da5e38c81c7a9261a105b5a04a0f27d750 Mon Sep 17 00:00:00 2001 From: Zach H Date: Wed, 26 Apr 2017 18:12:56 -0400 Subject: [PATCH] Add "Random card from graveyard" (#2652) --- cockatrice/src/player.cpp | 24 +++++++++++++++++++++++- cockatrice/src/player.h | 6 ++++-- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/cockatrice/src/player.cpp b/cockatrice/src/player.cpp index b095bd06..8c4ea971 100644 --- a/cockatrice/src/player.cpp +++ b/cockatrice/src/player.cpp @@ -287,6 +287,15 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_pare graveMenu = playerMenu->addMenu(QString()); graveMenu->addAction(aViewGraveyard); + + if (local) { + mRevealRandomGraveyardCard = graveMenu->addMenu(QString()); + QAction *newAction = mRevealRandomGraveyardCard->addAction(QString()); + newAction->setData(-1); + connect(newAction, SIGNAL(triggered()), this, SLOT(actRevealRandomGraveyardCard())); + allPlayersActions.append(newAction); + mRevealRandomGraveyardCard->addSeparator(); + } grave->setMenu(graveMenu, aViewGraveyard); rfgMenu = playerMenu->addMenu(QString()); @@ -533,7 +542,7 @@ void Player::playerListActionTriggered() cmd.set_zone_name("hand"); else if (menu == mRevealRandomHandCard) { cmd.set_zone_name("hand"); - cmd.set_card_id(-2); + cmd.set_card_id(RANDOM_CARD_FROM_ZONE); } else return; @@ -655,6 +664,7 @@ void Player::retranslateUi() handMenu->setTitle(tr("&Hand")); mRevealHand->setTitle(tr("&Reveal hand to...")); mRevealRandomHandCard->setTitle(tr("Reveal r&andom card to...")); + mRevealRandomGraveyardCard->setTitle(tr("Reveal random card to...")); sbMenu->setTitle(tr("&Sideboard")); libraryMenu->setTitle(tr("&Library")); countersMenu->setTitle(tr("&Counters")); @@ -892,6 +902,18 @@ void Player::actViewGraveyard() static_cast(scene())->toggleZoneView(this, "grave", -1); } +void Player::actRevealRandomGraveyardCard() +{ + Command_RevealCards cmd; + QAction *action = static_cast(sender()); + const int otherPlayerId = action->data().toInt(); + if (otherPlayerId != -1) + cmd.set_player_id(otherPlayerId); + cmd.set_zone_name("grave"); + cmd.set_card_id(RANDOM_CARD_FROM_ZONE); + sendGameCommand(cmd); +} + void Player::actViewRfg() { static_cast(scene())->toggleZoneView(this, "rfg", -1); diff --git a/cockatrice/src/player.h b/cockatrice/src/player.h index 032f3918..22e43f24 100644 --- a/cockatrice/src/player.h +++ b/cockatrice/src/player.h @@ -127,6 +127,7 @@ public slots: void actViewTopCards(); void actAlwaysRevealTopCard(); void actViewGraveyard(); + void actRevealRandomGraveyardCard(); void actViewRfg(); void actViewSideboard(); @@ -165,7 +166,7 @@ private slots: private: TabGame *game; QMenu *playerMenu, *handMenu, *moveHandMenu, *graveMenu, *moveGraveMenu, *rfgMenu, *moveRfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, - *mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard; + *mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard; QList playerLists; QList allPlayersActions; QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg, @@ -247,7 +248,8 @@ private: public: static const int counterAreaWidth = 55; enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToHand, cmMoveToGraveyard, cmMoveToExile }; - + enum CardsToReveal {RANDOM_CARD_FROM_ZONE = -2}; + enum { Type = typeOther }; int type() const { return Type; } QRectF boundingRect() const;