mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-21 14:23:54 -07:00
replace old mulligan with new behavior (#3773)
This commit is contained in:
parent
ce54aa6813
commit
a3a1e20074
7 changed files with 58 additions and 23 deletions
|
|
@ -434,10 +434,13 @@ void MessageLogWidget::logMulligan(Player *player, int number)
|
|||
if (!player) {
|
||||
return;
|
||||
}
|
||||
if (number > -1) {
|
||||
appendHtmlServerMessage(tr("%1 takes a mulligan to %2.").arg(sanitizeHtml(player->getName())).arg(number));
|
||||
if (number > 0) {
|
||||
appendHtmlServerMessage(tr("%1 shuffles their deck and draws a new hand of %2 card(s).", "", number)
|
||||
.arg(sanitizeHtml(player->getName()))
|
||||
.arg(number));
|
||||
} else {
|
||||
appendHtmlServerMessage(tr("%1 draws their initial hand.").arg(sanitizeHtml(player->getName())));
|
||||
appendHtmlServerMessage(
|
||||
tr("%1 shuffles their deck and draws a new hand.").arg(sanitizeHtml(player->getName())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1009,7 +1009,29 @@ void Player::actDrawCard()
|
|||
|
||||
void Player::actMulligan()
|
||||
{
|
||||
sendGameCommand(Command_Mulligan());
|
||||
int startSize = settingsCache->getStartingHandSize();
|
||||
int handSize = zones.value("hand")->getCards().size();
|
||||
int deckSize = zones.value("deck")->getCards().size() + handSize;
|
||||
bool ok;
|
||||
int number = QInputDialog::getInt(
|
||||
game, tr("Draw hand"), tr("Number of cards:") + '\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);
|
||||
}
|
||||
sendGameCommand(cmd);
|
||||
if (startSize != number) {
|
||||
settingsCache->setStartingHandSize(number);
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actDrawCards()
|
||||
|
|
|
|||
|
|
@ -228,6 +228,7 @@ SettingsCache::SettingsCache()
|
|||
spectatorNotificationsEnabled = settings->value("interface/specnotificationsenabled", false).toBool();
|
||||
doubleClickToPlay = settings->value("interface/doubleclicktoplay", true).toBool();
|
||||
playToStack = settings->value("interface/playtostack", true).toBool();
|
||||
startingHandSize = settings->value("interface/startinghandsize", 7).toInt();
|
||||
annotateTokens = settings->value("interface/annotatetokens", false).toBool();
|
||||
tabGameSplitterSizes = settings->value("interface/tabgame_splittersizes").toByteArray();
|
||||
displayCardNames = settings->value("cards/displaycardnames", true).toBool();
|
||||
|
|
@ -439,6 +440,12 @@ void SettingsCache::setPlayToStack(int _playToStack)
|
|||
settings->setValue("interface/playtostack", playToStack);
|
||||
}
|
||||
|
||||
void SettingsCache::setStartingHandSize(int _startingHandSize)
|
||||
{
|
||||
startingHandSize = _startingHandSize;
|
||||
settings->setValue("interface/startinghandsize", startingHandSize);
|
||||
}
|
||||
|
||||
void SettingsCache::setAnnotateTokens(int _annotateTokens)
|
||||
{
|
||||
annotateTokens = static_cast<bool>(_annotateTokens);
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ private:
|
|||
bool spectatorNotificationsEnabled;
|
||||
bool doubleClickToPlay;
|
||||
bool playToStack;
|
||||
int startingHandSize;
|
||||
bool annotateTokens;
|
||||
QByteArray tabGameSplitterSizes;
|
||||
bool displayCardNames;
|
||||
|
|
@ -232,6 +233,10 @@ public:
|
|||
{
|
||||
return playToStack;
|
||||
}
|
||||
int getStartingHandSize() const
|
||||
{
|
||||
return startingHandSize;
|
||||
}
|
||||
bool getAnnotateTokens() const
|
||||
{
|
||||
return annotateTokens;
|
||||
|
|
@ -466,6 +471,7 @@ public slots:
|
|||
void setSpectatorNotificationsEnabled(int _spectatorNotificationsEnabled);
|
||||
void setDoubleClickToPlay(int _doubleClickToPlay);
|
||||
void setPlayToStack(int _playToStack);
|
||||
void setStartingHandSize(int _startingHandSize);
|
||||
void setAnnotateTokens(int _annotateTokens);
|
||||
void setTabGameSplitterSizes(const QByteArray &_tabGameSplitterSizes);
|
||||
void setDisplayCardNames(int _displayCardNames);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue