mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-18 16:32:16 -07:00
Add actions for shuffle top/bottom X cards
This commit is contained in:
parent
ff7f31ca33
commit
0310ecddc8
3 changed files with 99 additions and 9 deletions
|
|
@ -246,8 +246,14 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
|||
connect(aDrawCards, &QAction::triggered, this, &Player::actDrawCards);
|
||||
aUndoDraw = new QAction(this);
|
||||
connect(aUndoDraw, &QAction::triggered, this, &Player::actUndoDraw);
|
||||
|
||||
aShuffle = new QAction(this);
|
||||
connect(aShuffle, &QAction::triggered, this, &Player::actShuffle);
|
||||
aShuffleTop = new QAction(this);
|
||||
connect(aShuffleTop, &QAction::triggered, this, &Player::actShuffleTop);
|
||||
aShuffleBottom = new QAction(this);
|
||||
connect(aShuffleBottom, &QAction::triggered, this, &Player::actShuffleBottom);
|
||||
|
||||
aMulligan = new QAction(this);
|
||||
connect(aMulligan, &QAction::triggered, this, &Player::actMulligan);
|
||||
|
||||
|
|
@ -288,6 +294,12 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
|||
connect(aMoveBottomCardToTop, &QAction::triggered, this, &Player::actMoveBottomCardToTop);
|
||||
}
|
||||
|
||||
aViewGraveyard = new QAction(this);
|
||||
connect(aViewGraveyard, &QAction::triggered, this, &Player::actViewGraveyard);
|
||||
|
||||
aViewRfg = new QAction(this);
|
||||
connect(aViewRfg, &QAction::triggered, this, &Player::actViewRfg);
|
||||
|
||||
playerMenu = new TearOffMenu();
|
||||
table->setMenu(playerMenu);
|
||||
|
||||
|
|
@ -313,7 +325,7 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
|||
libraryMenu->addAction(aDrawCards);
|
||||
libraryMenu->addAction(aUndoDraw);
|
||||
libraryMenu->addSeparator();
|
||||
libraryMenu->addAction(aShuffle);
|
||||
shuffleMenu = libraryMenu->addTearOffMenu(QString());
|
||||
libraryMenu->addSeparator();
|
||||
libraryMenu->addAction(aViewLibrary);
|
||||
libraryMenu->addAction(aViewTopCards);
|
||||
|
|
@ -331,6 +343,10 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
|
|||
libraryMenu->addAction(aOpenDeckInDeckEditor);
|
||||
_deck->setMenu(libraryMenu, aDrawCard);
|
||||
|
||||
shuffleMenu->addAction(aShuffle);
|
||||
shuffleMenu->addAction(aShuffleTop);
|
||||
shuffleMenu->addAction(aShuffleBottom);
|
||||
|
||||
topLibraryMenu->addAction(aMoveTopToPlay);
|
||||
topLibraryMenu->addAction(aMoveTopToPlayFaceDown);
|
||||
topLibraryMenu->addAction(aMoveTopCardToBottom);
|
||||
|
|
@ -792,7 +808,11 @@ void Player::retranslateUi()
|
|||
aDrawCards->setText(tr("D&raw cards..."));
|
||||
aUndoDraw->setText(tr("&Undo last draw"));
|
||||
aMulligan->setText(tr("Take &mulligan"));
|
||||
aShuffle->setText(tr("&Shuffle"));
|
||||
|
||||
shuffleMenu->setTitle(tr("Shuffle..."));
|
||||
aShuffle->setText(tr("Entire library"));
|
||||
aShuffleTop->setText(tr("Top cards of library..."));
|
||||
aShuffleBottom->setText(tr("Bottom cards of library..."));
|
||||
|
||||
aMoveTopToPlay->setText(tr("&Play top card"));
|
||||
aMoveTopToPlayFaceDown->setText(tr("Play top card &face down"));
|
||||
|
|
@ -979,6 +999,8 @@ void Player::setShortcutsActive()
|
|||
aUndoDraw->setShortcut(shortcuts.getSingleShortcut("Player/aUndoDraw"));
|
||||
aMulligan->setShortcut(shortcuts.getSingleShortcut("Player/aMulligan"));
|
||||
aShuffle->setShortcut(shortcuts.getSingleShortcut("Player/aShuffle"));
|
||||
aShuffleTop->setShortcut(shortcuts.getSingleShortcut("Player/aShuffleTop"));
|
||||
aShuffleBottom->setShortcut(shortcuts.getSingleShortcut("Player/aShuffleBottom"));
|
||||
aUntapAll->setShortcut(shortcuts.getSingleShortcut("Player/aUntapAll"));
|
||||
aRollDie->setShortcut(shortcuts.getSingleShortcut("Player/aRollDie"));
|
||||
aCreateToken->setShortcut(shortcuts.getSingleShortcut("Player/aCreateToken"));
|
||||
|
|
@ -1029,6 +1051,8 @@ void Player::setShortcutsInactive()
|
|||
aUndoDraw->setShortcut(QKeySequence());
|
||||
aMulligan->setShortcut(QKeySequence());
|
||||
aShuffle->setShortcut(QKeySequence());
|
||||
aShuffleTop->setShortcut(QKeySequence());
|
||||
aShuffleBottom->setShortcut(QKeySequence());
|
||||
aUntapAll->setShortcut(QKeySequence());
|
||||
aRollDie->setShortcut(QKeySequence());
|
||||
aCreateToken->setShortcut(QKeySequence());
|
||||
|
|
@ -1202,6 +1226,64 @@ void Player::actShuffle()
|
|||
sendGameCommand(Command_Shuffle());
|
||||
}
|
||||
|
||||
void Player::actShuffleTop()
|
||||
{
|
||||
const int maxCards = zones.value("deck")->getCards().size();
|
||||
if (maxCards == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
int number =
|
||||
QInputDialog::getInt(game, tr("Shuffle top cards of library"), tr("Number of cards: (max. %1)").arg(maxCards),
|
||||
defaultNumberTopCards, 1, maxCards, 1, &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (number > maxCards) {
|
||||
number = maxCards;
|
||||
}
|
||||
|
||||
defaultNumberTopCards = number;
|
||||
|
||||
Command_Shuffle cmd;
|
||||
cmd.set_zone_name("deck");
|
||||
cmd.set_start(0);
|
||||
cmd.set_end(number - 1); // inclusive, the indexed card at end will be shuffled
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actShuffleBottom()
|
||||
{
|
||||
const int maxCards = zones.value("deck")->getCards().size();
|
||||
if (maxCards == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool ok;
|
||||
int number = QInputDialog::getInt(game, tr("Shuffle bottom cards of library"),
|
||||
tr("Number of cards: (max. %1)").arg(maxCards), defaultNumberBottomCards, 1,
|
||||
maxCards, 1, &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (number > maxCards) {
|
||||
number = maxCards;
|
||||
}
|
||||
|
||||
defaultNumberBottomCards = number;
|
||||
|
||||
Command_Shuffle cmd;
|
||||
cmd.set_zone_name("deck");
|
||||
cmd.set_start(-number);
|
||||
cmd.set_end(-1);
|
||||
|
||||
sendGameCommand(cmd);
|
||||
}
|
||||
|
||||
void Player::actDrawCard()
|
||||
{
|
||||
Command_DrawCards cmd;
|
||||
|
|
|
|||
|
|
@ -161,6 +161,8 @@ public slots:
|
|||
void actCreateToken();
|
||||
void actCreateAnotherToken();
|
||||
void actShuffle();
|
||||
void actShuffleTop();
|
||||
void actShuffleBottom();
|
||||
void actDrawCard();
|
||||
void actDrawCards();
|
||||
void actUndoDraw();
|
||||
|
|
@ -251,8 +253,8 @@ private:
|
|||
TabGame *game;
|
||||
QMenu *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mRevealLibrary, *mLendLibrary, *mRevealTopCard,
|
||||
*mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard;
|
||||
TearOffMenu *moveGraveMenu, *moveRfgMenu, *graveMenu, *moveHandMenu, *handMenu, *libraryMenu, *topLibraryMenu,
|
||||
*bottomLibraryMenu, *rfgMenu, *playerMenu;
|
||||
TearOffMenu *moveGraveMenu, *moveRfgMenu, *graveMenu, *moveHandMenu, *handMenu, *libraryMenu, *shuffleMenu,
|
||||
*topLibraryMenu, *bottomLibraryMenu, *rfgMenu, *playerMenu;
|
||||
QList<QMenu *> playerLists;
|
||||
QList<QMenu *> singlePlayerLists;
|
||||
QList<QAction *> allPlayersActions;
|
||||
|
|
@ -263,10 +265,10 @@ private:
|
|||
*aViewBottomCards, *aAlwaysRevealTopCard, *aAlwaysLookAtTopCard, *aOpenDeckInDeckEditor,
|
||||
*aMoveTopCardToGraveyard, *aMoveTopCardToExile, *aMoveTopCardsToGraveyard, *aMoveTopCardsToExile,
|
||||
*aMoveTopCardsUntil, *aMoveTopCardToBottom, *aViewGraveyard, *aViewRfg, *aViewSideboard, *aDrawCard,
|
||||
*aDrawCards, *aUndoDraw, *aMulligan, *aShuffle, *aMoveTopToPlay, *aMoveTopToPlayFaceDown, *aUntapAll, *aRollDie,
|
||||
*aCreateToken, *aCreateAnotherToken, *aMoveBottomToPlay, *aMoveBottomToPlayFaceDown, *aMoveBottomCardToTop,
|
||||
*aMoveBottomCardToGraveyard, *aMoveBottomCardToExile, *aMoveBottomCardsToGraveyard, *aMoveBottomCardsToExile,
|
||||
*aDrawBottomCard, *aDrawBottomCards;
|
||||
*aDrawCards, *aUndoDraw, *aMulligan, *aShuffle, *aShuffleTop, *aShuffleBottom, *aMoveTopToPlay,
|
||||
*aMoveTopToPlayFaceDown, *aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken, *aMoveBottomToPlay,
|
||||
*aMoveBottomToPlayFaceDown, *aMoveBottomCardToTop, *aMoveBottomCardToGraveyard, *aMoveBottomCardToExile,
|
||||
*aMoveBottomCardsToGraveyard, *aMoveBottomCardsToExile, *aDrawBottomCard, *aDrawBottomCards;
|
||||
|
||||
QAction *aCardMenu;
|
||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
||||
|
|
|
|||
|
|
@ -575,9 +575,15 @@ private:
|
|||
{"Player/aRollDie", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Roll Dice..."),
|
||||
parseSequenceString("Ctrl+I"),
|
||||
ShortcutGroup::Gameplay)},
|
||||
{"Player/aShuffle", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Shuffle Library"),
|
||||
{"Player/aShuffle", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Shuffle Entire Library"),
|
||||
parseSequenceString("Ctrl+S"),
|
||||
ShortcutGroup::Gameplay)},
|
||||
{"Player/aShuffleTop", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Shuffle Top Cards of Library"),
|
||||
parseSequenceString(""),
|
||||
ShortcutGroup::Gameplay)},
|
||||
{"Player/aShuffleBottom", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Shuffle Bottom Cards of Library"),
|
||||
parseSequenceString(""),
|
||||
ShortcutGroup::Gameplay)},
|
||||
{"Player/aMulligan", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Mulligan"),
|
||||
parseSequenceString("Ctrl+M"),
|
||||
ShortcutGroup::Drawing)},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue