call method on MagicPermanent instead of getting MagicCardDefinition

master
melvin 2013-01-20 10:30:19 +08:00
parent 3e25833191
commit e9945a37fa
1 changed files with 21 additions and 3 deletions

View File

@ -294,7 +294,7 @@ public interface MagicTargetFilter<T extends MagicTarget> {
MagicPermanentFilterImpl TARGET_NONBASIC_LAND=new MagicPermanentFilterImpl() {
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicPermanent target) {
return target.isLand() && !target.getCardDefinition().isBasic();
return target.isLand() && !target.hasType(MagicType.Basic);
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Permanent;
@ -878,7 +878,7 @@ public interface MagicTargetFilter<T extends MagicTarget> {
MagicPermanentFilterImpl TARGET_CREATURE_CONVERTED_3_OR_LESS=new MagicPermanentFilterImpl() {
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicPermanent target) {
return target.isCreature() &&
target.getCardDefinition().getCost().getConvertedCost() <= 3;
target.getConvertedCost() <= 3;
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Permanent;
@ -1501,7 +1501,7 @@ public interface MagicTargetFilter<T extends MagicTarget> {
@Override
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicPermanent target) {
return targetFilter.accept(game,player,target) &&
operator.cmp(target.getCardDefinition().getConvertedCost(), cmc) ;
operator.cmp(target.getConvertedCost(), cmc) ;
}
@Override
@ -1546,4 +1546,22 @@ public interface MagicTargetFilter<T extends MagicTarget> {
return targetType==MagicTargetType.Permanent;
}
};
public static final class LegendaryTargetFilter extends MagicPermanentFilterImpl {
private final String name;
public LegendaryTargetFilter(final String name) {
this.name=name;
}
@Override
public boolean accept(final MagicGame game,final MagicPlayer player,final MagicPermanent target) {
return name.equals(target.getName()) && target.hasType(MagicType.Legendary);
}
public boolean acceptType(final MagicTargetType targetType) {
return targetType==MagicTargetType.Permanent;
}
};
}