mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-29 18:13:55 -07:00
Add a guard in case the printing info is empty for a related card. (#6087)
Took 4 hours 19 minutes Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
268559d8de
commit
ba794c2b60
2 changed files with 24 additions and 4 deletions
|
|
@ -460,8 +460,21 @@ bool CardDatabase::isPreferredPrinting(const CardRef &cardRef) const
|
||||||
|
|
||||||
ExactCard CardDatabase::getCardFromSameSet(const QString &cardName, const PrintingInfo &otherPrinting) const
|
ExactCard CardDatabase::getCardFromSameSet(const QString &cardName, const PrintingInfo &otherPrinting) const
|
||||||
{
|
{
|
||||||
|
// The source card does not have a printing defined, which means we can't get a card from the same set.
|
||||||
|
if (otherPrinting == PrintingInfo()) {
|
||||||
|
return getCard({cardName});
|
||||||
|
}
|
||||||
|
|
||||||
|
// The source card does have a printing defined, which means we can attempt to get a card from the same set.
|
||||||
PrintingInfo relatedPrinting = getSpecificPrinting(cardName, otherPrinting.getSet()->getCorrectedShortName(), "");
|
PrintingInfo relatedPrinting = getSpecificPrinting(cardName, otherPrinting.getSet()->getCorrectedShortName(), "");
|
||||||
return ExactCard(guessCard({cardName}).getCardPtr(), relatedPrinting);
|
ExactCard relatedCard = ExactCard(guessCard({cardName}).getCardPtr(), relatedPrinting);
|
||||||
|
|
||||||
|
// We didn't find a card from the same set, just try to find any card with the same name.
|
||||||
|
if (!relatedCard) {
|
||||||
|
return getCard({cardName});
|
||||||
|
}
|
||||||
|
|
||||||
|
return relatedCard;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CardDatabase::refreshCachedReverseRelatedCards()
|
void CardDatabase::refreshCachedReverseRelatedCards()
|
||||||
|
|
|
||||||
|
|
@ -1899,6 +1899,11 @@ void Player::actCreateRelatedCard()
|
||||||
if (createRelatedFromRelation(sourceCard, cardRelation) && cardRelation->getCanCreateAnother()) {
|
if (createRelatedFromRelation(sourceCard, cardRelation) && cardRelation->getCanCreateAnother()) {
|
||||||
ExactCard relatedCard = CardDatabaseManager::getInstance()->getCardFromSameSet(
|
ExactCard relatedCard = CardDatabaseManager::getInstance()->getCardFromSameSet(
|
||||||
cardRelation->getName(), sourceCard->getCard().getPrinting());
|
cardRelation->getName(), sourceCard->getCard().getPrinting());
|
||||||
|
|
||||||
|
if (!relatedCard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
setLastToken(relatedCard.getCardPtr());
|
setLastToken(relatedCard.getCardPtr());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2064,6 +2069,10 @@ void Player::createCard(const CardItem *sourceCard,
|
||||||
ExactCard relatedCard = CardDatabaseManager::getInstance()->getCardFromSameSet(cardInfo->getName(),
|
ExactCard relatedCard = CardDatabaseManager::getInstance()->getCardFromSameSet(cardInfo->getName(),
|
||||||
sourceCard->getCard().getPrinting());
|
sourceCard->getCard().getPrinting());
|
||||||
|
|
||||||
|
if (!relatedCard) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (attachType) {
|
switch (attachType) {
|
||||||
case CardRelation::DoesNotAttach:
|
case CardRelation::DoesNotAttach:
|
||||||
cmd.set_target_zone("table");
|
cmd.set_target_zone("table");
|
||||||
|
|
@ -4169,9 +4178,7 @@ void Player::addRelatedCardActions(const CardItem *card, QMenu *cardMenu)
|
||||||
for (const CardRelation *cardRelation : relatedCards) {
|
for (const CardRelation *cardRelation : relatedCards) {
|
||||||
ExactCard relatedCard = CardDatabaseManager::getInstance()->getCardFromSameSet(cardRelation->getName(),
|
ExactCard relatedCard = CardDatabaseManager::getInstance()->getCardFromSameSet(cardRelation->getName(),
|
||||||
card->getCard().getPrinting());
|
card->getCard().getPrinting());
|
||||||
if (!relatedCard) {
|
|
||||||
relatedCard = CardDatabaseManager::getInstance()->getCard({cardRelation->getName()});
|
|
||||||
}
|
|
||||||
if (!relatedCard) {
|
if (!relatedCard) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue