Reveal top x cards

Updated reveal top card to reveal top x cards
Sometimes you want to reveal more than only the top 1 card.
This commit is contained in:
Matt Lowe 2015-05-04 10:49:49 +02:00
parent 9ff22eaf17
commit 59c0834427
3 changed files with 23 additions and 4 deletions

View file

@ -515,8 +515,19 @@ void Player::playerListActionTriggered()
if (menu == mRevealLibrary) { if (menu == mRevealLibrary) {
cmd.set_zone_name("deck"); cmd.set_zone_name("deck");
} else if (menu == mRevealTopCard) { } else if (menu == mRevealTopCard) {
cmd.set_zone_name("deck"); bool ok;
cmd.set_card_id(0); int number =
#if QT_VERSION < 0x050000
QInputDialog::getInteger(
#else
QInputDialog::getInt(
#endif
0, tr("Reveal top cards of library"), tr("Number of cards:"), defaultNumberTopCards, 1, 2000000000, 1, &ok);
if (ok) {
cmd.set_zone_name("deck");
cmd.set_top_cards(number);
}
} else if (menu == mRevealHand) } else if (menu == mRevealHand)
cmd.set_zone_name("hand"); cmd.set_zone_name("hand");
else if (menu == mRevealRandomHandCard) { else if (menu == mRevealRandomHandCard) {
@ -624,7 +635,7 @@ void Player::retranslateUi()
aViewLibrary->setText(tr("&View library")); aViewLibrary->setText(tr("&View library"));
aViewTopCards->setText(tr("View &top cards of library...")); aViewTopCards->setText(tr("View &top cards of library..."));
mRevealLibrary->setTitle(tr("Reveal &library to...")); mRevealLibrary->setTitle(tr("Reveal &library to..."));
mRevealTopCard->setTitle(tr("Reveal t&op card to...")); mRevealTopCard->setTitle(tr("Reveal t&op cards to..."));
aAlwaysRevealTopCard->setText(tr("&Always reveal top card")); aAlwaysRevealTopCard->setText(tr("&Always reveal top card"));
aOpenDeckInDeckEditor->setText(tr("O&pen deck in deck editor")); aOpenDeckInDeckEditor->setText(tr("O&pen deck in deck editor"));
aViewSideboard->setText(tr("&View sideboard")); aViewSideboard->setText(tr("&View sideboard"));

View file

@ -7,4 +7,5 @@ message Command_RevealCards {
optional sint32 card_id = 2 [default = -1]; optional sint32 card_id = 2 [default = -1];
optional sint32 player_id = 3 [default = -1]; optional sint32 player_id = 3 [default = -1];
optional bool grant_write_access = 4; optional bool grant_write_access = 4;
optional sint32 top_cards = 5 [default = -1];
} }

View file

@ -1522,7 +1522,14 @@ Response::ResponseCode Server_Player::cmdRevealCards(const Command_RevealCards &
return Response::RespNameNotFound; return Response::RespNameNotFound;
QList<Server_Card *> cardsToReveal; QList<Server_Card *> cardsToReveal;
if (!cmd.has_card_id()) if (cmd.top_cards() != -1) {
for (int i = 0; i < cmd.top_cards(); i++) {
Server_Card *card = zone->getCard(i);
if (!card)
return Response::RespNameNotFound;
cardsToReveal.append(card);
}
} else if (!cmd.has_card_id())
cardsToReveal = zone->getCards(); cardsToReveal = zone->getCards();
else if (cmd.card_id() == -2) { else if (cmd.card_id() == -2) {
if (zone->getCards().isEmpty()) if (zone->getCards().isEmpty())