tryFindCopies method
Looks up a card in this collection by its cardSet
and orderInSet
.
If the card is found, returns a tuple of the card and the number of
copies of that card in this collection. If the card is not found, returns
a record of null
and 0
.
NOTE: This method is not highly optimized.
Implementation
({Card? card, int count}) tryFindCopies(CardSet cardSet, int orderInSet) {
final cardSetMap = _cards[cardSet];
if (cardSetMap == null) {
return (card: null, count: 0);
}
for (final card in cardSetMap.keys) {
if (card.orderInSet == orderInSet) {
return (card: card, count: cardSetMap[card] ?? 0);
}
}
return (card: null, count: 0);
}