[Refactor] Move card selection actions to GameScene and p/t parsing to CardState

This commit is contained in:
Lukas Brübach 2026-10-06 16:22:16 +02:00 • committed by GitHub
parent 680bc82dbe
commit 8347258075
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 121 additions and 116 deletions

View file

@ -65,6 +65,37 @@ void CardState::setFaceDown(bool _facedown)
emit stateChanged();
}
QVariantList CardState::parsePT(const QString &pt)
{
QVariantList ptList = QVariantList();
if (!pt.isEmpty()) {
int sep = pt.indexOf('/');
if (sep == 0) {
ptList.append(QVariant(pt.mid(1))); // cut off starting '/' and take full string
} else {
int start = 0;
for (;;) {
QString item = pt.mid(start, sep - start);
if (item.isEmpty()) {
ptList.append(QVariant(QString()));
} else if (item[0] == '+') {
ptList.append(QVariant(item.mid(1).toInt())); // add as int
} else if (item[0] == '-') {
ptList.append(QVariant(item.toInt())); // add as int
} else {
ptList.append(QVariant(item)); // add as qstring
}
if (sep == -1) {
break;
}
start = sep + 1;
sep = pt.indexOf('/', start);
}
}
}
return ptList;
}
void CardState::setZone(CardZoneLogic *_zone)
{
if (zone == _zone) {