reworked various cards which use this.getId in their constructor

This commit is contained in:
Evan Kranzler 2022-02-21 18:10:58 -05:00
parent 091fd16af9
commit df1067ada7
15 changed files with 246 additions and 253 deletions

View file

@ -12,8 +12,6 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanent;
@ -25,19 +23,27 @@ import java.util.UUID;
*/
public final class BlazingShoal extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a red card with mana value X from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.RED));
}
public BlazingShoal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{R}{R}");
this.subtype.add(SubType.ARCANE);
// You may exile a red card with converted mana cost X from your hand rather than pay Blazing Shoal's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a red card with mana value X from your hand");
filter.add(new ColorPredicate(ObjectColor.RED));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(
new TargetCardInHand(filter), true
)));
// Target creature gets +X/+0 until end of turn.
this.getSpellAbility().addEffect(new BoostTargetEffect(ExileFromHandCostCardConvertedMana.instance, StaticValue.get(0), Duration.EndOfTurn));
this.getSpellAbility().addEffect(new BoostTargetEffect(
ExileFromHandCostCardConvertedMana.instance,
StaticValue.get(0), Duration.EndOfTurn
));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}

View file

@ -1,7 +1,5 @@
package mage.cards.b;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
@ -11,29 +9,35 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.counters.CounterType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanentAmount;
import java.util.UUID;
/**
*
* @author LoneFox
*/
public final class BountyOfTheHunt extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a green card from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
public BountyOfTheHunt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{G}{G}");
// You may exile a green card from your hand rather than pay Bounty of the Hunt's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("green card from your hand");
filter.add(new ColorPredicate(ObjectColor.GREEN));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
// Distribute three +1/+1 counters among one, two, or three target creatures. For each +1/+1 counter you put on a creature this way, remove a +1/+1 counter from that creature at the beginning of the next cleanup step.
this.getSpellAbility().addEffect(new DistributeCountersEffect(CounterType.P1P1, 3, true, "one, two, or three target creatures"));
this.getSpellAbility().addEffect(new DistributeCountersEffect(
CounterType.P1P1, 3, true,
"one, two, or three target creatures"
));
this.getSpellAbility().addTarget(new TargetCreaturePermanentAmount(3));
}

View file

@ -1,7 +1,5 @@
package mage.cards.c;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
@ -12,24 +10,26 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.counters.CounterType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanentAmount;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class Contagion extends CardImpl {
public Contagion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{B}{B}");
private static final FilterOwnedCard filter
= new FilterOwnedCard("a black card from your hand");
FilterOwnedCard filter = new FilterOwnedCard("black card from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
}
public Contagion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{B}{B}");
// You may pay 1 life and exile a black card from your hand rather than pay Contagion's mana cost.
AlternativeCostSourceAbility ability = new AlternativeCostSourceAbility(new PayLifeCost(1));
@ -38,7 +38,10 @@ public final class Contagion extends CardImpl {
// Distribute two -2/-1 counters among one or two target creatures.
this.getSpellAbility().addTarget(new TargetCreaturePermanentAmount(2));
this.getSpellAbility().addEffect(new DistributeCountersEffect(CounterType.M2M1, 2, false, "one or two target creatures"));
this.getSpellAbility().addEffect(new DistributeCountersEffect(
CounterType.M2M1, 2, false,
"one or two target creatures"
));
}
private Contagion(final Contagion card) {

View file

@ -14,8 +14,6 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.stack.Spell;
@ -29,15 +27,21 @@ import java.util.UUID;
*/
public final class DisruptingShoal extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a blue card with mana value X from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
}
public DisruptingShoal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{U}{U}");
this.subtype.add(SubType.ARCANE);
// You may exile a blue card with converted mana cost X from your hand rather than pay Disrupting Shoal's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a blue card with mana value X from your hand");
filter.add(new ColorPredicate(ObjectColor.BLUE));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(
new TargetCardInHand(filter), true
)));
// 2/1/2005: Disrupting Shoal can target any spell, but does nothing unless that spell's converted mana cost is X.
// Counter target spell if its converted mana cost is X.
@ -96,5 +100,4 @@ class DisruptingShoalCounterTargetEffect extends OneShotEffect {
public String getText(Mode mode) {
return "Counter target spell if its mana value is X";
}
}

View file

@ -1,20 +1,26 @@
package mage.cards.e;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.ExileTargetEffect;
import mage.abilities.effects.common.ReturnCreaturesFromExileEffect;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ExileTargetForSourceEffect;
import mage.abilities.mana.ColorlessManaAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.ExileZone;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil;
import java.util.UUID;
public final class EndlessSands extends CardImpl {
@ -27,14 +33,13 @@ public final class EndlessSands extends CardImpl {
this.addAbility(new ColorlessManaAbility());
// {2}, {T}: Exile target creature you control.
Ability exileAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileTargetEffect(this.getId(), this.getIdName()), new ManaCostsImpl("{2}"));
Ability exileAbility = new SimpleActivatedAbility(new ExileTargetForSourceEffect(), new GenericManaCost(2));
exileAbility.addCost(new TapSourceCost());
exileAbility.addTarget(new TargetControlledCreaturePermanent());
this.addAbility(exileAbility);
// {4}, {T}, Sacrifice Endless Sands: Return each creature card exiled with Endless Sands to the battlefield under its owner's control.
ReturnCreaturesFromExileEffect returnFromExileEffect = new ReturnCreaturesFromExileEffect(this.getId(), true, "Return each creature card exiled with {this} to the battlefield under its owner's control.");
Ability returnAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, returnFromExileEffect, new ManaCostsImpl("{4}"));
Ability returnAbility = new SimpleActivatedAbility(new EndlessSandsEffect(), new GenericManaCost(4));
returnAbility.addCost(new TapSourceCost());
returnAbility.addCost(new SacrificeSourceCost());
this.addAbility(returnAbility);
@ -49,3 +54,34 @@ public final class EndlessSands extends CardImpl {
return new EndlessSands(this);
}
}
class EndlessSandsEffect extends OneShotEffect {
EndlessSandsEffect() {
super(Outcome.Benefit);
staticText = "return each creature card exiled with {this} to the battlefield under its owner's control";
}
private EndlessSandsEffect(final EndlessSandsEffect effect) {
super(effect);
}
@Override
public EndlessSandsEffect copy() {
return new EndlessSandsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ExileZone exileZone = game.getExile().getExileZone(CardUtil.getExileZoneId(game, source));
return player != null && exileZone != null
&& player.moveCards(
exileZone.getCards(game), Zone.BATTLEFIELD, source, game,
false, false, true, null
);
}
}

View file

@ -9,8 +9,6 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.TargetSpell;
import mage.target.common.TargetCardInHand;
@ -22,14 +20,17 @@ import java.util.UUID;
*/
public final class ForceOfWill extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a blue card from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
}
public ForceOfWill(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}{U}");
// You may pay 1 life and exile a blue card from your hand rather than pay Force of Will's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a blue card from your hand");
filter.add(new ColorPredicate(ObjectColor.BLUE));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
AlternativeCostSourceAbility ability = new AlternativeCostSourceAbility(new PayLifeCost(1));
ability.addCost(new ExileFromHandCost(new TargetCardInHand(filter)));
this.addAbility(ability);

View file

