mirror of
https://github.com/correl/mage.git
synced 2024-12-29 11:09:17 +00:00
finished the last few target adjusters
This commit is contained in:
parent
9d9c7b0242
commit
c9ca0e8916
3 changed files with 110 additions and 100 deletions
|
@ -1,11 +1,11 @@
|
||||||
|
|
||||||
package mage.cards.n;
|
package mage.cards.n;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.MageInt;
|
import mage.MageInt;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.SimpleActivatedAbility;
|
import mage.abilities.common.SimpleActivatedAbility;
|
||||||
import mage.abilities.costs.Cost;
|
import mage.abilities.costs.Cost;
|
||||||
|
import mage.abilities.costs.CostAdjuster;
|
||||||
import mage.abilities.costs.VariableCost;
|
import mage.abilities.costs.VariableCost;
|
||||||
import mage.abilities.costs.common.ExileFromGraveCost;
|
import mage.abilities.costs.common.ExileFromGraveCost;
|
||||||
import mage.abilities.costs.common.TapSourceCost;
|
import mage.abilities.costs.common.TapSourceCost;
|
||||||
|
@ -21,8 +21,8 @@ import mage.abilities.keyword.FlyingAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.SubType;
|
|
||||||
import mage.constants.Duration;
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.FilterCard;
|
import mage.filter.FilterCard;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
|
@ -30,15 +30,17 @@ import mage.players.Player;
|
||||||
import mage.target.Target;
|
import mage.target.Target;
|
||||||
import mage.target.common.TargetCardInYourGraveyard;
|
import mage.target.common.TargetCardInYourGraveyard;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
import mage.target.targetadjustment.TargetAdjuster;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author LevelX2
|
* @author LevelX2
|
||||||
*/
|
*/
|
||||||
public final class NecropolisFiend extends CardImpl {
|
public final class NecropolisFiend extends CardImpl {
|
||||||
|
|
||||||
public NecropolisFiend(UUID ownerId, CardSetInfo setInfo) {
|
public NecropolisFiend(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{7}{B}{B}");
|
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{7}{B}{B}");
|
||||||
this.subtype.add(SubType.DEMON);
|
this.subtype.add(SubType.DEMON);
|
||||||
|
|
||||||
this.power = new MageInt(4);
|
this.power = new MageInt(4);
|
||||||
|
@ -46,54 +48,29 @@ public final class NecropolisFiend extends CardImpl {
|
||||||
|
|
||||||
// Delve
|
// Delve
|
||||||
this.addAbility(new DelveAbility());
|
this.addAbility(new DelveAbility());
|
||||||
|
|
||||||
// Flying
|
// Flying
|
||||||
this.addAbility(FlyingAbility.getInstance());
|
this.addAbility(FlyingAbility.getInstance());
|
||||||
//TODO: Make ability properly copiable
|
|
||||||
// {X}, {T}, Exile X cards from your graveyard: Target creature gets -X/-X until end of turn.
|
// {X}, {T}, Exile X cards from your graveyard: Target creature gets -X/-X until end of turn.
|
||||||
DynamicValue xValue = new SignInversionDynamicValue(new ManacostVariableValue());
|
DynamicValue xValue = new SignInversionDynamicValue(new ManacostVariableValue());
|
||||||
Effect effect = new BoostTargetEffect(xValue,xValue,Duration.EndOfTurn);
|
Effect effect = new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn);
|
||||||
effect.setText("Target creature gets -X/-X until end of turn");
|
effect.setText("Target creature gets -X/-X until end of turn");
|
||||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{X}"));
|
Ability ability = new SimpleActivatedAbility(
|
||||||
|
Zone.BATTLEFIELD, effect,
|
||||||
|
new ManaCostsImpl("{X}")
|
||||||
|
);
|
||||||
ability.addCost(new TapSourceCost());
|
ability.addCost(new TapSourceCost());
|
||||||
ability.addTarget(new TargetCreaturePermanent());
|
ability.addTarget(new TargetCreaturePermanent());
|
||||||
ability.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(1,1,new FilterCard("cards from your graveyard")), "Exile X cards from your graveyard"));
|
ability.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(
|
||||||
|
1, 1, new FilterCard("cards from your graveyard")
|
||||||
|
), "Exile X cards from your graveyard"));
|
||||||
|
ability.setTargetAdjuster(NecropolisFiendTargetAdjuster.instance);
|
||||||
|
ability.setCostAdjuster(NecropolisFiendCostAdjuster.instance);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
if (ability instanceof SimpleActivatedAbility) {
|
|
||||||
Player controller = game.getPlayer(ability.getControllerId());
|
|
||||||
if (controller != null) {
|
|
||||||
for (VariableCost variableCost: ability.getManaCostsToPay().getVariableCosts()) {
|
|
||||||
if (variableCost instanceof VariableManaCost) {
|
|
||||||
((VariableManaCost)variableCost).setMaxX(controller.getGraveyard().size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
if (ability instanceof SimpleActivatedAbility) {
|
|
||||||
int xValue = ability.getManaCostsToPay().getX();
|
|
||||||
for(Cost cost: ability.getCosts()) {
|
|
||||||
if (cost instanceof ExileFromGraveCost) {
|
|
||||||
ExileFromGraveCost exileCost = (ExileFromGraveCost) cost;
|
|
||||||
for(Target target: exileCost.getTargets()) {
|
|
||||||
if (target instanceof TargetCardInYourGraveyard) {
|
|
||||||
target.setMaxNumberOfTargets(xValue);
|
|
||||||
target.setMinNumberOfTargets(xValue);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public NecropolisFiend(final NecropolisFiend card) {
|
public NecropolisFiend(final NecropolisFiend card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
@ -103,3 +80,41 @@ public final class NecropolisFiend extends CardImpl {
|
||||||
return new NecropolisFiend(this);
|
return new NecropolisFiend(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum NecropolisFiendCostAdjuster implements CostAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustCosts(Ability ability, Game game) {
|
||||||
|
Player controller = game.getPlayer(ability.getControllerId());
|
||||||
|
if (controller == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (VariableCost variableCost : ability.getManaCostsToPay().getVariableCosts()) {
|
||||||
|
if (variableCost instanceof VariableManaCost) {
|
||||||
|
((VariableManaCost) variableCost).setMaxX(controller.getGraveyard().size());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum NecropolisFiendTargetAdjuster implements TargetAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
|
int xValue = ability.getManaCostsToPay().getX();
|
||||||
|
for (Cost cost : ability.getCosts()) {
|
||||||
|
if (!(cost instanceof ExileFromGraveCost)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ExileFromGraveCost exileCost = (ExileFromGraveCost) cost;
|
||||||
|
for (Target target : exileCost.getTargets()) {
|
||||||
|
if (target instanceof TargetCardInYourGraveyard) {
|
||||||
|
target.setMaxNumberOfTargets(xValue);
|
||||||
|
target.setMinNumberOfTargets(xValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,8 @@
|
||||||
|
|
||||||
package mage.cards.p;
|
package mage.cards.p;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
import mage.abilities.costs.CostAdjuster;
|
||||||
import mage.abilities.costs.common.PayLifeCost;
|
import mage.abilities.costs.common.PayLifeCost;
|
||||||
import mage.abilities.effects.common.DestroyMultiTargetEffect;
|
import mage.abilities.effects.common.DestroyMultiTargetEffect;
|
||||||
import mage.abilities.effects.common.InfoEffect;
|
import mage.abilities.effects.common.InfoEffect;
|
||||||
|
@ -13,9 +12,11 @@ import mage.constants.CardType;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
import mage.target.targetadjustment.TargetAdjuster;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author escplan9 - Derek Monturo
|
* @author escplan9 - Derek Monturo
|
||||||
*/
|
*/
|
||||||
public final class PhyrexianPurge extends CardImpl {
|
public final class PhyrexianPurge extends CardImpl {
|
||||||
|
@ -28,24 +29,8 @@ public final class PhyrexianPurge extends CardImpl {
|
||||||
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE));
|
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE));
|
||||||
this.getSpellAbility().addEffect(new DestroyMultiTargetEffect());
|
this.getSpellAbility().addEffect(new DestroyMultiTargetEffect());
|
||||||
this.getSpellAbility().addEffect(new InfoEffect("<br><br>{this} costs 3 life more to cast for each target"));
|
this.getSpellAbility().addEffect(new InfoEffect("<br><br>{this} costs 3 life more to cast for each target"));
|
||||||
}
|
this.getSpellAbility().setTargetAdjuster(PhyrexianPurgeTargetAdjuster.instance);
|
||||||
|
this.getSpellAbility().setCostAdjuster(PhyrexianPurgeCostAdjuster.instance);
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
int numTargets = ability.getTargets().get(0).getTargets().size();
|
|
||||||
if (numTargets > 0) {
|
|
||||||
ability.getCosts().add(new PayLifeCost(numTargets * 3));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
if (ability instanceof SpellAbility) {
|
|
||||||
ability.getTargets().clear();
|
|
||||||
Player you = game.getPlayer(ownerId);
|
|
||||||
int maxTargets = you.getLife() / 3;
|
|
||||||
ability.addTarget(new TargetCreaturePermanent(0, maxTargets));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public PhyrexianPurge(final PhyrexianPurge card) {
|
public PhyrexianPurge(final PhyrexianPurge card) {
|
||||||
|
@ -57,3 +42,27 @@ public final class PhyrexianPurge extends CardImpl {
|
||||||
return new PhyrexianPurge(this);
|
return new PhyrexianPurge(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum PhyrexianPurgeCostAdjuster implements CostAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustCosts(Ability ability, Game game) {
|
||||||
|
int numTargets = ability.getTargets().get(0).getTargets().size();
|
||||||
|
if (numTargets > 0) {
|
||||||
|
ability.getCosts().add(new PayLifeCost(numTargets * 3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum PhyrexianPurgeTargetAdjuster implements TargetAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
|
ability.getTargets().clear();
|
||||||
|
Player you = game.getPlayer(ability.getControllerId());
|
||||||
|
int maxTargets = you.getLife() / 3;
|
||||||
|
ability.addTarget(new TargetCreaturePermanent(0, maxTargets));
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,36 +1,36 @@
|
||||||
|
|
||||||
package mage.cards.s;
|
package mage.cards.s;
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.SpellAbility;
|
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
|
import mage.abilities.costs.CostAdjuster;
|
||||||
import mage.abilities.costs.common.DiscardTargetCost;
|
import mage.abilities.costs.common.DiscardTargetCost;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.Effect;
|
||||||
import mage.abilities.effects.OneShotEffect;
|
|
||||||
import mage.abilities.effects.common.DestroyTargetEffect;
|
import mage.abilities.effects.common.DestroyTargetEffect;
|
||||||
|
import mage.abilities.effects.common.InfoEffect;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.CardType;
|
import mage.constants.CardType;
|
||||||
import mage.constants.Outcome;
|
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterLandCard;
|
import mage.filter.common.FilterLandCard;
|
||||||
import mage.filter.common.FilterLandPermanent;
|
import mage.filter.common.FilterLandPermanent;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.target.common.TargetCardInHand;
|
import mage.target.common.TargetCardInHand;
|
||||||
import mage.target.common.TargetLandPermanent;
|
import mage.target.common.TargetLandPermanent;
|
||||||
|
import mage.target.targetadjustment.TargetAdjuster;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
|
||||||
* @author fireshoes
|
* @author fireshoes
|
||||||
*/
|
*/
|
||||||
public final class ScorchedEarth extends CardImpl {
|
public final class ScorchedEarth extends CardImpl {
|
||||||
|
|
||||||
public ScorchedEarth(UUID ownerId, CardSetInfo setInfo) {
|
public ScorchedEarth(UUID ownerId, CardSetInfo setInfo) {
|
||||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{R}");
|
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{R}");
|
||||||
|
|
||||||
// As an additional cost to cast Scorched Earth, discard X land cards.
|
// As an additional cost to cast Scorched Earth, discard X land cards.
|
||||||
Ability ability = new SimpleStaticAbility(Zone.ALL, new ScorchedEarthRuleEffect());
|
Ability ability = new SimpleStaticAbility(Zone.ALL, new InfoEffect("as an additional cost to cast this spell, discard X land cards"));
|
||||||
ability.setRuleAtTheTop(true);
|
ability.setRuleAtTheTop(true);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
|
@ -39,53 +39,39 @@ public final class ScorchedEarth extends CardImpl {
|
||||||
effect.setText("Destroy X target lands");
|
effect.setText("Destroy X target lands");
|
||||||
this.getSpellAbility().addTarget(new TargetLandPermanent());
|
this.getSpellAbility().addTarget(new TargetLandPermanent());
|
||||||
this.getSpellAbility().addEffect(effect);
|
this.getSpellAbility().addEffect(effect);
|
||||||
}
|
this.getSpellAbility().setTargetAdjuster(ScorchedEarthTargetAdjuster.instance);
|
||||||
|
this.getSpellAbility().setCostAdjuster(ScorchedEarthCostAdjuster.instance);
|
||||||
@Override
|
|
||||||
public void adjustTargets(Ability ability, Game game) {
|
|
||||||
if (ability instanceof SpellAbility) {
|
|
||||||
ability.getTargets().clear();
|
|
||||||
int xValue = ability.getManaCostsToPay().getX();
|
|
||||||
ability.addTarget(new TargetLandPermanent(xValue, xValue, new FilterLandPermanent(), false));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScorchedEarth(final ScorchedEarth card) {
|
public ScorchedEarth(final ScorchedEarth card) {
|
||||||
super(card);
|
super(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void adjustCosts(Ability ability, Game game) {
|
|
||||||
int xValue = ability.getManaCostsToPay().getX();
|
|
||||||
if (xValue > 0) {
|
|
||||||
ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, new FilterLandCard("land cards"))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScorchedEarth copy() {
|
public ScorchedEarth copy() {
|
||||||
return new ScorchedEarth(this);
|
return new ScorchedEarth(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ScorchedEarthRuleEffect extends OneShotEffect {
|
enum ScorchedEarthTargetAdjuster implements TargetAdjuster {
|
||||||
|
instance;
|
||||||
public ScorchedEarthRuleEffect() {
|
|
||||||
super(Outcome.Benefit);
|
|
||||||
this.staticText = "as an additional cost to cast this spell, discard X land cards";
|
|
||||||
}
|
|
||||||
|
|
||||||
public ScorchedEarthRuleEffect(final ScorchedEarthRuleEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ScorchedEarthRuleEffect copy() {
|
public void adjustTargets(Ability ability, Game game) {
|
||||||
return new ScorchedEarthRuleEffect(this);
|
ability.getTargets().clear();
|
||||||
|
int xValue = ability.getManaCostsToPay().getX();
|
||||||
|
ability.addTarget(new TargetLandPermanent(xValue, xValue, new FilterLandPermanent(), false));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ScorchedEarthCostAdjuster implements CostAdjuster {
|
||||||
|
instance;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source) {
|
public void adjustCosts(Ability ability, Game game) {
|
||||||
return true;
|
int xValue = ability.getManaCostsToPay().getX();
|
||||||
|
if (xValue > 0) {
|
||||||
|
ability.addCost(new DiscardTargetCost(new TargetCardInHand(xValue, xValue, new FilterLandCard("land cards"))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue