diff --git a/cockatrice/src/client/settings/shortcuts_settings.h b/cockatrice/src/client/settings/shortcuts_settings.h index 736f0c896..156ee82ea 100644 --- a/cockatrice/src/client/settings/shortcuts_settings.h +++ b/cockatrice/src/client/settings/shortcuts_settings.h @@ -660,6 +660,12 @@ private: {"Player/aMulligan", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Mulligan"), parseSequenceString("Ctrl+M"), ShortcutGroup::Drawing)}, + {"Player/aMulliganSame", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Mulligan (Same hand size)"), + parseSequenceString("Ctrl+Shift+M"), + ShortcutGroup::Drawing)}, + {"Player/aMulliganMinusOne", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Mulligan (Hand size - 1)"), + parseSequenceString("Ctrl+Shift+Alt+M"), + ShortcutGroup::Drawing)}, {"Player/aDrawCard", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Draw a Card"), parseSequenceString("Ctrl+D"), ShortcutGroup::Drawing)}, diff --git a/cockatrice/src/game/player/menu/hand_menu.cpp b/cockatrice/src/game/player/menu/hand_menu.cpp index e193d2e4a..019ab925c 100644 --- a/cockatrice/src/game/player/menu/hand_menu.cpp +++ b/cockatrice/src/game/player/menu/hand_menu.cpp @@ -60,6 +60,16 @@ HandMenu::HandMenu(Player *_player, PlayerActions *actions, QWidget *parent) : T connect(aMulligan, &QAction::triggered, actions, &PlayerActions::actMulligan); addAction(aMulligan); + // Mulligan same size + aMulliganSame = new QAction(this); + connect(aMulliganSame, &QAction::triggered, actions, &PlayerActions::actMulliganSameSize); + addAction(aMulliganSame); + + // Mulligan -1 + aMulliganMinusOne = new QAction(this); + connect(aMulliganMinusOne, &QAction::triggered, actions, &PlayerActions::actMulliganMinusOne); + addAction(aMulliganMinusOne); + addSeparator(); mMoveHandMenu = addTearOffMenu(QString()); @@ -104,7 +114,9 @@ void HandMenu::retranslateUi() aSortHandByType->setText(tr("Type")); aSortHandByManaValue->setText(tr("Mana Value")); - aMulligan->setText(tr("Take &mulligan")); + aMulligan->setText(tr("Take &mulligan (Choose hand size)")); + aMulliganSame->setText(tr("Take mulligan (Same hand size)")); + aMulliganMinusOne->setText(tr("Take mulligan (Hand size - 1)")); mMoveHandMenu->setTitle(tr("&Move hand to...")); aMoveHandToTopLibrary->setText(tr("&Top of library")); @@ -128,6 +140,8 @@ void HandMenu::setShortcutsActive() aSortHandByType->setShortcuts(shortcuts.getShortcut("Player/aSortHandByType")); aSortHandByManaValue->setShortcuts(shortcuts.getShortcut("Player/aSortHandByManaValue")); aMulligan->setShortcuts(shortcuts.getShortcut("Player/aMulligan")); + aMulliganSame->setShortcuts(shortcuts.getShortcut("Player/aMulliganSame")); + aMulliganMinusOne->setShortcuts(shortcuts.getShortcut("Player/aMulliganMinusOne")); aRevealHandToAll->setShortcuts(shortcuts.getShortcut("Player/aRevealHandToAll")); aRevealRandomHandCardToAll->setShortcuts(shortcuts.getShortcut("Player/aRevealRandomHandCardToAll")); } diff --git a/cockatrice/src/game/player/menu/hand_menu.h b/cockatrice/src/game/player/menu/hand_menu.h index 2c776b857..51e071a62 100644 --- a/cockatrice/src/game/player/menu/hand_menu.h +++ b/cockatrice/src/game/player/menu/hand_menu.h @@ -46,6 +46,8 @@ private: QAction *aViewHand = nullptr; QAction *aMulligan = nullptr; + QAction *aMulliganSame = nullptr; + QAction *aMulliganMinusOne = nullptr; QMenu *mSortHand = nullptr; QAction *aSortHandByName = nullptr; diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index 444eecb0d..ed77808b0 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -310,28 +310,48 @@ void PlayerActions::actMulligan() { int startSize = SettingsCache::instance().getStartingHandSize(); int handSize = player->getHandZone()->getCards().size(); - int deckSize = player->getDeckZone()->getCards().size() + handSize; // hand is shuffled back into the deck + int deckSize = player->getDeckZone()->getCards().size() + handSize; + bool ok; int number = QInputDialog::getInt(player->getGame()->getTab(), tr("Draw hand"), tr("Number of cards: (max. %1)").arg(deckSize) + '\n' + tr("0 and lower are in comparison to current hand size"), startSize, -handSize, deckSize, 1, &ok); + if (!ok) { return; } - Command_Mulligan cmd; + if (number < 1) { - if (handSize == 0) { - return; - } - cmd.set_number(handSize + number); - } else { - cmd.set_number(number); + number = handSize + number; } + + doMulligan(number); + SettingsCache::instance().setStartingHandSize(number); +} + +void PlayerActions::actMulliganSameSize() +{ + int handSize = player->getHandZone()->getCards().size(); + doMulligan(handSize); +} + +void PlayerActions::actMulliganMinusOne() +{ + int handSize = player->getHandZone()->getCards().size(); + int targetSize = qMax(1, handSize - 1); + doMulligan(targetSize); +} + +void PlayerActions::doMulligan(int number) +{ + if (number < 1) { + return; + } + + Command_Mulligan cmd; + cmd.set_number(number); sendGameCommand(cmd); - if (startSize != number) { - SettingsCache::instance().setStartingHandSize(number); - } } void PlayerActions::actDrawCards() diff --git a/cockatrice/src/game/player/player_actions.h b/cockatrice/src/game/player/player_actions.h index e0f86e4fc..b294b5946 100644 --- a/cockatrice/src/game/player/player_actions.h +++ b/cockatrice/src/game/player/player_actions.h @@ -85,6 +85,9 @@ public slots: void actDrawCards(); void actUndoDraw(); void actMulligan(); + void actMulliganSameSize(); + void actMulliganMinusOne(); + void doMulligan(int number); void actPlay(); void actPlayFacedown();