forked from External/mage
Tests: added checks for errors on card loading (see #4402)
This commit is contained in:
parent
a63f87da2c
commit
7c2511355e
2 changed files with 33 additions and 9 deletions
|
|
@ -43,16 +43,23 @@ public final class CardScanner {
|
|||
private static final Logger logger = Logger.getLogger(CardScanner.class);
|
||||
|
||||
public static void scan() {
|
||||
scan(null);
|
||||
}
|
||||
|
||||
public static void scan(List<String> errorsList) {
|
||||
if (scanned) {
|
||||
return;
|
||||
}
|
||||
scanned = true;
|
||||
|
||||
List<CardInfo> cardsToAdd = new ArrayList<>();
|
||||
int setsUpdatedCount = 0;
|
||||
int setsAddedCount = 0;
|
||||
|
||||
for (ExpansionSet set : Sets.getInstance().values()) {
|
||||
ExpansionInfo expansionInfo = ExpansionRepository.instance.getSetByCode(set.getCode());
|
||||
if (expansionInfo == null) {
|
||||
setsAddedCount += 1;
|
||||
ExpansionRepository.instance.add(new ExpansionInfo(set));
|
||||
} else if (!expansionInfo.name.equals(set.getName())
|
||||
|| !expansionInfo.code.equals(set.getCode())
|
||||
|
|
@ -61,17 +68,26 @@ public final class CardScanner {
|
|||
|| expansionInfo.type != set.getSetType()
|
||||
|| expansionInfo.boosters != set.hasBoosters()
|
||||
|| expansionInfo.basicLands != set.hasBasicLands()) {
|
||||
setsUpdatedCount += 1;
|
||||
ExpansionRepository.instance.update(expansionInfo);
|
||||
}
|
||||
}
|
||||
ExpansionRepository.instance.setContentVersion(ExpansionRepository.instance.getContentVersionConstant());
|
||||
|
||||
if (setsAddedCount > 0) {
|
||||
logger.info("DB: need to add " + setsUpdatedCount + " new sets");
|
||||
}
|
||||
if (setsUpdatedCount > 0) {
|
||||
logger.info("DB: need to update " + setsUpdatedCount + " sets");
|
||||
}
|
||||
|
||||
for (ExpansionSet set : Sets.getInstance().values()) {
|
||||
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
||||
if (CardRepository.instance.findCard(set.getCode(), setInfo.getCardNumber()) == null) {
|
||||
Card card = CardImpl.createCard(setInfo.getCardClass(),
|
||||
new CardSetInfo(setInfo.getName(), set.getCode(), setInfo.getCardNumber(),
|
||||
setInfo.getRarity(), setInfo.getGraphicInfo()));
|
||||
Card card = CardImpl.createCard(
|
||||
setInfo.getCardClass(),
|
||||
new CardSetInfo(setInfo.getName(), set.getCode(), setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()),
|
||||
errorsList);
|
||||
if (card != null) {
|
||||
cardsToAdd.add(new CardInfo(card));
|
||||
if (card instanceof SplitCard) {
|
||||
|
|
@ -85,7 +101,7 @@ public final class CardScanner {
|
|||
}
|
||||
|
||||
if (!cardsToAdd.isEmpty()) {
|
||||
logger.info("Cards need storing in DB: " + cardsToAdd.size());
|
||||
logger.info("DB: need to add " + cardsToAdd.size() + " new cards");
|
||||
CardRepository.instance.addCards(cardsToAdd);
|
||||
}
|
||||
CardRepository.instance.setContentVersion(CardRepository.instance.getContentVersionConstant());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue