Updated cards which target cards with attribute x

This commit is contained in:
Evan Kranzler 2017-09-16 21:08:52 -04:00
parent b3712b88c7
commit dcddc91144
10 changed files with 53 additions and 59 deletions

View file

@ -79,11 +79,7 @@ public class DeepfireElemental extends CardImpl {
if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy();
StringBuilder message = new StringBuilder(filter2.getMessage());
message.setLength(message.length() - 1);
message.append(xValue);
filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filter2.setMessage(message.toString());
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(filter2));
}

View file

@ -50,7 +50,7 @@ import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.Target;
import mage.target.TargetCard;
import mage.target.common.TargetCardInOpponentsGraveyard;
/**
@ -58,6 +58,14 @@ import mage.target.common.TargetCardInOpponentsGraveyard;
*/
public class GethLordOfTheVault extends CardImpl {
private static final FilterCard filter = new FilterCard("artifact or creature card with converted mana cost X from an opponent's graveyard");
static {
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
}
public GethLordOfTheVault(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{B}{B}");
addSuperType(SuperType.LEGENDARY);
@ -72,23 +80,20 @@ public class GethLordOfTheVault extends CardImpl {
// {X}{B}: Put target artifact or creature card with converted mana cost X from an opponent's graveyard onto the battlefield under your control tapped.
// Then that player puts the top X cards of his or her library into his or her graveyard.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new GethLordOfTheVaultEffect(), new ManaCostsImpl("{X}{B}"));
ability.setTargetAdjustment(TargetAdjustment.X_CMC_EQUAL_NONPERM);
ability.addTarget(new TargetCardInOpponentsGraveyard(new FilterCard("artifact or creature card with converted mana cost X from an opponent's graveyard")));
ability.setTargetAdjustment(TargetAdjustment.GETH);
ability.addTarget(new TargetCardInOpponentsGraveyard(filter));
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_NONPERM) {
if (ability.getTargetAdjustment() == TargetAdjustment.GETH) {
int xValue = ability.getManaCostsToPay().getX();
TargetCard oldTarget = (TargetCard) ability.getTargets().get(0);
FilterCard filter2 = oldTarget.getFilter().copy();
filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
ability.getTargets().clear();
FilterCard filter = new FilterCard("artifact or creature card with converted mana cost " + xValue + " from an opponent's graveyard");
filter.add(Predicates.or(
new CardTypePredicate(CardType.ARTIFACT),
new CardTypePredicate(CardType.CREATURE)));
filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
Target target = new TargetCardInOpponentsGraveyard(filter);
ability.addTarget(target);
ability.getTargets().add(new TargetCardInOpponentsGraveyard(filter2));
}
}

View file

@ -79,14 +79,13 @@ public class GorillaShaman extends CardImpl {
public void adjustTargets(Ability ability, Game game) {
if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy();
StringBuilder message = new StringBuilder(filter2.getMessage());
message.setLength(message.length() - 1);
message.append(xValue);
TargetPermanent oldTarget = (TargetPermanent) ability.getTargets().get(0);
int minTargets = oldTarget.getMinNumberOfTargets();
int maxTargets = oldTarget.getMaxNumberOfTargets();
FilterPermanent filter2 = oldTarget.getFilter().copy();
filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filter2.setMessage(message.toString());
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(filter2));
ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, filter2, false));
}
}

View file

@ -79,11 +79,7 @@ public class HearthKami extends CardImpl {
if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy();
StringBuilder message = new StringBuilder(filter2.getMessage());
message.setLength(message.length() - 1);
message.append(xValue);
filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filter2.setMessage(message.toString());
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(filter2));
}

View file

@ -102,11 +102,7 @@ public class LinessaZephyrMage extends CardImpl {
if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy();
StringBuilder message = new StringBuilder(filter2.getMessage());
message.setLength(message.length() - 1);
message.append(xValue);
filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filter2.setMessage(message.toString());
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(filter2));
}

View file

