Пример #1
0
bool CardDatabaseDisplayModel::filterAcceptsRow(int sourceRow, const QModelIndex & /*sourceParent*/) const
{
	CardInfo *info = static_cast<CardDatabaseModel *>(sourceModel())->getCard(sourceRow);
	
	if (!cardNameBeginning.isEmpty())
		if (!info->getName().startsWith(cardNameBeginning, Qt::CaseInsensitive))
			return false;
	
	if (!cardName.isEmpty())
		if (!info->getName().contains(cardName, Qt::CaseInsensitive))
			return false;
	
	if (!cardText.isEmpty())
		if (!info->getText().contains(cardText, Qt::CaseInsensitive))
			return false;
	
	if (!cardColors.isEmpty())
		if (QSet<QString>::fromList(info->getColors()).intersect(cardColors).isEmpty() && !(info->getColors().isEmpty() && cardColors.contains("X")))
			return false;
		
	if (!cardTypes.isEmpty())
		if (!cardTypes.contains(info->getMainCardType()))
			return false;

	return true;
}
Пример #2
0
void DlgEditTokens::tokenSelectionChanged(const QModelIndex &current, const QModelIndex & /* previous */)
{
    const QModelIndex realIndex = cardDatabaseDisplayModel->mapToSource(current);
    CardInfo *cardInfo = current.row() >= 0 ? cardDatabaseModel->getCard(realIndex.row()) : cardDatabaseModel->getDatabase()->getCard();
    if (!cardInfo->getName().isEmpty())
        currentCard = cardInfo;
    else
        currentCard = 0;
    
    nameEdit->setText(cardInfo->getName());
    const QString cardColor = cardInfo->getColors().isEmpty() ? QString() : (cardInfo->getColors().size() > 1 ? QString("m") : cardInfo->getColors().first());
    colorEdit->setCurrentIndex(colorEdit->findData(cardColor, Qt::UserRole, Qt::MatchFixedString));
    ptEdit->setText(cardInfo->getPowTough());
    annotationEdit->setText(cardInfo->getText());
}
Пример #3
0
CardInfo *OracleImporter::addCard(const QString &setName,
								  QString cardName,
								  bool isToken,
								  int cardId,
								  const QString &cardCost,
								  const QString &cardType,
								  const QString &cardPT,
								  int cardLoyalty,
								  const QStringList &cardText)
{
	QString fullCardText = cardText.join("\n");
	bool splitCard = false;
	if (cardName.contains('(')) {
		cardName.remove(QRegExp(" \\(.*\\)"));
		splitCard = true;
	}
	// Workaround for card name weirdness
	if (cardName.contains("XX"))
		cardName.remove("XX");
	cardName = cardName.replace("Æ", "AE");
        cardName = cardName.replace("’", "'");

	CardInfo *card;
	if (cardHash.contains(cardName)) {
		card = cardHash.value(cardName);
		if (splitCard && !card->getText().contains(fullCardText))
			card->setText(card->getText() + "\n---\n" + fullCardText);
	} else {
		bool mArtifact = false;
		if (cardType.endsWith("Artifact"))
			for (int i = 0; i < cardText.size(); ++i)
				if (cardText[i].contains("{T}") && cardText[i].contains("to your mana pool"))
					mArtifact = true;
					
		QStringList colors;
		QStringList allColors = QStringList() << "W" << "U" << "B" << "R" << "G";
		for (int i = 0; i < allColors.size(); i++)
			if (cardCost.contains(allColors[i]))
				colors << allColors[i];
		
		if (cardText.contains(cardName + " is white."))
			colors << "W";
		if (cardText.contains(cardName + " is blue."))
			colors << "U";
		if (cardText.contains(cardName + " is black."))
			colors << "B";
		if (cardText.contains(cardName + " is red."))
			colors << "R";
		if (cardText.contains(cardName + " is green."))
			colors << "G";
		
		bool cipt = (cardText.contains(cardName + " enters the battlefield tapped."));
		
		card = new CardInfo(this, cardName, isToken, cardCost, cardType, cardPT, fullCardText, colors, cardLoyalty, cipt);
		int tableRow = 1;
		QString mainCardType = card->getMainCardType();
		if ((mainCardType == "Land") || mArtifact)
			tableRow = 0;
		else if ((mainCardType == "Sorcery") || (mainCardType == "Instant"))
			tableRow = 3;
		else if (mainCardType == "Creature")
			tableRow = 2;
		card->setTableRow(tableRow);
		
		cardHash.insert(cardName, card);
	}
	card->setPicURL(setName, getPictureUrl(pictureUrl, cardId, cardName, setName));
	card->setPicURLHq(setName, getPictureUrl(pictureUrlHq, cardId, cardName, setName));
	card->setPicURLSt(setName, getPictureUrl(pictureUrlSt, cardId, cardName, setName));
	return card;
}