clicking to play can now play all selected (#5254)

* play action now applies to all selected cards

* check card zone before applying action

* fix bug with wonky play from deck

* refactor

* don't play card if it's already on table

* add new setting

* make actPlay and friends public

* implement thing

* refactor card_item
This commit is contained in:
RickyRister 2024-12-17 20:43:17 -08:00 committed by GitHub
parent fd5a649246
commit a6b5abf271
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 109 additions and 38 deletions

View file

@ -3540,13 +3540,36 @@ static bool isUnwritableRevealZone(CardZone *zone)
return false;
}
void Player::playSelectedCards(const bool faceDown)
{
QList<CardItem *> selectedCards;
for (const auto &item : scene()->selectedItems()) {
auto *card = static_cast<CardItem *>(item);
selectedCards.append(card);
}
// CardIds will get shuffled downwards when cards leave the deck.
// We need to iterate through the cards in reverse order so cardIds don't get changed out from under us as we play
// out the cards one-by-one.
std::sort(selectedCards.begin(), selectedCards.end(),
[](const auto &card1, const auto &card2) { return card1->getId() > card2->getId(); });
for (auto &card : selectedCards) {
if (card && !isUnwritableRevealZone(card->getZone()) && card->getZone()->getName() != "table") {
const bool cipt = !faceDown && card->getInfo() ? card->getInfo()->getCipt() : false;
playCard(card, faceDown, cipt);
}
}
}
void Player::actPlay()
{
auto *card = game->getActiveCard();
if (card) {
const bool cipt = card->getInfo() ? card->getInfo()->getCipt() : false;
playCard(card, false, cipt);
}
playSelectedCards(false);
}
void Player::actPlayFacedown()
{
playSelectedCards(true);
}
void Player::actHide()
@ -3559,14 +3582,6 @@ void Player::actHide()
}
}
void Player::actPlayFacedown()
{
auto *card = game->getActiveCard();
if (card) {
playCard(card, true, false);
}
}
void Player::actReveal(QAction *action)
{
const int otherPlayerId = action->data().toInt();