mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-11-05 09:33:25 -08:00
Fixed no-op, added documentation
This commit is contained in:
parent
39474e286d
commit
560ca53b94
2 changed files with 20 additions and 4 deletions
|
|
@ -234,14 +234,29 @@ QModelIndex DeckStateManager::decrementCard(const ExactCard &card, const QString
|
|||
return {};
|
||||
}
|
||||
|
||||
QString zone = card.getInfo().getIsToken() ? DECK_ZONE_TOKENS : zoneName;
|
||||
QString zone = zoneName;
|
||||
|
||||
QString providerId = card.getPrinting().getUuid();
|
||||
QString collectorNumber = card.getPrinting().getProperty("num");
|
||||
|
||||
QModelIndex idx = deckListModel->findCard(card.getName(), zone, providerId, collectorNumber);
|
||||
|
||||
if (!idx.isValid()) {
|
||||
return {};
|
||||
|
||||
// Tokens are usually added to the token zone, but it is possible for imported/hand-edited
|
||||
// decks to contain them in the main or sideboards. This is why we only try to remove the
|
||||
// token from the token zone if it does not exist in the given zone, allowing us to still
|
||||
// remove it from there.
|
||||
if (card.getInfo().getIsToken()) {
|
||||
zone = DECK_ZONE_TOKENS;
|
||||
idx = deckListModel->findCard(card.getName(), zone, providerId, collectorNumber);
|
||||
|
||||
if (!idx.isValid()) {
|
||||
return {};
|
||||
}
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
bool success = offsetCountAtIndex(idx, -1);
|
||||
|
|
|
|||
|
|
@ -187,17 +187,18 @@ public:
|
|||
///@}
|
||||
|
||||
/**
|
||||
* @brief Adds the given card to the given zone.
|
||||
* @brief Adds the given card to the given zone. Tokens always go to DECK_ZONE_TOKENS, ignoring the given zone.
|
||||
* Saves the operation to history if successful.
|
||||
*
|
||||
* @param card The card to add
|
||||
* @param zoneName The zone to add the card to
|
||||
* @param zoneName The zone to add the card to if the card is not a token
|
||||
* @return The index of the added card
|
||||
*/
|
||||
QModelIndex addCard(const ExactCard &card, const QString &zoneName);
|
||||
|
||||
/**
|
||||
* @brief Removes 1 copy of the given card from the given zone.
|
||||
* If the card is a token and is not in the given zone, then it is removed from DECK_ZONE_TOKENS instead.
|
||||
* Saves the operation to history if successful.
|
||||
*
|
||||
* @param card The card to remove
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue