From 04e80304ef1f4754e760e39b2dcf06d5f6ffc8b1 Mon Sep 17 00:00:00 2001 From: arxanas Date: Tue, 8 Jul 2014 22:56:18 -0400 Subject: [PATCH] Fix #184: Deck loader reads 4x cardname correctly. --- common/decklist.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/common/decklist.cpp b/common/decklist.cpp index 8e877ba9..52ef6415 100644 --- a/common/decklist.cpp +++ b/common/decklist.cpp @@ -547,14 +547,21 @@ bool DeckList::loadFromStream_Plain(QTextStream &in) line.remove(rx); line = line.simplified(); - int i = line.indexOf(' '); + int cardNameStart = i + 1; + + // If the count ends with an 'x', ignore it. For example, + // "4x Storm Crow" will count 4 correctly. + if (i > 0 && line[i - 1] == 'x') { + i--; + } + bool ok; int number = line.left(i).toInt(&ok); if (!ok) continue; - QString cardName = line.mid(i + 1); + QString cardName = line.mid(cardNameStart); // Common differences between cockatrice's card names // and what's commonly used in decklists rx.setPattern("’");