@ -33,19 +33,20 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CantBeBlockedTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.TargetAdjustment;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.CardTypePredicate;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.target.Target;
import mage.target.common.TargetCreaturePermanent;
import mage.target.TargetPermanent;
/**
*
@ -53,11 +54,14 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class MinamoSightbender extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with power X or less");
private final UUID originalId;
private static final FilterPermanent filter = new FilterPermanent("creature with power X or less");
static {
filter.add(new CardTypePredicate(CardType.CREATURE));
}
public MinamoSightbender(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}");
this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.WIZARD);
@ -67,34 +71,30 @@ public class MinamoSightbender extends CardImpl {
//TODO: Make ability properly copiable
// {X}, {T}: Target creature with power X or less can't be blocked this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CantBeBlockedTargetEffect(), new ManaCostsImpl("{X}"));
Target target = new TargetCreaturePermanent(filter);
Target target = new TargetPermanent(filter);
ability.setTargetAdjustment(TargetAdjustment.X_POWER_LEQ);
ability.addTarget(target);
ability.addCost(new TapSourceCost());
originalId = ability.getOriginalId();
this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
if (ability.getOriginalId().equals(originalId)) {
for (Effect effect : ability.getEffects()) {
if (effect instanceof CantBeBlockedTargetEffect) {
int manaX = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
FilterCreaturePermanent newFilter = new FilterCreaturePermanent(new StringBuilder("creature with power ").append(manaX).append(" or less").toString());
filter.add(new PowerPredicate(ComparisonType.FEWER_THAN, manaX + 1));
Target target = new TargetCreaturePermanent(newFilter);
ability.addTarget(target);
break;
}
}
if (ability.getTargetAdjustment() == TargetAdjustment.X_POWER_LEQ) {
int xValue = ability.getManaCostsToPay().getX();
TargetPermanent oldTarget = (TargetPermanent) ability.getTargets().get(0);
int minTargets = oldTarget.getMinNumberOfTargets();
int maxTargets = oldTarget.getMaxNumberOfTargets();
FilterPermanent filter2 = oldTarget.getFilter().copy();
filter2.add(new PowerPredicate(ComparisonType.FEWER_THAN, xValue + 1));
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, filter2, false));
}
}
public MinamoSightbender(final MinamoSightbender card) {
super(card);
this.originalId = card.originalId;
}
@Override

View file

@ -81,11 +81,7 @@ public class Plaguebearer extends CardImpl {
if (ability.getTargetAdjustment() == TargetAdjustment.X_CMC_EQUAL_PERM) {
int xValue = ability.getManaCostsToPay().getX();
FilterPermanent filter2 = ((TargetPermanent) ability.getTargets().get(0)).getFilter().copy();
StringBuilder message = new StringBuilder(filter2.getMessage());
message.setLength(message.length() - 1);
message.append(xValue);
filter2.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, xValue));
filter2.setMessage(message.toString());
ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(filter2));
}

View file

@ -6,5 +6,5 @@ package mage.constants;
*/
public enum TargetAdjustment {
NONE, X_TARGETS, X_CMC_EQUAL_PERM, X_CMC_EQUAL_NONPERM, DEFENDING_PLAYER
NONE, X_TARGETS, X_CMC_EQUAL_PERM, GETH, DEFENDING_PLAYER,X_POWER_LEQ
}

View file

@ -53,8 +53,7 @@ public interface Target extends Serializable {
boolean isNotTarget();
/**
* controls if it will be checked, if the target can be targeted from
* source
* controls if it will be checked, if the target can be targeted from source
*
* @param notTarget true = do not check for protection, false = check for
* protection
@ -113,6 +112,8 @@ public interface Target extends Serializable {
int getNumberOfTargets();
int getMinNumberOfTargets();
int getMaxNumberOfTargets();
void setMinNumberOfTargets(int minNumberofTargets);
@ -157,8 +158,8 @@ public interface Target extends Serializable {
void setTargetTag(int tag);
Target getOriginalTarget();
// used for cards like Spellskite
void setTargetAmount(UUID targetId, int amount, Game game);
}

View file

@ -105,6 +105,11 @@ public abstract class TargetImpl implements Target {
return this.minNumberOfTargets;
}
@Override
public int getMinNumberOfTargets() {
return this.minNumberOfTargets;
}
@Override
public int getMaxNumberOfTargets() {
return this.maxNumberOfTargets;