mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
Added verify test to check missing second face cards in sets, fixed missing cards;
This commit is contained in:
parent
7aac355f4a
commit
1b430e5d99
9 changed files with 99 additions and 34 deletions
|
|
@ -10,6 +10,8 @@ import mage.abilities.hint.Hint;
|
|||
import mage.abilities.hint.HintUtils;
|
||||
import mage.abilities.keyword.FlashbackAbility;
|
||||
import mage.abilities.mana.ActivatedManaAbilityImpl;
|
||||
import mage.cards.repository.CardInfo;
|
||||
import mage.cards.repository.CardRepository;
|
||||
import mage.cards.repository.PluginClassloaderRegistery;
|
||||
import mage.constants.*;
|
||||
import mage.counters.Counter;
|
||||
|
|
@ -683,6 +685,7 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
|
||||
@Override
|
||||
public final Card getSecondCardFace() {
|
||||
// init second side card on first call
|
||||
if (secondSideCardClazz == null && secondSideCard == null) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -691,14 +694,12 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
return secondSideCard;
|
||||
}
|
||||
|
||||
List<ExpansionSet.SetCardInfo> cardInfo = Sets.findSet(expansionSetCode).findCardInfoByClass(secondSideCardClazz);
|
||||
if (cardInfo.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ExpansionSet.SetCardInfo info = cardInfo.get(0);
|
||||
return secondSideCard = createCard(secondSideCardClazz,
|
||||
new CardSetInfo(info.getName(), expansionSetCode, info.getCardNumber(), info.getRarity(), info.getGraphicInfo()));
|
||||
// must be non strict search in any sets, not one set
|
||||
// example: if set contains only one card side, e.g. dev forget to add it
|
||||
// verify test checks missing side cards in test_checkMissingSecondSideCardsInSets
|
||||
CardInfo cardInfo = CardRepository.instance.findPreferedCoreExpansionCardByClassName(secondSideCardClazz.getCanonicalName(), expansionSetCode);
|
||||
secondSideCard = cardInfo.getCard();
|
||||
return secondSideCard;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -971,5 +972,5 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -406,14 +406,21 @@ public enum CardRepository {
|
|||
}
|
||||
|
||||
public CardInfo findPreferedCoreExpansionCard(String name, boolean caseInsensitive, String preferedSetCode) {
|
||||
|
||||
List<CardInfo> cards;
|
||||
if (caseInsensitive) {
|
||||
cards = findCardsCaseInsensitive(name);
|
||||
} else {
|
||||
cards = findCards(name);
|
||||
}
|
||||
return findPreferedOrLatestCard(cards, preferedSetCode);
|
||||
}
|
||||
|
||||
public CardInfo findPreferedCoreExpansionCardByClassName(String canonicalClassName, String preferedSetCode) {
|
||||
List<CardInfo> cards = findCardsByClass(canonicalClassName);
|
||||
return findPreferedOrLatestCard(cards, preferedSetCode);
|
||||
}
|
||||
|
||||
private CardInfo findPreferedOrLatestCard(List<CardInfo> cards, String preferedSetCode) {
|
||||
if (!cards.isEmpty()) {
|
||||
Date lastReleaseDate = null;
|
||||
Date lastExpansionDate = null;
|
||||
|
|
@ -469,6 +476,16 @@ public enum CardRepository {
|
|||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<CardInfo> findCardsByClass(String canonicalClassName) {
|
||||
try {
|
||||
QueryBuilder<CardInfo, Object> queryBuilder = cardDao.queryBuilder();
|
||||
queryBuilder.where().eq("className", new SelectArg(canonicalClassName));
|
||||
return cardDao.query(queryBuilder.prepare());
|
||||
} catch (SQLException ex) {
|
||||
}
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public List<CardInfo> findCardsCaseInsensitive(String name) {
|
||||
try {
|
||||
String sqlName = name.toLowerCase(Locale.ENGLISH).replaceAll("'", "''");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue