[MOM] Implement Ozolith, the Shattered Spine

This commit is contained in:
theelk801 2023-04-04 19:31:17 -04:00
parent b2c1e3f8f8
commit b4e2059a61
8 changed files with 170 additions and 267 deletions

View file

@ -7,28 +7,33 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.costs.common.RemoveCountersSourceCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect; import mage.abilities.effects.common.EntersBattlefieldWithXCountersEffect;
import mage.abilities.effects.common.counter.AddCountersTargetEffect; import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.filter.StaticFilters; import mage.filter.StaticFilters;
import mage.game.Game; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.events.GameEvent; import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.util.CardUtil;
import java.util.UUID; import java.util.UUID;
/** /**
*
* @author Grath * @author Grath
*/ */
public final class BenevolentHydra extends CardImpl { public final class BenevolentHydra extends CardImpl {
private static final FilterPermanent filter = new FilterControlledCreaturePermanent("another creature you control");
static {
filter.add(AnotherPredicate.instance);
}
public BenevolentHydra(UUID ownerId, CardSetInfo setInfo) { public BenevolentHydra(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{X}{G}{G}");
@ -42,7 +47,7 @@ public final class BenevolentHydra extends CardImpl {
)); ));
// If one or more +1/+1 counters would be put on another creature you control, that many plus one +1/+1 counters are put on it instead. // If one or more +1/+1 counters would be put on another creature you control, that many plus one +1/+1 counters are put on it instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BenevolentHydraEffect())); this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(filter, CounterType.P1P1)));
// {T}, Remove a +1/+1 counter from Benevolent Hydra: Put a +1/+1 counter on another target creature you control. // {T}, Remove a +1/+1 counter from Benevolent Hydra: Put a +1/+1 counter on another target creature you control.
Ability ability = new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()).setText("Put a +1/+1 counter on another target creature you control"), new TapSourceCost()); Ability ability = new SimpleActivatedAbility(new AddCountersTargetEffect(CounterType.P1P1.createInstance()).setText("Put a +1/+1 counter on another target creature you control"), new TapSourceCost());
@ -60,49 +65,3 @@ public final class BenevolentHydra extends CardImpl {
return new BenevolentHydra(this); return new BenevolentHydra(this);
} }
} }
class BenevolentHydraEffect extends ReplacementEffectImpl {
BenevolentHydraEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false);
staticText = "If one or more +1/+1 counters would be put on another creature you control, that many plus one +1/+1 counters are put on it instead";
}
BenevolentHydraEffect(final BenevolentHydraEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmountForCounters(CardUtil.overflowInc(event.getAmount(), 1), true);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADD_COUNTERS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getData().equals(CounterType.P1P1.getName()) && event.getAmount() > 0) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null && permanent.isControlledBy(source.getControllerId())
&& permanent.isCreature(game) && !event.getTargetId().equals(source.getSourceId());
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public BenevolentHydraEffect copy() {
return new BenevolentHydraEffect(this);
}
}

View file

@ -1,23 +1,18 @@
package mage.cards.c; package mage.cards.c;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.DiesSourceTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount; import mage.abilities.dynamicvalue.common.SourcePermanentPowerCount;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.GainLifeEffect; import mage.abilities.effects.common.GainLifeEffect;
import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect;
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.Duration;
import mage.constants.Outcome;
import mage.constants.SubType; import mage.constants.SubType;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.filter.StaticFilters;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.UUID; import java.util.UUID;
@ -37,7 +32,7 @@ public final class ConclaveMentor extends CardImpl {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on that creature instead. // If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on that creature instead.
this.addAbility(new SimpleStaticAbility(new ConclaveMentorEffect())); this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(StaticFilters.FILTER_CONTROLLED_CREATURE, CounterType.P1P1)));
// When Conclave Mentor dies, you gain life equal to its power. // When Conclave Mentor dies, you gain life equal to its power.
this.addAbility(new DiesSourceTriggeredAbility(new GainLifeEffect(xValue, "you gain life equal to its power"))); this.addAbility(new DiesSourceTriggeredAbility(new GainLifeEffect(xValue, "you gain life equal to its power")));
@ -52,50 +47,3 @@ public final class ConclaveMentor extends CardImpl {
return new ConclaveMentor(this); return new ConclaveMentor(this);
} }
} }
class ConclaveMentorEffect extends ReplacementEffectImpl {
ConclaveMentorEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false);
staticText = "If one or more +1/+1 counters would be put on a creature you control, " +
"that many plus one +1/+1 counters are put on that creature instead";
}
private ConclaveMentorEffect(final ConclaveMentorEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmountForCounters(event.getAmount() + 1, true);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADD_COUNTERS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getData().equals(CounterType.P1P1.getName()) && event.getAmount() > 0) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null && permanent.isControlledBy(source.getControllerId())
&& permanent.isCreature(game);
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public ConclaveMentorEffect copy() {
return new ConclaveMentorEffect(this);
}
}

View file

@ -1,18 +1,12 @@
package mage.cards.h; package mage.cards.h;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect;
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.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.filter.StaticFilters;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import java.util.UUID; import java.util.UUID;
@ -25,7 +19,9 @@ public final class HardenedScales extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{G}");
// If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on it instead. // If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on it instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new HardenedScalesEffect())); this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(
StaticFilters.FILTER_CONTROLLED_CREATURE, CounterType.P1P1
)));
} }
@ -38,49 +34,3 @@ public final class HardenedScales extends CardImpl {
return new HardenedScales(this); return new HardenedScales(this);
} }
} }
class HardenedScalesEffect extends ReplacementEffectImpl {
HardenedScalesEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false);
staticText = "If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on it instead";
}
HardenedScalesEffect(final HardenedScalesEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmountForCounters(event.getAmount() + 1, true);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADD_COUNTERS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getData().equals(CounterType.P1P1.getName()) && event.getAmount() > 0) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null && permanent.isControlledBy(source.getControllerId())
&& permanent.isCreature(game);
}
return false;
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public HardenedScalesEffect copy() {
return new HardenedScalesEffect(this);
}
}

View file

@ -0,0 +1,56 @@
package mage.cards.o;
import mage.abilities.Ability;
import mage.abilities.common.ActivateAsSorceryActivatedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.counter.AddCountersTargetEffect;
import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect;
import mage.abilities.keyword.CyclingAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SuperType;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
public final class OzolithTheShatteredSpire extends CardImpl {
public OzolithTheShatteredSpire(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}{G}");
this.addSuperType(SuperType.LEGENDARY);
// If one or more +1/+1 counters would be put on an artifact or creature you control, that many plus one +1/+1 counters are put on it instead.
this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE, CounterType.P1P1
)));
// {1}{G}, {T}: Put a +1/+1 counter on target artifact or creature you control. Activate only as a sorcery.
Ability ability = new ActivateAsSorceryActivatedAbility(
new AddCountersTargetEffect(CounterType.P1P1.createInstance()), new ManaCostsImpl<>("{1}{G}")
);
ability.addCost(new TapSourceCost());
ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE));
this.addAbility(ability);
// Cycling {2}
this.addAbility(new CyclingAbility(new ManaCostsImpl<>("{2}")));
}
private OzolithTheShatteredSpire(final OzolithTheShatteredSpire card) {
super(card);
}
@Override
public OzolithTheShatteredSpire copy() {
return new OzolithTheShatteredSpire(this);
}
}

View file

@ -1,17 +1,16 @@
package mage.cards.p; package mage.cards.p;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect;
import mage.abilities.keyword.PartnerWithAbility; import mage.abilities.keyword.PartnerWithAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.CardType;
import mage.game.Game; import mage.constants.SubType;
import mage.game.events.GameEvent; import mage.constants.SuperType;
import mage.game.permanent.Permanent; import mage.constants.TargetController;
import mage.players.Player; import mage.filter.FilterPermanent;
import java.util.UUID; import java.util.UUID;
@ -20,6 +19,12 @@ import java.util.UUID;
*/ */
public final class PirImaginativeRascal extends CardImpl { public final class PirImaginativeRascal extends CardImpl {
private static final FilterPermanent filter = new FilterPermanent("permanent your team controls");
static {
filter.add(TargetController.TEAM.getControllerPredicate());
}
public PirImaginativeRascal(UUID ownerId, CardSetInfo setInfo) { public PirImaginativeRascal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
@ -32,7 +37,7 @@ public final class PirImaginativeRascal extends CardImpl {
this.addAbility(new PartnerWithAbility("Toothy, Imaginary Friend", true)); this.addAbility(new PartnerWithAbility("Toothy, Imaginary Friend", true));
// If one or more counters would be put on a permanent your team controls, that many plus one of each of those kinds of counters are put on that permanent instead. // If one or more counters would be put on a permanent your team controls, that many plus one of each of those kinds of counters are put on that permanent instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PirImaginativeRascalEffect())); this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(filter, null)));
} }
private PirImaginativeRascal(final PirImaginativeRascal card) { private PirImaginativeRascal(final PirImaginativeRascal card) {
@ -44,48 +49,3 @@ public final class PirImaginativeRascal extends CardImpl {
return new PirImaginativeRascal(this); return new PirImaginativeRascal(this);
} }
} }
class PirImaginativeRascalEffect extends ReplacementEffectImpl {
PirImaginativeRascalEffect() {
super(Duration.WhileOnBattlefield, Outcome.Benefit, false);
staticText = "If one or more counters would be put on a permanent your team controls, "
+ "that many plus one of each of those kinds of counters are put on that permanent instead";
}
PirImaginativeRascalEffect(final PirImaginativeRascalEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmountForCounters(event.getAmount() + 1, true);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADD_COUNTERS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
Player player = game.getPlayer(source.getControllerId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null && player != null && event.getAmount() > 0
&& !player.hasOpponent(permanent.getControllerId(), game);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public PirImaginativeRascalEffect copy() {
return new PirImaginativeRascalEffect(this);
}
}

View file

@ -4,12 +4,16 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.replacement.ModifyCountersAddedEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.filter.StaticFilters;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -27,10 +31,12 @@ public final class WindingConstrictor extends CardImpl {
this.toughness = new MageInt(3); this.toughness = new MageInt(3);
// If one or more counters would be put on an artifact or creature you control, that many plus one of each of those kinds of counters are put on that permanent instead. // If one or more counters would be put on an artifact or creature you control, that many plus one of each of those kinds of counters are put on that permanent instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindingConstrictorPermanentEffect())); this.addAbility(new SimpleStaticAbility(new ModifyCountersAddedEffect(
StaticFilters.FILTER_CONTROLLED_PERMANENT_ARTIFACT_OR_CREATURE, null
)));
// If you would get one or more counters, you get that many plus one of each of those kinds of counters instead. // If you would get one or more counters, you get that many plus one of each of those kinds of counters instead.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WindingConstrictorPlayerEffect())); this.addAbility(new SimpleStaticAbility(new WindingConstrictorPlayerEffect()));
} }
private WindingConstrictor(final WindingConstrictor card) { private WindingConstrictor(final WindingConstrictor card) {
@ -43,52 +49,6 @@ public final class WindingConstrictor extends CardImpl {
} }
} }
class WindingConstrictorPermanentEffect extends ReplacementEffectImpl {
WindingConstrictorPermanentEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false);
staticText = "If one or more counters would be put on an artifact or creature you control, "
+ "that many plus one of each of those kinds of counters are put on that permanent instead";
}
WindingConstrictorPermanentEffect(final WindingConstrictorPermanentEffect effect) {
super(effect);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmountForCounters(event.getAmount() + 1, true);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADD_COUNTERS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null
&& event.getAmount() > 0
&& (permanent.isCreature(game) || permanent.isArtifact(game))
&& permanent.isControlledBy(source.getControllerId());
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public WindingConstrictorPermanentEffect copy() {
return new WindingConstrictorPermanentEffect(this);
}
}
class WindingConstrictorPlayerEffect extends ReplacementEffectImpl { class WindingConstrictorPlayerEffect extends ReplacementEffectImpl {
WindingConstrictorPlayerEffect() { WindingConstrictorPlayerEffect() {

View file

@ -85,6 +85,7 @@ public final class MarchOfTheMachine extends ExpansionSet {
cards.add(new SetCardInfo("Norn's Inquisitor", 29, Rarity.UNCOMMON, mage.cards.n.NornsInquisitor.class)); cards.add(new SetCardInfo("Norn's Inquisitor", 29, Rarity.UNCOMMON, mage.cards.n.NornsInquisitor.class));
cards.add(new SetCardInfo("Omen Hawker", 70, Rarity.UNCOMMON, mage.cards.o.OmenHawker.class)); cards.add(new SetCardInfo("Omen Hawker", 70, Rarity.UNCOMMON, mage.cards.o.OmenHawker.class));
cards.add(new SetCardInfo("Oracle of Tragedy", 71, Rarity.UNCOMMON, mage.cards.o.OracleOfTragedy.class)); cards.add(new SetCardInfo("Oracle of Tragedy", 71, Rarity.UNCOMMON, mage.cards.o.OracleOfTragedy.class));
cards.add(new SetCardInfo("Ozolith, the Shattered Spire", 198, Rarity.RARE, mage.cards.o.OzolithTheShatteredSpire.class));
cards.add(new SetCardInfo("Phyrexian Awakening", 30, Rarity.UNCOMMON, mage.cards.p.PhyrexianAwakening.class)); cards.add(new SetCardInfo("Phyrexian Awakening", 30, Rarity.UNCOMMON, mage.cards.p.PhyrexianAwakening.class));
cards.add(new SetCardInfo("Phyrexian Gargantua", 121, Rarity.UNCOMMON, mage.cards.p.PhyrexianGargantua.class)); cards.add(new SetCardInfo("Phyrexian Gargantua", 121, Rarity.UNCOMMON, mage.cards.p.PhyrexianGargantua.class));
cards.add(new SetCardInfo("Phyrexian Pegasus", 324, Rarity.COMMON, mage.cards.p.PhyrexianPegasus.class)); cards.add(new SetCardInfo("Phyrexian Pegasus", 324, Rarity.COMMON, mage.cards.p.PhyrexianPegasus.class));

View file

@ -0,0 +1,69 @@
package mage.abilities.effects.common.replacement;
import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.counters.CounterType;
import mage.filter.FilterPermanent;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.util.CardUtil;
/**
* @author TheElk801
*/
public class ModifyCountersAddedEffect extends ReplacementEffectImpl {
private final FilterPermanent filter;
private final CounterType counterType;
public ModifyCountersAddedEffect(FilterPermanent filter, CounterType counterType) {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature, false);
this.filter = filter;
this.counterType = counterType;
staticText = "if one or more " + (counterType != null ? counterType + " " : "") + "counters would be put on " +
CardUtil.addArticle(filter.getMessage()) + " you control, that many plus one " +
(counterType != null ? counterType : "of each of those kinds of") + " counters are put on it instead";
}
private ModifyCountersAddedEffect(final ModifyCountersAddedEffect effect) {
super(effect);
this.filter = effect.filter;
this.counterType = effect.counterType;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
event.setAmountForCounters(event.getAmount() + 1, true);
return false;
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.ADD_COUNTERS;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if ((counterType != null && !event.getData().equals(counterType.getName())) || event.getAmount() <= 0) {
return false;
}
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent == null) {
permanent = game.getPermanentEntering(event.getTargetId());
}
return permanent != null && filter.match(permanent, source.getControllerId(), source, game);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public ModifyCountersAddedEffect copy() {
return new ModifyCountersAddedEffect(this);
}
}