From 9e2da24629f400435db7df4ea2a76cf07d812b6b Mon Sep 17 00:00:00 2001 From: Zach H Date: Mon, 6 Jul 2015 08:59:40 -0400 Subject: [PATCH] use QSet for zones --- common/decklist.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/common/decklist.cpp b/common/decklist.cpp index 1287bd69..3c54449e 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -727,6 +727,11 @@ void DeckList::updateDeckHash() { QStringList cardList; bool isValidDeckList = true; + static QSet hashZones, optionalZones; + + hashZones << "main" << "side"; // Zones in deck to be included in hashing process + optionalZones << "tokens"; // Optional zones in deck not included in hashing process + for (int i = 0; i < root->size(); i++) { InnerDecklistNode *node = dynamic_cast(root->at(i)); @@ -735,11 +740,11 @@ void DeckList::updateDeckHash() DecklistCardNode *card = dynamic_cast(node->at(j)); for (int k = 0; k < card->getNumber(); ++k) { - if (node->getName() == "main" || node->getName() == "side") // Mainboard or Sideboard + if (hashZones.contains(node->getName())) // Mainboard or Sideboard { cardList.append((node->getName() == "side" ? "SB:" : "") + card->getName().toLower()); } - else if (node->getName() != "tokens") // Neither Mainboard, Sideboard, or Tokens... cheater? + else if (!optionalZones.contains(node->getName())) // Not a valid zone -> cheater? { isValidDeckList = false; // Deck is invalid }