mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 17:44:01 -07:00
fix hashes (for real this time)
This commit is contained in:
parent
ebf7b70ff8
commit
f9fe7484a5
1 changed files with 10 additions and 8 deletions
|
|
@ -656,15 +656,17 @@ static QString computeDeckHash(const DeckList &deckList)
|
|||
auto mainDeckNodes = deckList.getCardNodes({DECK_ZONE_MAIN});
|
||||
auto sideDeckNodes = deckList.getCardNodes({DECK_ZONE_SIDE});
|
||||
|
||||
QStringList cardList;
|
||||
|
||||
static auto repeatName = [](const DecklistCardNode *node, const QString &prefix = {}) {
|
||||
return (prefix + node->getName().toLower()).repeated(node->getNumber());
|
||||
static auto nodesToCardList = [](const QList<const DecklistCardNode *> &nodes, const QString &prefix = {}) {
|
||||
QStringList result;
|
||||
for (auto node : nodes) {
|
||||
for (int i = 0; i < node->getNumber(); ++i) {
|
||||
result.append(prefix + node->getName().toLower());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
};
|
||||
std::transform(mainDeckNodes.cbegin(), mainDeckNodes.cend(), std::back_inserter(cardList),
|
||||
[](auto node) { return repeatName(node); });
|
||||
std::transform(sideDeckNodes.cbegin(), sideDeckNodes.cend(), std::back_inserter(cardList),
|
||||
[](auto node) { return repeatName(node, "SB:"); });
|
||||
|
||||
QStringList cardList = nodesToCardList(mainDeckNodes) + nodesToCardList(sideDeckNodes, "SB:");
|
||||
|
||||
cardList.sort();
|
||||
QByteArray deckHashArray = QCryptographicHash::hash(cardList.join(";").toUtf8(), QCryptographicHash::Sha1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue