示例#1
0
bool SideboardPlan::readElement(QXmlStreamReader *xml)
{
	while (!xml->atEnd()) {
		xml->readNext();
		const QString childName = xml->name().toString();
		if (xml->isStartElement()) {
			if (childName == "name")
				name = xml->readElementText();
			else if (childName == "move_card_to_zone") {
				MoveCard_ToZone m;
				while (!xml->atEnd()) {
					xml->readNext();
					const QString childName2 = xml->name().toString();
					if (xml->isStartElement()) {
						if (childName2 == "card_name")
							m.set_card_name(xml->readElementText().toStdString());
						else if (childName2 == "start_zone")
							m.set_start_zone(xml->readElementText().toStdString());
						else if (childName2 == "target_zone")
							m.set_target_zone(xml->readElementText().toStdString());
					} else if (xml->isEndElement() && (childName2 == "move_card_to_zone")) {
						moveList.append(m);
						break;
					}
				}
			}
		} else if (xml->isEndElement() && (childName == "sideboard_plan"))
			return true;
	}
	return false;
}
示例#2
0
QList<MoveCard_ToZone> DeckViewScene::getSideboardPlan() const
{
    QList<MoveCard_ToZone> result;
    QMapIterator<QString, DeckViewCardContainer *> containerIterator(cardContainers);
    while (containerIterator.hasNext()) {
        DeckViewCardContainer *cont = containerIterator.next().value();
        const QList<DeckViewCard *> cardList = cont->getCards();
        for (int i = 0; i < cardList.size(); ++i)
            if (cardList[i]->getOriginZone() != cont->getName()) {
                MoveCard_ToZone m;
                m.set_card_name(cardList[i]->getName().toStdString());
                m.set_start_zone(cardList[i]->getOriginZone().toStdString());
                m.set_target_zone(cont->getName().toStdString());
                result.append(m);
            }
    }
    return result;
}