mirror of
https://github.com/correl/mage.git
synced 2024-12-26 03:00:11 +00:00
Improved logs on card create exceptions, fixed broken tests
This commit is contained in:
parent
0840fa9e0d
commit
c11a16d115
2 changed files with 14 additions and 3 deletions
|
@ -28,6 +28,7 @@
|
||||||
package mage.cards;
|
package mage.cards;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.MageObjectImpl;
|
import mage.MageObjectImpl;
|
||||||
|
@ -205,22 +206,30 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Card createCard(Class<?> clazz, CardSetInfo setInfo, List<String> errorList) {
|
public static Card createCard(Class<?> clazz, CardSetInfo setInfo, List<String> errorList) {
|
||||||
|
String setCode = null;
|
||||||
try {
|
try {
|
||||||
Card card;
|
Card card;
|
||||||
if (setInfo == null) {
|
if (setInfo == null) {
|
||||||
Constructor<?> con = clazz.getConstructor(UUID.class);
|
Constructor<?> con = clazz.getConstructor(UUID.class);
|
||||||
card = (Card) con.newInstance(new Object[]{null});
|
card = (Card) con.newInstance(new Object[]{null});
|
||||||
} else {
|
} else {
|
||||||
|
setCode = setInfo.getExpansionSetCode();
|
||||||
Constructor<?> con = clazz.getConstructor(UUID.class, CardSetInfo.class);
|
Constructor<?> con = clazz.getConstructor(UUID.class, CardSetInfo.class);
|
||||||
card = (Card) con.newInstance(null, setInfo);
|
card = (Card) con.newInstance(null, setInfo);
|
||||||
}
|
}
|
||||||
return card;
|
return card;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
String err = "Error loading card: " + clazz.getCanonicalName();
|
String err = "Error loading card: " + clazz.getCanonicalName() + " (" + setCode + ")";
|
||||||
if (errorList != null) {
|
if (errorList != null) {
|
||||||
errorList.add(err);
|
errorList.add(err);
|
||||||
}
|
}
|
||||||
logger.fatal(err, e);
|
|
||||||
|
if (e instanceof InvocationTargetException) {
|
||||||
|
logger.fatal(err, ((InvocationTargetException) e).getTargetException());
|
||||||
|
} else {
|
||||||
|
logger.fatal(err, e);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.target.common;
|
package mage.target.common;
|
||||||
|
|
||||||
import mage.constants.SuperType;
|
import mage.constants.SuperType;
|
||||||
|
import mage.filter.common.FilterLandPermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||||
|
|
||||||
|
@ -39,7 +40,8 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||||
public class TargetNonBasicLandPermanent extends TargetLandPermanent {
|
public class TargetNonBasicLandPermanent extends TargetLandPermanent {
|
||||||
|
|
||||||
public TargetNonBasicLandPermanent() {
|
public TargetNonBasicLandPermanent() {
|
||||||
filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
|
this.filter = new FilterLandPermanent();
|
||||||
|
this.filter.add(Predicates.not(new SupertypePredicate(SuperType.BASIC)));
|
||||||
this.targetName = "nonbasic land";
|
this.targetName = "nonbasic land";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue