forked from External/mage
add verify checks for Double Faced Cards having abilities on main card
* add booleans to card scanner, restricting to checking cards by name and set. Reduces duplication of verify checks across sets.
This commit is contained in:
parent
69e20b1061
commit
b32a786236
3 changed files with 32 additions and 9 deletions
|
|
@ -61,7 +61,7 @@ public final class RateCard {
|
|||
public static void bootstrapCardsAndRatings() {
|
||||
// preload cards and ratings
|
||||
log.info("Loading cards and rating...");
|
||||
List<Card> cards = CardScanner.getAllCards(false);
|
||||
List<Card> cards = CardScanner.getAllCards(false, true, true);
|
||||
for (Card card : cards) {
|
||||
RateCard.rateCard(card, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -329,7 +329,8 @@ public class VerifyCardDataTest {
|
|||
checkWrongAbilitiesTextStart();
|
||||
|
||||
int cardIndex = 0;
|
||||
for (Card card : CardScanner.getAllCards()) {
|
||||
List<Card> allCards = CardScanner.getAllCards(true, true, false);
|
||||
for (Card card : allCards) {
|
||||
cardIndex++;
|
||||
if (card instanceof CardWithHalves) {
|
||||
check(((CardWithHalves) card).getLeftHalfCard(), cardIndex);
|
||||
|
|
@ -346,7 +347,7 @@ public class VerifyCardDataTest {
|
|||
|
||||
printMessages(outputMessages);
|
||||
if (failed > 0) {
|
||||
Assert.fail(String.format("found %d errors in %d cards verify (see errors list above)", failed, CardScanner.getAllCards().size()));
|
||||
Assert.fail(String.format("found %d errors in %d cards verify (see errors list above)", failed, allCards.size()));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2291,6 +2292,20 @@ public class VerifyCardDataTest {
|
|||
fail(card, "abilities", "card has backup but is missing this.addAbility(backupAbility)");
|
||||
}
|
||||
|
||||
// special check: DFC main card should not have abilities
|
||||
if (card instanceof DoubleFacedCardHalf && !card.getMainCard().getInitAbilities().isEmpty()) {
|
||||
fail(card, "abilities", "transforming double-faced card should not have abilities on the main card");
|
||||
}
|
||||
|
||||
// TODO: remove after transform ability removed
|
||||
// special check: new DFC implementation should not have transform ability
|
||||
if (card instanceof DoubleFacedCardHalf && card.getAbilities().containsClass(TransformAbility.class)
|
||||
&& !card.getAbilities().containsClass(DayboundAbility.class)
|
||||
&& !card.getAbilities().containsClass(CraftAbility.class)
|
||||
&& !card.getAbilities().containsClass(SiegeAbility.class)) {
|
||||
fail(card, "abilities", "new transforming double-faced card should not have transform ability");
|
||||
}
|
||||
|
||||
// special check: Werewolves front ability should only be on front and vice versa
|
||||
if (card.getAbilities().containsClass(WerewolfFrontTriggeredAbility.class) && (card.isNightCard() || (card instanceof DoubleFacedCardHalf && ((DoubleFacedCardHalf) card).isBackSide()))) {
|
||||
fail(card, "abilities", "card is a back face werewolf with a front face ability");
|
||||
|
|
|
|||
|
|
@ -3,10 +3,7 @@ package mage.cards.repository;
|
|||
import mage.cards.*;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author North
|
||||
|
|
@ -83,17 +80,28 @@ public final class CardScanner {
|
|||
}
|
||||
|
||||
public static List<Card> getAllCards() {
|
||||
return getAllCards(true);
|
||||
return getAllCards(true, true, true);
|
||||
}
|
||||
|
||||
public static List<Card> getAllCards(boolean ignoreCustomSets) {
|
||||
public static List<Card> getAllCards(boolean ignoreCustomSets, boolean uniqueByName, boolean uniqueBySet) {
|
||||
Set<String> uniqueCardNames = new HashSet<>();
|
||||
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
||||
List<Card> cards = new ArrayList<>();
|
||||
for (ExpansionSet set : sets) {
|
||||
if (ignoreCustomSets && set.getSetType().isCustomSet()) {
|
||||
continue;
|
||||
}
|
||||
if (uniqueBySet) {
|
||||
uniqueCardNames.clear();
|
||||
}
|
||||
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
||||
if (uniqueByName) {
|
||||
String cardName = setInfo.getName();
|
||||
if (uniqueCardNames.contains(cardName)) {
|
||||
continue;
|
||||
}
|
||||
uniqueCardNames.add(cardName);
|
||||
}
|
||||
cards.add(CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
||||
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo())));
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue