Fix #45: don't send tokens to deckstats.

This commit is contained in:
arxanas
2014-06-30 01:18:05 -04:00
parent 4d6f46b06e
commit 7cbe410172
8 changed files with 105 additions and 47 deletions

View File

@@ -579,16 +579,30 @@ bool DeckList::loadFromFile_Plain(QIODevice *device)
return loadFromStream_Plain(in);
}
struct WriteToStream {
QTextStream &stream;
WriteToStream(QTextStream &_stream) : stream(_stream) {}
void operator()(
const InnerDecklistNode *node,
const DecklistCardNode *card
) {
if (node->getName() == "side") {
stream << "SB: ";
}
stream << QString("%1 %2\n").arg(
card->getNumber()
).arg(
card->getName()
);
}
};
bool DeckList::saveToStream_Plain(QTextStream &out)
{
// Support for this is only possible if the internal structure doesn't get more complicated.
for (int i = 0; i < root->size(); i++) {
InnerDecklistNode *node = dynamic_cast<InnerDecklistNode *>(root->at(i));
for (int j = 0; j < node->size(); j++) {
DecklistCardNode *card = dynamic_cast<DecklistCardNode *>(node->at(j));
out << QString("%1%2 %3\n").arg(node->getName() == "side" ? "SB: " : "").arg(card->getNumber()).arg(card->getName());
}
}
WriteToStream writeToStream(out);
forEachCard(writeToStream);
return true;
}