mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
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() {
|
public static void bootstrapCardsAndRatings() {
|
||||||
// preload cards and ratings
|
// preload cards and ratings
|
||||||
log.info("Loading cards and rating...");
|
log.info("Loading cards and rating...");
|
||||||
List<Card> cards = CardScanner.getAllCards(false);
|
List<Card> cards = CardScanner.getAllCards(false, true, true);
|
||||||
for (Card card : cards) {
|
for (Card card : cards) {
|
||||||
RateCard.rateCard(card, null);
|
RateCard.rateCard(card, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -329,7 +329,8 @@ public class VerifyCardDataTest {
|
||||||
checkWrongAbilitiesTextStart();
|
checkWrongAbilitiesTextStart();
|
||||||
|
|
||||||
int cardIndex = 0;
|
int cardIndex = 0;
|
||||||
for (Card card : CardScanner.getAllCards()) {
|
List<Card> allCards = CardScanner.getAllCards(true, true, false);
|
||||||
|
for (Card card : allCards) {
|
||||||
cardIndex++;
|
cardIndex++;
|
||||||
if (card instanceof CardWithHalves) {
|
if (card instanceof CardWithHalves) {
|
||||||
check(((CardWithHalves) card).getLeftHalfCard(), cardIndex);
|
check(((CardWithHalves) card).getLeftHalfCard(), cardIndex);
|
||||||
|
|
@ -346,7 +347,7 @@ public class VerifyCardDataTest {
|
||||||
|
|
||||||
printMessages(outputMessages);
|
printMessages(outputMessages);
|
||||||
if (failed > 0) {
|
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)");
|
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
|
// 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()))) {
|
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");
|
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 mage.cards.*;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author North
|
* @author North
|
||||||
|
|
@ -83,17 +80,28 @@ public final class CardScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<Card> getAllCards() {
|
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();
|
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
||||||
List<Card> cards = new ArrayList<>();
|
List<Card> cards = new ArrayList<>();
|
||||||
for (ExpansionSet set : sets) {
|
for (ExpansionSet set : sets) {
|
||||||
if (ignoreCustomSets && set.getSetType().isCustomSet()) {
|
if (ignoreCustomSets && set.getSetType().isCustomSet()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (uniqueBySet) {
|
||||||
|
uniqueCardNames.clear();
|
||||||
|
}
|
||||||
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
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(),
|
cards.add(CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
||||||
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo())));
|
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo())));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue