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;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.*;
|
||||
import mage.MageObject;
|
||||
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) {
|
||||
String setCode = null;
|
||||
try {
|
||||
Card card;
|
||||
if (setInfo == null) {
|
||||
Constructor<?> con = clazz.getConstructor(UUID.class);
|
||||
card = (Card) con.newInstance(new Object[]{null});
|
||||
} else {
|
||||
setCode = setInfo.getExpansionSetCode();
|
||||
Constructor<?> con = clazz.getConstructor(UUID.class, CardSetInfo.class);
|
||||
card = (Card) con.newInstance(null, setInfo);
|
||||
}
|
||||
return card;
|
||||
} catch (Exception e) {
|
||||
String err = "Error loading card: " + clazz.getCanonicalName();
|
||||
String err = "Error loading card: " + clazz.getCanonicalName() + " (" + setCode + ")";
|
||||
if (errorList != null) {
|
||||
errorList.add(err);
|
||||
}
|
||||
|
||||
if (e instanceof InvocationTargetException) {
|
||||
logger.fatal(err, ((InvocationTargetException) e).getTargetException());
|
||||
} else {
|
||||
logger.fatal(err, e);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.constants.SuperType;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.SupertypePredicate;
|
||||
|
||||
|
@ -39,7 +40,8 @@ import mage.filter.predicate.mageobject.SupertypePredicate;
|
|||
public class TargetNonBasicLandPermanent extends TargetLandPermanent {
|
||||
|
||||
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";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue