fix issues with #4648 (#4864)

This commit is contained in:
ebbit1q 2023-08-18 18:34:17 +02:00 committed by GitHub
parent ac5dc2578a
commit 90679d5669
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 21 additions and 10 deletions

View file

@ -71,7 +71,9 @@
#include <QPainter>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QTimer>
// milliseconds in between triggers of the move top cards until action
static constexpr int MOVE_TOP_CARD_UNTIL_INTERVAL = 100;
PlayerArea::PlayerArea(QGraphicsItem *parentItem) : QObject(), QGraphicsItem(parentItem)
{
@ -108,9 +110,9 @@ void PlayerArea::setPlayerZoneId(int _playerZoneId)
}
Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, TabGame *_parent)
: QObject(_parent), game(_parent), shortcutsActive(false), lastTokenDestroy(true), lastTokenTableRow(0), id(_id),
active(false), local(_local), judge(_judge), mirrored(false), handVisible(false), conceded(false), zoneId(0),
dialogSemaphore(false), deck(nullptr)
: QObject(_parent), game(_parent), movingCardsUntil(false), shortcutsActive(false), lastTokenDestroy(true),
lastTokenTableRow(0), id(_id), active(false), local(_local), judge(_judge), mirrored(false), handVisible(false),
conceded(false), zoneId(0), dialogSemaphore(false), deck(nullptr)
{
userInfo = new ServerInfo_User;
userInfo->CopyFrom(info);
@ -533,6 +535,11 @@ Player::Player(const ServerInfo_User &info, int _id, bool _local, bool _judge, T
addPlayer(player);
}
moveTopCardTimer = new QTimer(this);
moveTopCardTimer->setInterval(MOVE_TOP_CARD_UNTIL_INTERVAL);
moveTopCardTimer->setSingleShot(true);
connect(moveTopCardTimer, &QTimer::timeout, [this]() { actMoveTopCardToPlay(); });
rearrangeZones();
retranslateUi();
connect(&SettingsCache::instance().shortcuts(), SIGNAL(shortCutChanged()), this, SLOT(refreshShortcuts()));
@ -1301,6 +1308,8 @@ void Player::actMoveTopCardsToExile()
void Player::actMoveTopCardsUntil()
{
moveTopCardTimer->stop();
movingCardsUntil = false;
QString expr = previousMovingCardsUntilExpr;
for (;;) {
bool ok;
@ -1328,13 +1337,13 @@ void Player::actMoveTopCardsUntil()
}
}
void Player::moveOneCardUntil(const QString &cardName)
void Player::moveOneCardUntil(const CardInfoPtr card)
{
auto card = db->getCard(cardName);
moveTopCardTimer->stop();
if (zones.value("deck")->getCards().empty() || card.isNull() || movingCardsUntilFilter.check(card)) {
movingCardsUntil = false;
} else {
QTimer::singleShot(100, [this]() { actMoveTopCardToPlay(); });
moveTopCardTimer->start();
}
}
@ -2183,7 +2192,7 @@ void Player::eventMoveCard(const Event_MoveCard &event, const GameEventContext &
updateCardMenu(card);
if (movingCardsUntil && startZoneString == "deck" && targetZone->getName() == "stack") {
moveOneCardUntil(card->getName());
moveOneCardUntil(card->getInfo());
}
}