@ -1,7 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
@ -11,34 +9,33 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterSpell;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.filter.predicate.other.NumberOfTargetsPredicate;
import mage.target.TargetSpell;
import mage.target.common.TargetCardInHand;
import java.util.UUID;
/**
*
* @author jonubuu
*/
public final class Misdirection extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a blue card from your hand");
private static final FilterSpell filter2 = new FilterSpell("spell with a single target");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
filter2.add(new NumberOfTargetsPredicate(1));
}
public Misdirection(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{3}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{U}{U}");
// You may exile a blue card from your hand rather than pay Misdirection's mana cost.
FilterOwnedCard filterCardInHand = new FilterOwnedCard("a blue card from your hand");
filterCardInHand.add(new ColorPredicate(ObjectColor.BLUE));
// the exile cost can never be paid with the card itself
filterCardInHand.add(Predicates.not(new CardIdPredicate(this.getId())));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filterCardInHand))));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
// Change the target of target spell with a single target.
this.getSpellAbility().addEffect(new ChooseNewTargetsTargetEffect(true, true));
@ -54,4 +51,3 @@ public final class Misdirection extends CardImpl {
return new Misdirection(this);
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.n;
import mage.ObjectColor;
@ -11,33 +10,34 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class NourishingShoal extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a red card with mana value X from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.GREEN));
}
public NourishingShoal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{G}{G}");
this.subtype.add(SubType.ARCANE);
// You may exile a green card with converted mana cost X from your hand rather than pay Nourishing Shoal's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a green card with mana value X from your hand");
filter.add(new ColorPredicate(ObjectColor.GREEN));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(
new TargetCardInHand(filter), true
)));
// You gain X life.
this.getSpellAbility().addEffect(new GainLifeEffect(ExileFromHandCostCardConvertedMana.instance));
}
private NourishingShoal(final NourishingShoal card) {

View file

@ -1,41 +1,38 @@
package mage.cards.o;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.StateTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SkipUntapOptionalAbility;
import mage.abilities.condition.CompoundCondition;
import mage.abilities.condition.Condition;
import mage.abilities.condition.common.SourceTappedCondition;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.decorator.ConditionalContinuousEffect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.GainControlTargetEffect;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.constants.*;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author LevelX2
* @author TheElk801
*/
public final class OldManOfTheSea extends CardImpl {
private static final FilterPermanent filter
= new FilterCreaturePermanent("creature with less than or equal power");
static {
filter.add(OldManOfTheSeaPredicate.instance);
}
public OldManOfTheSea(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
this.subtype.add(SubType.DJINN);
this.power = new MageInt(2);
@ -45,16 +42,9 @@ public final class OldManOfTheSea extends CardImpl {
this.addAbility(new SkipUntapOptionalAbility());
// {tap}: Gain control of target creature with power less than or equal to Old Man of the Sea's power for as long as Old Man of the Sea remains tapped and that creature's power remains less than or equal to Old Man of the Sea's power.
FilterCreaturePermanent controllableCreatures = new FilterCreaturePermanent("creature with power less than or equal to Old Man of the Sea's power");
controllableCreatures.add(new PowerLowerEqualSourcePredicate(this.getId()));
ConditionalContinuousEffect effect = new ConditionalContinuousEffect(
new OldManOfTheSeaGainControlTargetEffect(Duration.Custom, true), new CompoundCondition(SourceTappedCondition.TAPPED, new SourcePowerGreaterEqualTargetCondition()),
"Gain control of target creature with power less than or equal to {this}'s power for as long as {this} remains tapped and that creature's power remains less than or equal to {this}'s power");
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent(controllableCreatures));
Ability ability = new SimpleActivatedAbility(new OldManOfTheSeaEffect(), new TapSourceCost());
ability.addTarget(new TargetPermanent(filter));
this.addAbility(ability);
// internal ability to check condition
this.addAbility(new OldManOfTheSeaStateBasedTriggeredAbility());
}
private OldManOfTheSea(final OldManOfTheSea card) {
@ -67,109 +57,61 @@ public final class OldManOfTheSea extends CardImpl {
}
}
class OldManOfTheSeaGainControlTargetEffect extends GainControlTargetEffect {
enum OldManOfTheSeaPredicate implements ObjectSourcePlayerPredicate<Permanent> {
instance;
public OldManOfTheSeaGainControlTargetEffect(Duration duration, boolean fixedControl) {
super(duration, fixedControl);
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(input.getSourceId());
return sourcePermanent != null
&& input.getObject().getPower().getValue() <= sourcePermanent.getPower().getValue();
}
}
class OldManOfTheSeaEffect extends ContinuousEffectImpl {
OldManOfTheSeaEffect() {
super(Duration.Custom, Outcome.GainControl);
staticText = "gain control of target creature with power less than or equal to {this}'s power for as long as {this} remains tapped and that creature's power remains less than or equal to {this}'s power";
}
public OldManOfTheSeaGainControlTargetEffect(final OldManOfTheSeaGainControlTargetEffect effect) {
private OldManOfTheSeaEffect(final OldManOfTheSeaEffect effect) {
super(effect);
}
@Override
public void init(Ability source, Game game) {
super.init(source, game);
// save target id to be available for hidden state based triggered effect
game.getState().setValue("target" + source.getSourceId(), getTargetPointer().getFirst(game, source));
public OldManOfTheSeaEffect copy() {
return new OldManOfTheSeaEffect(this);
}
@Override
public OldManOfTheSeaGainControlTargetEffect copy() {
return new OldManOfTheSeaGainControlTargetEffect(this);
}
}
/*
used a state based triggered effect here (not going to stack, so running hidden) to compare power of the controlled
creature to Old Man of the seas power. It's not possible to do this as condition of continuous effect, because the
time the effect checks its condition, the layered effects that modify power are not applied yet.
result is save to a state value to be available for the condition of the continuous effect
*/
class OldManOfTheSeaStateBasedTriggeredAbility extends StateTriggeredAbility {
public OldManOfTheSeaStateBasedTriggeredAbility() {
super(Zone.BATTLEFIELD, new InfoEffect(""));
this.setRuleVisible(false);
this.usesStack = false;
}
public OldManOfTheSeaStateBasedTriggeredAbility(final OldManOfTheSeaStateBasedTriggeredAbility ability) {
super(ability);
}
@Override
public OldManOfTheSeaStateBasedTriggeredAbility copy() {
return new OldManOfTheSeaStateBasedTriggeredAbility(this);
}
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Permanent sourcePermanent = game.getPermanent(getSourceId());
if (sourcePermanent != null && sourcePermanent.isTapped()) {
UUID controlledCreatureId = (UUID) game.getState().getValue("target" + getSourceId());
if (controlledCreatureId != null) {
Permanent controlledCreature = game.getPermanent(controlledCreatureId);
if (controlledCreature != null) {
if (controlledCreature.getPower().getValue() > sourcePermanent.getPower().getValue()) {
game.getState().setValue("powerCondition" + getSourceId(), Boolean.TRUE);
}
public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) {
Permanent sourcePermanent = source.getSourcePermanentIfItStillExists(game);
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (sourcePermanent == null || permanent == null || !sourcePermanent.isTapped()) {
discard();
return false;
}
switch (layer) {
case ControlChangingEffects_2:
permanent.changeControllerId(source.getControllerId(), game, source);
return true;
case RulesEffects:
if (permanent.getPower().getValue() > sourcePermanent.getPower().getValue()) {
discard();
return false;
}
}
return false;
}
}
class SourcePowerGreaterEqualTargetCondition implements Condition {
@Override
public boolean apply(Game game, Ability source) {
Object object = game.getState().getValue("powerCondition" + source.getSourceId());
if (object != null && (Boolean) object) {
// reset the values
game.getState().setValue("powerCondition" + source.getSourceId(), Boolean.FALSE);
game.getState().setValue("target" + source.getSourceId(), null);
// stop controlling target
return false;
}
return true;
}
}
class PowerLowerEqualSourcePredicate implements ObjectSourcePlayerPredicate<Permanent> {
UUID sourceId;
public PowerLowerEqualSourcePredicate(UUID sourceId) {
this.sourceId = sourceId;
}
@Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
Permanent sourcePermanent = game.getPermanent(sourceId);
Permanent permanent = input.getObject();
if (permanent != null && sourcePermanent != null) {
if (permanent.getPower().getValue() <= sourcePermanent.getPower().getValue()) {
return true;
}
}
return false;
}
@Override
public String toString() {
return "creature with power less than or equal to {this}'s power";
public boolean hasLayer(Layer layer) {
return layer == Layer.ControlChangingEffects_2 || layer == Layer.RulesEffects;
}
}

View file

@ -12,12 +12,13 @@ import mage.abilities.effects.common.counter.AddCountersSourceEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
@ -43,12 +44,6 @@ public final class OliviaVoldaren extends CardImpl {
this.power = new MageInt(3);
this.toughness = new MageInt(3);
String rule = "Gain control of target Vampire for as long as you control {this}";
FilterPermanent filter2 = new FilterPermanent();
filter2.add(TargetController.YOU.getControllerPredicate());
filter2.add(new CardIdPredicate(this.getId()));
this.addAbility(FlyingAbility.getInstance());
// {1}{R}: Olivia Voldaren deals 1 damage to another target creature. That creature becomes a Vampire in addition to its other types. Put a +1/+1 counter on Olivia Voldaren.

View file

@ -1,7 +1,5 @@
package mage.cards.p;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
@ -10,26 +8,28 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanentAmount;
import java.util.UUID;
/**
*
* @author Plopman
*/
public final class Pyrokinesis extends CardImpl {
public Pyrokinesis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{4}{R}{R}");
private static final FilterOwnedCard filter
= new FilterOwnedCard("a red card from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.RED));
}
public Pyrokinesis(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{4}{R}{R}");
// You may exile a red card from your hand rather than pay Pyrokinesis's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a red card from your hand");
filter.add(new ColorPredicate(ObjectColor.RED));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
// Pyrokinesis deals 4 damage divided as you choose among any number of target creatures.

View file

@ -1,7 +1,5 @@
package mage.cards.r;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
@ -10,31 +8,35 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.StaticFilters;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import java.util.UUID;
/**
*
* @author ciaccona007
*/
public final class ReverentMantra extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a white card from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
}
public ReverentMantra(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{3}{W}");
// You may exile a white card from your hand rather than pay Reverent Mantra's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a white card from your hand");
filter.add(new ColorPredicate(ObjectColor.WHITE));
filter.add(Predicates.not(new CardIdPredicate(this.getId())));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
// Choose a color. All creatures gain protection from the chosen color until end of turn.
this.getSpellAbility().addEffect(new GainProtectionFromColorAllEffect(Duration.EndOfTurn, new FilterCreaturePermanent()));
this.getSpellAbility().addEffect(new GainProtectionFromColorAllEffect(
Duration.EndOfTurn, StaticFilters.FILTER_PERMANENT_CREATURE
));
}
private ReverentMantra(final ReverentMantra card) {

View file

@ -1,7 +1,5 @@
package mage.cards.s;
import java.util.UUID;
import mage.MageObject;
import mage.ObjectColor;
import mage.abilities.Ability;
@ -16,8 +14,6 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
@ -27,24 +23,33 @@ import mage.target.TargetSource;
import mage.target.common.TargetAnyTarget;
import mage.target.common.TargetCardInHand;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class ShiningShoal extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a white card with mana value X from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.WHITE));
}
public ShiningShoal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{W}{W}");
this.subtype.add(SubType.ARCANE);
// You may exile a white card with converted mana cost X from your hand rather than pay Shining Shoal's mana cost
FilterOwnedCard filter = new FilterOwnedCard("a white card with mana value X from your hand");
filter.add(new ColorPredicate(ObjectColor.WHITE));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(
new TargetCardInHand(filter), true
)));
// The next X damage that a source of your choice would deal to you and/or creatures you control this turn is dealt to any target instead.
this.getSpellAbility().addEffect(new ShiningShoalRedirectDamageTargetEffect(Duration.EndOfTurn, ExileFromHandCostCardConvertedMana.instance));
this.getSpellAbility().addEffect(new ShiningShoalRedirectDamageTargetEffect(
Duration.EndOfTurn, ExileFromHandCostCardConvertedMana.instance
));
this.getSpellAbility().addTarget(new TargetSource());
this.getSpellAbility().addTarget(new TargetAnyTarget());
}
@ -129,5 +134,4 @@ class ShiningShoalRedirectDamageTargetEffect extends RedirectDamageFromSourceToT
}
return false;
}
}

View file

@ -1,4 +1,3 @@
package mage.cards.s;
import mage.ObjectColor;
@ -14,8 +13,6 @@ import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.SubType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanent;
@ -23,25 +20,29 @@ import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author LevelX2
*/
public final class SickeningShoal extends CardImpl {
private static final FilterOwnedCard filter
= new FilterOwnedCard("a black card with mana value X from your hand");
private static final DynamicValue xValue = new SignInversionDynamicValue(ExileFromHandCostCardConvertedMana.instance);
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
}
public SickeningShoal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{X}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{X}{B}{B}");
this.subtype.add(SubType.ARCANE);
// You may exile a black card with converted mana cost X from your hand rather than pay Sickening Shoal's mana cost.
FilterOwnedCard filter = new FilterOwnedCard("a black card with mana value X from your hand");
filter.add(new ColorPredicate(ObjectColor.BLACK));
filter.add(Predicates.not(new CardIdPredicate(this.getId()))); // the exile cost can never be paid with the card itself
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter), true)));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(
new TargetCardInHand(filter), true
)));
// Target creature gets -X/-X until end of turn.
DynamicValue x = new SignInversionDynamicValue(ExileFromHandCostCardConvertedMana.instance);
this.getSpellAbility().addEffect(new BoostTargetEffect(x, x, Duration.EndOfTurn, true));
this.getSpellAbility().addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn, true));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
}

View file

@ -1,7 +1,5 @@
package mage.cards.s;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.costs.AlternativeCostSourceAbility;
import mage.abilities.costs.common.ExileFromHandCost;
@ -10,27 +8,29 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.common.FilterOwnedCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardIdPredicate;
import mage.filter.predicate.mageobject.ColorPredicate;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class Snapback extends CardImpl {
public Snapback(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{1}{U}");
private static final FilterOwnedCard filter
= new FilterOwnedCard("a blue card from your hand");
static {
filter.add(new ColorPredicate(ObjectColor.BLUE));
}
public Snapback(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{U}");
// You may exile a blue card from your hand rather than pay Snapback's mana cost.
FilterOwnedCard filterCardInHand = new FilterOwnedCard("a blue card from your hand");
filterCardInHand.add(new ColorPredicate(ObjectColor.BLUE));
filterCardInHand.add(Predicates.not(new CardIdPredicate(this.getId())));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filterCardInHand))));
this.addAbility(new AlternativeCostSourceAbility(new ExileFromHandCost(new TargetCardInHand(filter))));
// Return target creature to its owner's hand.
this.getSpellAbility().addTarget(new TargetCreaturePermanent());