mirror of
https://github.com/correl/mage.git
synced 2024-12-27 03:00:13 +00:00
Extra tests to catch card creation errors;
This commit is contained in:
parent
e77b21f4e9
commit
b9b8415c99
3 changed files with 43 additions and 6 deletions
|
@ -1,8 +1,5 @@
|
||||||
package mage.cards.e;
|
package mage.cards.e;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.effects.ContinuousEffect;
|
import mage.abilities.effects.ContinuousEffect;
|
||||||
import mage.abilities.effects.ContinuousEffectImpl;
|
import mage.abilities.effects.ContinuousEffectImpl;
|
||||||
|
@ -22,6 +19,10 @@ import mage.target.Target;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author JRHerlehy
|
* @author JRHerlehy
|
||||||
*/
|
*/
|
||||||
|
@ -30,7 +31,8 @@ public final class Expropriate extends CardImpl {
|
||||||
public Expropriate(UUID ownerId, CardSetInfo setInfo) {
|
public Expropriate(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{7}{U}{U}");
|
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{7}{U}{U}");
|
||||||
|
|
||||||
// <i>Council's dilemma</i> — Starting with you, each player votes for time or money. For each time vote, take an extra turn after this one. For each money vote, choose a permanent owned by the voter and gain control of it. Exile Expropriate
|
// <i>Council's dilemma</i> — Starting with you, each player votes for time or money. For each time vote,
|
||||||
|
// take an extra turn after this one. For each money vote, choose a permanent owned by the voter and gain control of it. Exile Expropriate
|
||||||
this.getSpellAbility().addEffect(new ExpropriateDilemmaEffect());
|
this.getSpellAbility().addEffect(new ExpropriateDilemmaEffect());
|
||||||
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
|
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,16 @@ public class ExportJsonGameplayDataTest {
|
||||||
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
||||||
for (ExpansionSet set : sets) {
|
for (ExpansionSet set : sets) {
|
||||||
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
||||||
cards.add(CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
// catch cards creation errors and report (e.g. on wrong card code)
|
||||||
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo())));
|
try {
|
||||||
|
Card card = CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
||||||
|
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()));
|
||||||
|
if (card != null) {
|
||||||
|
cards.add(card);
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("Can't create card " + setInfo.getName() + ": " + e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
JsonObject res = new JsonObject();
|
JsonObject res = new JsonObject();
|
||||||
|
|
|
@ -15,6 +15,7 @@ import mage.game.draft.RateCard;
|
||||||
import mage.game.permanent.token.Token;
|
import mage.game.permanent.token.Token;
|
||||||
import mage.game.permanent.token.TokenImpl;
|
import mage.game.permanent.token.TokenImpl;
|
||||||
import mage.watchers.Watcher;
|
import mage.watchers.Watcher;
|
||||||
|
import org.apache.log4j.Logger;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
@ -41,6 +42,8 @@ import java.util.stream.Collectors;
|
||||||
*/
|
*/
|
||||||
public class VerifyCardDataTest {
|
public class VerifyCardDataTest {
|
||||||
|
|
||||||
|
private static final Logger logger = Logger.getLogger(VerifyCardDataTest.class);
|
||||||
|
|
||||||
// right now this is very noisy, and not useful enough to make any assertions on
|
// right now this is very noisy, and not useful enough to make any assertions on
|
||||||
private static final boolean CHECK_SOURCE_TOKENS = false;
|
private static final boolean CHECK_SOURCE_TOKENS = false;
|
||||||
|
|
||||||
|
@ -971,4 +974,28 @@ public class VerifyCardDataTest {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCardsCreatingAndConstructorErrors() {
|
||||||
|
int errorsCount = 0;
|
||||||
|
Collection<ExpansionSet> sets = Sets.getInstance().values();
|
||||||
|
for (ExpansionSet set : sets) {
|
||||||
|
for (ExpansionSet.SetCardInfo setInfo : set.getSetCardInfo()) {
|
||||||
|
// catch cards creation errors and report (e.g. on wrong card code or construction checks fail)
|
||||||
|
try {
|
||||||
|
Card card = CardImpl.createCard(setInfo.getCardClass(), new CardSetInfo(setInfo.getName(), set.getCode(),
|
||||||
|
setInfo.getCardNumber(), setInfo.getRarity(), setInfo.getGraphicInfo()));
|
||||||
|
if (card == null) {
|
||||||
|
errorsCount++;
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
logger.error("Can't create card " + setInfo.getName() + ": " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (errorsCount > 0) {
|
||||||
|
Assert.fail("Founded " + errorsCount + " broken cards, look at logs for stack error");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue