mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-01 11:03:54 -07:00
refactor: remove cipt param from Player::playCard (#5266)
This commit is contained in:
parent
245d51caea
commit
c716f85962
4 changed files with 10 additions and 15 deletions
|
|
@ -319,8 +319,7 @@ void ArrowAttachItem::attachCards(CardItem *startCard, const CardItem *targetCar
|
||||||
|
|
||||||
// move card onto table first if attaching from some other zone
|
// move card onto table first if attaching from some other zone
|
||||||
if (startZone->getName() != "table") {
|
if (startZone->getName() != "table") {
|
||||||
auto info = startCard->getInfo();
|
player->playCardToTable(startCard, false);
|
||||||
player->playCardToTable(startCard, false, info ? info->getCipt() : false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Command_AttachCard cmd;
|
Command_AttachCard cmd;
|
||||||
|
|
|
||||||
|
|
@ -387,7 +387,7 @@ void CardItem::playCard(bool faceDown)
|
||||||
if (SettingsCache::instance().getClickPlaysAllSelected()) {
|
if (SettingsCache::instance().getClickPlaysAllSelected()) {
|
||||||
faceDown ? zone->getPlayer()->actPlayFacedown() : zone->getPlayer()->actPlay();
|
faceDown ? zone->getPlayer()->actPlayFacedown() : zone->getPlayer()->actPlay();
|
||||||
} else {
|
} else {
|
||||||
zone->getPlayer()->playCard(this, faceDown, info ? info->getCipt() : false);
|
zone->getPlayer()->playCard(this, faceDown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1380,10 +1380,7 @@ void Player::moveOneCardUntil(CardItem *card)
|
||||||
if (isMatch && movingCardsUntilAutoPlay) {
|
if (isMatch && movingCardsUntilAutoPlay) {
|
||||||
// Directly calling playCard will deadlock, since we are already in the middle of processing an event.
|
// Directly calling playCard will deadlock, since we are already in the middle of processing an event.
|
||||||
// Use QTimer::singleShot to queue up the playCard on the event loop.
|
// Use QTimer::singleShot to queue up the playCard on the event loop.
|
||||||
QTimer::singleShot(0, this, [card, this] {
|
QTimer::singleShot(0, this, [card, this] { playCard(card, false); });
|
||||||
bool cipt = card && card->getInfo() && card->getInfo()->getCipt();
|
|
||||||
playCard(card, false, cipt);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (zones.value("deck")->getCards().empty() || !card) {
|
if (zones.value("deck")->getCards().empty() || !card) {
|
||||||
|
|
@ -2648,7 +2645,7 @@ void Player::processCardAttachment(const ServerInfo_Player &info)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::playCard(CardItem *card, bool faceDown, bool tapped)
|
void Player::playCard(CardItem *card, bool faceDown)
|
||||||
{
|
{
|
||||||
if (card == nullptr) {
|
if (card == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -2685,7 +2682,7 @@ void Player::playCard(CardItem *card, bool faceDown, bool tapped)
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
cardToMove->set_pt(info->getPowTough().toStdString());
|
cardToMove->set_pt(info->getPowTough().toStdString());
|
||||||
}
|
}
|
||||||
cardToMove->set_tapped(faceDown ? false : tapped);
|
cardToMove->set_tapped(!faceDown && info->getCipt());
|
||||||
if (tableRow != 3)
|
if (tableRow != 3)
|
||||||
cmd.set_target_zone("table");
|
cmd.set_target_zone("table");
|
||||||
cmd.set_x(gridPoint.x());
|
cmd.set_x(gridPoint.x());
|
||||||
|
|
@ -2698,7 +2695,7 @@ void Player::playCard(CardItem *card, bool faceDown, bool tapped)
|
||||||
* Like {@link Player::playCard}, but forces the card to be played to the table zone.
|
* Like {@link Player::playCard}, but forces the card to be played to the table zone.
|
||||||
* Cards with tablerow 3 (the stack) will be played to tablerow 1 (the noncreatures row).
|
* Cards with tablerow 3 (the stack) will be played to tablerow 1 (the noncreatures row).
|
||||||
*/
|
*/
|
||||||
void Player::playCardToTable(CardItem *card, bool faceDown, bool tapped)
|
void Player::playCardToTable(CardItem *card, bool faceDown)
|
||||||
{
|
{
|
||||||
if (card == nullptr) {
|
if (card == nullptr) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -2727,7 +2724,7 @@ void Player::playCardToTable(CardItem *card, bool faceDown, bool tapped)
|
||||||
if (!faceDown) {
|
if (!faceDown) {
|
||||||
cardToMove->set_pt(info->getPowTough().toStdString());
|
cardToMove->set_pt(info->getPowTough().toStdString());
|
||||||
}
|
}
|
||||||
cardToMove->set_tapped(faceDown ? false : tapped);
|
cardToMove->set_tapped(!faceDown && info->getCipt());
|
||||||
cmd.set_target_zone("table");
|
cmd.set_target_zone("table");
|
||||||
cmd.set_x(gridPoint.x());
|
cmd.set_x(gridPoint.x());
|
||||||
cmd.set_y(gridPoint.y());
|
cmd.set_y(gridPoint.y());
|
||||||
|
|
@ -3574,8 +3571,7 @@ void Player::playSelectedCards(const bool faceDown)
|
||||||
|
|
||||||
for (auto &card : selectedCards) {
|
for (auto &card : selectedCards) {
|
||||||
if (card && !isUnwritableRevealZone(card->getZone()) && card->getZone()->getName() != "table") {
|
if (card && !isUnwritableRevealZone(card->getZone()) && card->getZone()->getName() != "table") {
|
||||||
const bool cipt = !faceDown && card->getInfo() ? card->getInfo()->getCipt() : false;
|
playCard(card, faceDown);
|
||||||
playCard(card, faceDown, cipt);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -394,8 +394,8 @@ public:
|
||||||
QRectF boundingRect() const override;
|
QRectF boundingRect() const override;
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
||||||
|
|
||||||
void playCard(CardItem *c, bool faceDown, bool tapped);
|
void playCard(CardItem *c, bool faceDown);
|
||||||
void playCardToTable(CardItem *c, bool faceDown, bool tapped);
|
void playCardToTable(CardItem *c, bool faceDown);
|
||||||
void addCard(CardItem *c);
|
void addCard(CardItem *c);
|
||||||
void deleteCard(CardItem *c);
|
void deleteCard(CardItem *c);
|
||||||
void addZone(CardZone *z);
|
void addZone(CardZone *z);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue