mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-20 09:22:15 -07:00
refactor
This commit is contained in:
parent
d3b2cd8261
commit
8170a428e1
2 changed files with 19 additions and 19 deletions
|
|
@ -3479,7 +3479,7 @@ static bool isUnwritableRevealZone(CardZone *zone)
|
|||
return false;
|
||||
}
|
||||
|
||||
void Player::actPlay()
|
||||
void Player::playSelectedCards(const bool faceDown)
|
||||
{
|
||||
QList<CardItem *> selectedCards;
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
|
|
@ -3487,17 +3487,30 @@ void Player::actPlay()
|
|||
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())) {
|
||||
const bool cipt = card->getInfo() ? card->getInfo()->getCipt() : false;
|
||||
playCard(card, false, cipt);
|
||||
const bool cipt = !faceDown && card->getInfo() ? card->getInfo()->getCipt() : false;
|
||||
playCard(card, faceDown, cipt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actPlay()
|
||||
{
|
||||
playSelectedCards(false);
|
||||
}
|
||||
|
||||
void Player::actPlayFacedown()
|
||||
{
|
||||
playSelectedCards(true);
|
||||
}
|
||||
|
||||
void Player::actHide()
|
||||
{
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
|
|
@ -3508,21 +3521,6 @@ void Player::actHide()
|
|||
}
|
||||
}
|
||||
|
||||
void Player::actPlayFacedown()
|
||||
{
|
||||
QList<CardItem *> selectedCards;
|
||||
for (const auto &item : scene()->selectedItems()) {
|
||||
auto *card = static_cast<CardItem *>(item);
|
||||
selectedCards.append(card);
|
||||
}
|
||||
|
||||
for (auto &card : selectedCards) {
|
||||
if (card && !isUnwritableRevealZone(card->getZone())) {
|
||||
playCard(card, true, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Player::actReveal(QAction *action)
|
||||
{
|
||||
const int otherPlayerId = action->data().toInt();
|
||||
|
|
|
|||
|
|
@ -224,8 +224,8 @@ private slots:
|
|||
void actFlowT();
|
||||
void actSetAnnotation();
|
||||
void actPlay();
|
||||
void actHide();
|
||||
void actPlayFacedown();
|
||||
void actHide();
|
||||
void actReveal(QAction *action);
|
||||
void refreshShortcuts();
|
||||
|
||||
|
|
@ -323,6 +323,8 @@ private:
|
|||
void addPlayerToList(QMenu *playerList, Player *player);
|
||||
static void removePlayerFromList(QMenu *playerList, Player *player);
|
||||
|
||||
void playSelectedCards(bool faceDown = false);
|
||||
|
||||
QRectF bRect;
|
||||
|
||||
QMap<int, AbstractCounter *> counters;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue