mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-02 11:33:55 -07:00
[CardInfo] refactor some fields into a UiAttributes struct (#6322)
* refactor CardInfo * refactor everything else
This commit is contained in:
parent
722344967f
commit
9a3104c5ac
12 changed files with 73 additions and 87 deletions
|
|
@ -60,7 +60,8 @@ void AbstractCardItem::refreshCardInfo()
|
|||
exactCard = CardDatabaseManager::query()->getCard(cardRef);
|
||||
|
||||
if (!exactCard && !cardRef.name.isEmpty()) {
|
||||
auto info = CardInfo::newInstance(cardRef.name, "", true, {}, {}, {}, {}, false, false, -1, false);
|
||||
CardInfo::UiAttributes attributes = {.tableRow = -1};
|
||||
auto info = CardInfo::newInstance(cardRef.name, "", true, {}, {}, {}, {}, attributes);
|
||||
exactCard = ExactCard(info);
|
||||
}
|
||||
if (exactCard) {
|
||||
|
|
|
|||
|
|
@ -238,8 +238,8 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
|||
if (startZone->getName().compare("hand") == 0) {
|
||||
startCard->playCard(false);
|
||||
CardInfoPtr ci = startCard->getCard().getCardPtr();
|
||||
if (ci && ((!SettingsCache::instance().getPlayToStack() && ci->getTableRow() == 3) ||
|
||||
(SettingsCache::instance().getPlayToStack() && ci->getTableRow() != 0 &&
|
||||
if (ci && ((!SettingsCache::instance().getPlayToStack() && ci->getUiAttributes().tableRow == 3) ||
|
||||
(SettingsCache::instance().getPlayToStack() && ci->getUiAttributes().tableRow != 0 &&
|
||||
startCard->getZone()->getName().toStdString() != "stack")))
|
||||
cmd.set_start_zone("stack");
|
||||
else
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
|
|||
|
||||
const CardInfo &info = exactCard.getInfo();
|
||||
|
||||
int tableRow = info.getTableRow();
|
||||
int tableRow = info.getUiAttributes().tableRow;
|
||||
bool playToStack = SettingsCache::instance().getPlayToStack();
|
||||
QString currentZone = card->getZone()->getName();
|
||||
if (currentZone == "stack" && tableRow == 3) {
|
||||
|
|
@ -72,13 +72,13 @@ void PlayerActions::playCard(CardItem *card, bool faceDown)
|
|||
cmd.set_x(-1);
|
||||
cmd.set_y(0);
|
||||
} else {
|
||||
tableRow = faceDown ? 2 : info.getTableRow();
|
||||
tableRow = faceDown ? 2 : info.getUiAttributes().tableRow;
|
||||
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - tableRow));
|
||||
cardToMove->set_face_down(faceDown);
|
||||
if (!faceDown) {
|
||||
cardToMove->set_pt(info.getPowTough().toStdString());
|
||||
}
|
||||
cardToMove->set_tapped(!faceDown && info.getCipt());
|
||||
cardToMove->set_tapped(!faceDown && info.getUiAttributes().cipt);
|
||||
if (tableRow != 3)
|
||||
cmd.set_target_zone("table");
|
||||
cmd.set_x(gridPoint.x());
|
||||
|
|
@ -111,7 +111,7 @@ void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
|
|||
|
||||
const CardInfo &info = exactCard.getInfo();
|
||||
|
||||
int tableRow = faceDown ? 2 : info.getTableRow();
|
||||
int tableRow = faceDown ? 2 : info.getUiAttributes().tableRow;
|
||||
// default instant/sorcery cards to the noncreatures row
|
||||
if (tableRow > 2) {
|
||||
tableRow = 1;
|
||||
|
|
@ -122,7 +122,7 @@ void PlayerActions::playCardToTable(const CardItem *card, bool faceDown)
|
|||
if (!faceDown) {
|
||||
cardToMove->set_pt(info.getPowTough().toStdString());
|
||||
}
|
||||
cardToMove->set_tapped(!faceDown && info.getCipt());
|
||||
cardToMove->set_tapped(!faceDown && info.getUiAttributes().cipt);
|
||||
cmd.set_target_zone("table");
|
||||
cmd.set_x(gridPoint.x());
|
||||
cmd.set_y(gridPoint.y());
|
||||
|
|
@ -859,7 +859,7 @@ void PlayerActions::actCreateToken()
|
|||
ExactCard correctedCard = CardDatabaseManager::query()->guessCard({lastTokenInfo.name, lastTokenInfo.providerId});
|
||||
if (correctedCard) {
|
||||
lastTokenInfo.name = correctedCard.getName();
|
||||
lastTokenTableRow = TableZone::clampValidTableRow(2 - correctedCard.getInfo().getTableRow());
|
||||
lastTokenTableRow = TableZone::clampValidTableRow(2 - correctedCard.getInfo().getUiAttributes().tableRow);
|
||||
if (lastTokenInfo.pt.isEmpty()) {
|
||||
lastTokenInfo.pt = correctedCard.getInfo().getPowTough();
|
||||
}
|
||||
|
|
@ -910,7 +910,7 @@ void PlayerActions::setLastToken(CardInfoPtr cardInfo)
|
|||
.providerId =
|
||||
SettingsCache::instance().cardOverrides().getCardPreferenceOverride(cardInfo->getName())};
|
||||
|
||||
lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getTableRow());
|
||||
lastTokenTableRow = TableZone::clampValidTableRow(2 - cardInfo->getUiAttributes().tableRow);
|
||||
|
||||
utilityMenu->setAndEnableCreateAnotherTokenAction(tr("C&reate another %1 token").arg(lastTokenInfo.name));
|
||||
}
|
||||
|
|
@ -1080,7 +1080,7 @@ void PlayerActions::createCard(const CardItem *sourceCard,
|
|||
|
||||
// get the target token's location
|
||||
// TODO: Define this QPoint into its own function along with the one below
|
||||
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - cardInfo->getTableRow()));
|
||||
QPoint gridPoint = QPoint(-1, TableZone::clampValidTableRow(2 - cardInfo->getUiAttributes().tableRow));
|
||||
|
||||
// create the token for the related card
|
||||
Command_CreateToken cmd;
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ void TableZoneLogic::addCardImpl(CardItem *card, int _x, int _y)
|
|||
if (!card->getFaceDown() && card->getPT().isEmpty()) {
|
||||
card->setPT(card->getCardInfo().getPowTough());
|
||||
}
|
||||
if (card->getCardInfo().getCipt() && card->getCardInfo().getLandscapeOrientation()) {
|
||||
if (card->getCardInfo().getUiAttributes().cipt && card->getCardInfo().getUiAttributes().landscapeOrientation) {
|
||||
card->setDoesntUntap(true);
|
||||
}
|
||||
card->setGridPoint(QPoint(_x, _y));
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue