diff --git a/cockatrice/src/client/settings/shortcuts_settings.h b/cockatrice/src/client/settings/shortcuts_settings.h index 1de73c165..d9ea494dc 100644 --- a/cockatrice/src/client/settings/shortcuts_settings.h +++ b/cockatrice/src/client/settings/shortcuts_settings.h @@ -664,6 +664,9 @@ private: {"Player/aRollDie", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Roll Dice..."), parseSequenceString("Ctrl+I"), ShortcutGroup::Gameplay)}, + {"Player/aFlipCoin", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Flip Coin"), + parseSequenceString("Ctrl+Shift+I"), + ShortcutGroup::Gameplay)}, {"Player/aShuffle", ShortcutKey(QT_TRANSLATE_NOOP("shortcutsTab", "Shuffle Library"), parseSequenceString("Ctrl+S"), ShortcutGroup::Gameplay)}, diff --git a/cockatrice/src/game/player/menu/utility_menu.cpp b/cockatrice/src/game/player/menu/utility_menu.cpp index 37bdcbbaf..bcb4683fd 100644 --- a/cockatrice/src/game/player/menu/utility_menu.cpp +++ b/cockatrice/src/game/player/menu/utility_menu.cpp @@ -19,6 +19,9 @@ UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu) aRollDie = new QAction(this); connect(aRollDie, &QAction::triggered, playerActions, &PlayerActions::actRollDie); + aFlipCoin = new QAction(this); + connect(aFlipCoin, &QAction::triggered, playerActions, &PlayerActions::actFlipCoin); + aCreateToken = new QAction(this); connect(aCreateToken, &QAction::triggered, playerActions, &PlayerActions::actCreateToken); @@ -38,6 +41,7 @@ UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu) playerMenu->addAction(aUntapAll); playerMenu->addSeparator(); playerMenu->addAction(aRollDie); + playerMenu->addAction(aFlipCoin); playerMenu->addSeparator(); playerMenu->addAction(aCreateToken); playerMenu->addAction(aCreateAnotherToken); @@ -50,6 +54,7 @@ UtilityMenu::UtilityMenu(Player *_player, QMenu *playerMenu) : QMenu(playerMenu) aIncrementAllCardCounters = nullptr; aUntapAll = nullptr; aRollDie = nullptr; + aFlipCoin = nullptr; } retranslateUi(); @@ -89,6 +94,7 @@ void UtilityMenu::retranslateUi() aIncrementAllCardCounters->setText(tr("Increment all card counters")); aUntapAll->setText(tr("&Untap all permanents")); aRollDie->setText(tr("R&oll die...")); + aFlipCoin->setText(tr("Flip coin")); aCreateToken->setText(tr("&Create token...")); aCreateAnotherToken->setText(tr("C&reate another token")); createPredefinedTokenMenu->setTitle(tr("Cr&eate predefined token")); @@ -103,6 +109,7 @@ void UtilityMenu::setShortcutsActive() aIncrementAllCardCounters->setShortcuts(shortcuts.getShortcut("Player/aIncrementAllCardCounters")); aUntapAll->setShortcuts(shortcuts.getShortcut("Player/aUntapAll")); aRollDie->setShortcuts(shortcuts.getShortcut("Player/aRollDie")); + aFlipCoin->setShortcuts(shortcuts.getShortcut("Player/aFlipCoin")); aCreateToken->setShortcuts(shortcuts.getShortcut("Player/aCreateToken")); aCreateAnotherToken->setShortcuts(shortcuts.getShortcut("Player/aCreateAnotherToken")); } @@ -113,6 +120,7 @@ void UtilityMenu::setShortcutsInactive() if (player->getPlayerInfo()->getLocalOrJudge()) { aUntapAll->setShortcut(QKeySequence()); aRollDie->setShortcut(QKeySequence()); + aFlipCoin->setShortcut(QKeySequence()); aCreateToken->setShortcut(QKeySequence()); aCreateAnotherToken->setShortcut(QKeySequence()); aIncrementAllCardCounters->setShortcut(QKeySequence()); diff --git a/cockatrice/src/game/player/menu/utility_menu.h b/cockatrice/src/game/player/menu/utility_menu.h index f6577d7d1..117a7e13a 100644 --- a/cockatrice/src/game/player/menu/utility_menu.h +++ b/cockatrice/src/game/player/menu/utility_menu.h @@ -47,7 +47,7 @@ private: QMenu *createPredefinedTokenMenu; QAction *aIncrementAllCardCounters; - QAction *aUntapAll, *aRollDie; + QAction *aUntapAll, *aRollDie, *aFlipCoin; QAction *aCreateToken, *aCreateAnotherToken; }; diff --git a/cockatrice/src/game/player/player_actions.cpp b/cockatrice/src/game/player/player_actions.cpp index 20034df16..92c4b16bf 100644 --- a/cockatrice/src/game/player/player_actions.cpp +++ b/cockatrice/src/game/player/player_actions.cpp @@ -852,6 +852,14 @@ void PlayerActions::actRollDie() sendGameCommand(cmd); } +void PlayerActions::actFlipCoin() +{ + Command_RollDie cmd; + cmd.set_sides(2); + cmd.set_count(1); + sendGameCommand(cmd); +} + void PlayerActions::actCreateToken() { DlgCreateToken dlg(player->getPlayerMenu()->getUtilityMenu()->getPredefinedTokens(), player->getGame()->getTab()); diff --git a/cockatrice/src/game/player/player_actions.h b/cockatrice/src/game/player/player_actions.h index d4c6daacf..08e016f2a 100644 --- a/cockatrice/src/game/player/player_actions.h +++ b/cockatrice/src/game/player/player_actions.h @@ -77,6 +77,7 @@ public slots: void actUntapAll(); void actRollDie(); + void actFlipCoin(); void actCreateToken(); void actCreateAnotherToken(); void actShuffle();