mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-11 12:54:10 -07:00
[DeckListModel] Refactor: Don't access underlying decklist for iteration
This commit is contained in:
parent
64bb5355ff
commit
49a4bb1a3c
7 changed files with 52 additions and 85 deletions
|
|
@ -599,6 +599,16 @@ QList<ExactCard> DeckListModel::getCardsForZone(const QString &zoneName) const
|
|||
return cards;
|
||||
}
|
||||
|
||||
QList<QString> DeckListModel::getCardNames() const
|
||||
{
|
||||
auto nodes = deckList->getCardNodes();
|
||||
|
||||
QList<QString> names;
|
||||
std::transform(nodes.cbegin(), nodes.cend(), std::back_inserter(names), [](auto node) { return node->getName(); });
|
||||
|
||||
return names;
|
||||
}
|
||||
|
||||
QList<QString> DeckListModel::getZones() const
|
||||
{
|
||||
auto zoneNodes = deckList->getZoneNodes();
|
||||
|
|
@ -632,7 +642,6 @@ int maxAllowedForLegality(const FormatRules &format, const QString &legality)
|
|||
return -1; // unknown legality → treat as illegal
|
||||
}
|
||||
|
||||
|
||||
bool DeckListModel::isCardQuantityLegalForCurrentFormat(const CardInfoPtr cardInfo, int quantity)
|
||||
{
|
||||
auto formatRules = CardDatabaseManager::query()->getFormat(deckList->getGameFormat());
|
||||
|
|
|
|||
|
|
@ -311,6 +311,7 @@ public:
|
|||
|
||||
[[nodiscard]] QList<ExactCard> getCards() const;
|
||||
[[nodiscard]] QList<ExactCard> getCardsForZone(const QString &zoneName) const;
|
||||
[[nodiscard]] QList<QString> getCardNames() const;
|
||||
[[nodiscard]] QList<QString> getZones() const;
|
||||
bool isCardLegalForCurrentFormat(CardInfoPtr cardInfo);
|
||||
bool isCardQuantityLegalForCurrentFormat(CardInfoPtr cardInfo, int quantity);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue