Pentarch Paladin is now supported properly

This commit is contained in:
Evan Kranzler 2017-09-19 18:01:37 -04:00
parent bc9a3dd58a
commit ce68a1d9ed
3 changed files with 26 additions and 32 deletions

View file

@ -29,7 +29,6 @@ package mage.cards.p;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -44,23 +43,21 @@ import mage.constants.SubType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.abilities.effects.common.DestroyTargetEffect; import mage.abilities.effects.common.DestroyTargetEffect;
import mage.constants.TargetAdjustment;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
*/ */
public class PentarchPaladin extends CardImpl { public class PentarchPaladin extends CardImpl {
private final UUID originalId;
FilterPermanent filter = new FilterPermanent("permanent of the chosen color."); FilterPermanent filter = new FilterPermanent("permanent of the chosen color.");
public PentarchPaladin(UUID ownerId, CardSetInfo setInfo) { public PentarchPaladin(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}{W}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{W}{W}{W}");
this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.HUMAN);
this.subtype.add(SubType.KNIGHT); this.subtype.add(SubType.KNIGHT);
this.power = new MageInt(3); this.power = new MageInt(3);
@ -71,37 +68,21 @@ public class PentarchPaladin extends CardImpl {
// As Pentarch Paladin enters the battlefield, choose a color. // As Pentarch Paladin enters the battlefield, choose a color.
this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Detriment))); this.addAbility(new AsEntersBattlefieldAbility(new ChooseColorEffect(Outcome.Detriment)));
//TODO: Make ability properly copiable
// {W}{W}, {tap}: Destroy target permanent of the chosen color. // {W}{W}, {tap}: Destroy target permanent of the chosen color.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{W}{W}")); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DestroyTargetEffect(), new ManaCostsImpl("{W}{W}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPermanent(filter)); ability.addTarget(new TargetPermanent(filter));
originalId = ability.getOriginalId(); ability.setTargetAdjustment(TargetAdjustment.CHOSEN_COLOR);
this.addAbility(ability); this.addAbility(ability);
}
@Override
public void adjustTargets(Ability ability, Game game) {
ObjectColor color = (ObjectColor) game.getState().getValue(ability.getSourceId() + "_color");
if (ability.getOriginalId().equals(originalId)
&& color != null) {
ability.getTargets().clear();
FilterPermanent filter = new FilterPermanent("permanent of the chosen color.");
filter.add(new ColorPredicate(color));
TargetPermanent target = new TargetPermanent(filter);
ability.addTarget(target);
}
} }
public PentarchPaladin(final PentarchPaladin card) { public PentarchPaladin(final PentarchPaladin card) {
super(card); super(card);
this.originalId = card.originalId;
} }
@Override @Override
public PentarchPaladin copy() { public PentarchPaladin copy() {
return new PentarchPaladin(this); return new PentarchPaladin(this);
} }
} }

View file

@ -46,6 +46,7 @@ import mage.counters.Counters;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.filter.FilterSpell; import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate; import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.filter.predicate.mageobject.NamePredicate; import mage.filter.predicate.mageobject.NamePredicate;
import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.PowerPredicate;
@ -351,6 +352,12 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
ability.getTargets().clear(); ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, permanentFilter, false)); ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, permanentFilter, false));
break; break;
case X_TARGETS:
xValue = ability.getManaCostsToPay().getX();
permanentFilter = ((TargetPermanent) ability.getTargets().get(0)).getFilter();
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(xValue, permanentFilter));
break;
case X_POWER_LEQ:// Minamo Sightbender only case X_POWER_LEQ:// Minamo Sightbender only
xValue = ability.getManaCostsToPay().getX(); xValue = ability.getManaCostsToPay().getX();
oldTargetPermanent = (TargetPermanent) ability.getTargets().get(0); oldTargetPermanent = (TargetPermanent) ability.getTargets().get(0);
@ -361,12 +368,6 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
ability.getTargets().clear(); ability.getTargets().clear();
ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, permanentFilter, false)); ability.getTargets().add(new TargetPermanent(minTargets, maxTargets, permanentFilter, false));
break; break;
case X_TARGETS:
xValue = ability.getManaCostsToPay().getX();
permanentFilter = ((TargetPermanent) ability.getTargets().get(0)).getFilter();
ability.getTargets().clear();
ability.addTarget(new TargetPermanent(xValue, permanentFilter));
break;
case X_CMC_EQUAL_GY_CARD: //Geth, Lord of the Vault only case X_CMC_EQUAL_GY_CARD: //Geth, Lord of the Vault only
xValue = ability.getManaCostsToPay().getX(); xValue = ability.getManaCostsToPay().getX();
TargetCard oldTarget = (TargetCard) ability.getTargets().get(0); TargetCard oldTarget = (TargetCard) ability.getTargets().get(0);
@ -382,6 +383,18 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
TargetSpell target = new TargetSpell(1, filterSpell); TargetSpell target = new TargetSpell(1, filterSpell);
ability.addTarget(target); ability.addTarget(target);
break; break;
case CHOSEN_COLOR: //Pentarch Paladin only
ObjectColor chosenColor = (ObjectColor) game.getState().getValue(ability.getSourceId() + "_color");
ability.getTargets().clear();
FilterPermanent filter = new FilterPermanent("permanent of the chosen color.");
if (chosenColor != null) {
filter.add(new ColorPredicate(chosenColor));
} else {
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, -5));// Pretty sure this is always false
}
oldTargetPermanent = new TargetPermanent(filter);
ability.addTarget(oldTargetPermanent);
break;
} }
} }

View file

@ -6,5 +6,5 @@ package mage.constants;
*/ */
public enum TargetAdjustment { public enum TargetAdjustment {
NONE, X_TARGETS, X_CMC_EQUAL_PERM, X_CMC_EQUAL_GY_CARD, X_POWER_LEQ, CHOSEN_NAME NONE, X_TARGETS, X_CMC_EQUAL_PERM, X_CMC_EQUAL_GY_CARD, X_POWER_LEQ, CHOSEN_NAME, CHOSEN_COLOR
} }