consolidate effects which add counters to players

This commit is contained in:
theelk801 2023-01-26 08:35:39 -05:00
parent de3efda5ce
commit f942c36651
12 changed files with 74 additions and 152 deletions

View file

@ -1,15 +1,11 @@
package mage.cards.d;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateTokenEffect;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
@ -17,8 +13,9 @@ import mage.counters.CounterType;
import mage.filter.FilterSpell;
import mage.game.permanent.token.DaxosSpiritToken;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class DaxosTheReturned extends CardImpl {
@ -38,10 +35,9 @@ public final class DaxosTheReturned extends CardImpl {
this.toughness = new MageInt(2);
// Whenever you cast an enchantment spell, you get an experience counter.
Effect effect = new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1));
effect.setText("you get an experience counter");
Ability ability = new SpellCastControllerTriggeredAbility(effect, filter, false);
this.addAbility(ability);
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersPlayersEffect(
CounterType.EXPERIENCE.createInstance(), TargetController.YOU
), filter, false));
// {1}{W}{B}: Create a white and black Spirit enchantment creature token. It has
// "This creature's power and toughness are each equal to the number of experience counters you have."

View file

@ -1,32 +1,32 @@
package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfCombatTriggeredAbility;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.common.EntersBattlefieldControlledTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.filter.predicate.mageobject.AnotherPredicate;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class EzuriClawOfProgress extends CardImpl {
final private static FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
final private static FilterControlledCreaturePermanent filter
= new FilterControlledCreaturePermanent("a creature with power 2 or less");
final private static FilterControlledCreaturePermanent filter2 = new FilterControlledCreaturePermanent();
static {
@ -34,8 +34,6 @@ public final class EzuriClawOfProgress extends CardImpl {
filter2.add(AnotherPredicate.instance);
}
private static final String rule = "Whenever a creature with power 2 or less enters the battlefield under your control, you get an experience counter.";
public EzuriClawOfProgress(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}{U}");
addSuperType(SuperType.LEGENDARY);
@ -46,8 +44,9 @@ public final class EzuriClawOfProgress extends CardImpl {
this.toughness = new MageInt(3);
// Whenever a creature with power 2 or less enters the battlefield under your control, you get an experience counter.
this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new AddCountersControllerEffect(
CounterType.EXPERIENCE.createInstance(1)), filter, false, rule, true));
this.addAbility(new EntersBattlefieldControlledTriggeredAbility(new AddCountersPlayersEffect(
CounterType.EXPERIENCE.createInstance(), TargetController.YOU
), filter));
// At the beginning of combat on your turn, put X +1/+1 counters on another target creature you control, where X is the number of experience counters you have.
Ability ability = new BeginningOfCombatTriggeredAbility(new EzuriClawOfProgressEffect(), TargetController.YOU, false);

View file

@ -1,22 +1,17 @@
package mage.cards.i;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.abilities.keyword.InfectAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
* @author Loki
@ -31,9 +26,9 @@ public final class IchorRats extends CardImpl {
this.power = new MageInt(2);
this.toughness = new MageInt(1);
this.addAbility(InfectAbility.getInstance());
this.addAbility(new EntersBattlefieldTriggeredAbility(
new AddPoisonCounterAllEffect(TargetController.EACH_PLAYER), false
));
this.addAbility(new EntersBattlefieldTriggeredAbility(new AddCountersPlayersEffect(
CounterType.POISON.createInstance(), TargetController.EACH_PLAYER
), false));
}
private IchorRats(final IchorRats card) {

View file

@ -1,17 +1,18 @@
package mage.cards.i;
import java.util.UUID;
import mage.abilities.effects.common.DamageWithPowerFromOneToAnotherTargetEffect;
import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.filter.StaticFilters;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
/**
* @author TheElk801
*/
@ -24,7 +25,9 @@ public final class InfectiousBite extends CardImpl {
this.getSpellAbility().addEffect(new DamageWithPowerFromOneToAnotherTargetEffect());
this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
this.getSpellAbility().addTarget(new TargetCreaturePermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL));
this.getSpellAbility().addEffect(new AddPoisonCounterAllEffect(TargetController.OPPONENT));
this.getSpellAbility().addEffect(new AddCountersPlayersEffect(
CounterType.POISON.createInstance(), TargetController.OPPONENT
));
}
private InfectiousBite(final InfectiousBite card) {

View file

@ -1,7 +1,5 @@
package mage.cards.k;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
@ -9,25 +7,21 @@ import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.abilities.keyword.DoubleStrikeAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.ComparisonType;
import mage.constants.Duration;
import mage.constants.SuperType;
import mage.constants.Zone;
import mage.constants.*;
import mage.counters.CounterType;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ManaValuePredicate;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID;
/**
*
* @author fireshoes
*/
public final class KalemneDiscipleOfIroas extends CardImpl {
@ -40,7 +34,7 @@ public final class KalemneDiscipleOfIroas extends CardImpl {
}
public KalemneDiscipleOfIroas(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{W}");
addSuperType(SuperType.LEGENDARY);
this.subtype.add(SubType.GIANT);
this.subtype.add(SubType.SOLDIER);
@ -54,10 +48,9 @@ public final class KalemneDiscipleOfIroas extends CardImpl {
this.addAbility(VigilanceAbility.getInstance());
// Whenever you cast a creature spell with converted mana cost 5 or greater, you get an experience counter.
Effect effect = new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1));
effect.setText("you get an experience counter");
Ability ability = new SpellCastControllerTriggeredAbility(effect, filterSpell, false);
this.addAbility(ability);
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersPlayersEffect(
CounterType.EXPERIENCE.createInstance(), TargetController.YOU
), filterSpell, false));
// Kalemne, Disciple of Iroas gets +1/+1 for each experience counter you have.
DynamicValue value = new SourceControllerExperienceCountersCount();

View file

@ -11,7 +11,7 @@ import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.continuous.BoostSourceEffect;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.abilities.keyword.HasteAbility;
import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl;
@ -53,7 +53,7 @@ public final class KelsienThePlague extends CardImpl {
// {T}: Kelsien deals 1 damage to target creature you don't control. When that creature dies this turn, you get an experience counter.
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(1), new TapSourceCost());
ability.addEffect(new CreateDelayedTriggeredAbilityEffect(new WhenTargetDiesDelayedTriggeredAbility(
new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance())
new AddCountersPlayersEffect(CounterType.EXPERIENCE.createInstance(), TargetController.YOU)
)));
ability.addTarget(new TargetPermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL));
this.addAbility(ability);

View file

@ -5,7 +5,7 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfYourEndStepTriggeredAbility;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -42,9 +42,9 @@ public final class MerenOfClanNelToth extends CardImpl {
this.toughness = new MageInt(4);
// Whenever another creature you control dies, you get an experience counter.
this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersControllerEffect(
CounterType.EXPERIENCE.createInstance(1)
).setText("you get an experience counter"), false, filter));
this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersPlayersEffect(
CounterType.EXPERIENCE.createInstance(), TargetController.YOU
), false, filter));
// At the beginning of your end step, choose target creature card in your graveyard.
// If that card's converted mana cost is less than or equal to the number of experience counters you have, return it to the battlefield. Otherwise, put it into your hand.

View file

@ -1,6 +1,5 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
@ -8,7 +7,7 @@ import mage.abilities.SpellAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.common.cost.CostModificationEffectImpl;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -22,8 +21,9 @@ import mage.game.stack.Spell;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.UUID;
/**
*
* @author emerald000
*/
public final class MizzixOfTheIzmagnus extends CardImpl {
@ -43,8 +43,9 @@ public final class MizzixOfTheIzmagnus extends CardImpl {
this.toughness = new MageInt(2);
// Whenever you cast an instant or sorcery spell with converted mana cost greater than the number of experience counters you have, you get an experience counter.
this.addAbility(new SpellCastControllerTriggeredAbility(
new AddCountersControllerEffect(CounterType.EXPERIENCE.createInstance(1)), filter, false));
this.addAbility(new SpellCastControllerTriggeredAbility(new AddCountersPlayersEffect(
CounterType.EXPERIENCE.createInstance(), TargetController.YOU
), filter, false));
// Instant and sorcery spells you cast cost {1} less to cast for each experience counter you have.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new MizzixOfTheIzmagnusCostReductionEffect()));

View file

@ -1,24 +1,17 @@
package mage.cards.p;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.OnEventTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.abilities.keyword.InfectAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.game.Game;
import mage.game.events.GameEvent.EventType;
import mage.players.Player;
import java.util.UUID;
/**
* @author Viserion
@ -34,7 +27,9 @@ public final class PhyrexianVatmother extends CardImpl {
this.toughness = new MageInt(5);
this.addAbility(InfectAbility.getInstance());
this.addAbility(new BeginningOfUpkeepTriggeredAbility(
new AddPoisonCounterAllEffect(TargetController.YOU), TargetController.YOU, false
new AddCountersPlayersEffect(
CounterType.POISON.createInstance(), TargetController.YOU
), TargetController.YOU, false
));
}

View file

@ -1,23 +1,22 @@
package mage.cards.r;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.BecomesTappedAttachedTriggeredAbility;
import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.counter.AddCountersControllerEffect;
import mage.abilities.effects.common.counter.AddPoisonCounterAllEffect;
import mage.abilities.effects.common.counter.AddCountersPlayersEffect;
import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.target.TargetPermanent;
import mage.target.common.TargetArtifactPermanent;
import java.util.UUID;
/**
* @author nantuko
*/
@ -34,10 +33,9 @@ public final class RelicPutrescence extends CardImpl {
this.addAbility(ability);
// Whenever enchanted artifact becomes tapped, its controller gets a poison counter.
this.addAbility(new BecomesTappedAttachedTriggeredAbility(
new AddPoisonCounterAllEffect(TargetController.CONTROLLER_ATTACHED_TO),
"enchanted artifact"
));
this.addAbility(new BecomesTappedAttachedTriggeredAbility(new AddCountersPlayersEffect(
CounterType.POISON.createInstance(), TargetController.CONTROLLER_ATTACHED_TO
), "enchanted artifact"));
}
public RelicPutrescence(final RelicPutrescence card) {

View file

@ -1,50 +0,0 @@
package mage.abilities.effects.common.counter;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.counters.Counter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.UUID;
/**
* @author nantuko
*/
public class AddCountersControllerEffect extends OneShotEffect {
private Counter counter;
/**
* @param counter Counter to add. Includes type and amount.
*/
public AddCountersControllerEffect(Counter counter) {
super(Outcome.Benefit);
this.counter = counter.copy();
staticText = "you get" + counter.getDescription();
}
public AddCountersControllerEffect(final AddCountersControllerEffect effect) {
super(effect);
if (effect.counter != null) {
this.counter = effect.counter.copy();
}
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
player.addCounters(counter, source.getControllerId(), source, game);
return true;
}
return false;
}
@Override
public AddCountersControllerEffect copy() {
return new AddCountersControllerEffect(this);
}
}

View file

@ -1,46 +1,40 @@
package mage.abilities.effects.common.counter;
import mage.abilities.Ability;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.counters.CounterType;
import mage.counters.Counter;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
import java.util.*;
/**
* @author TheElk801
*/
public class AddPoisonCounterAllEffect extends OneShotEffect {
public class AddCountersPlayersEffect extends OneShotEffect {
private final int amount;
private final Counter counter;
private final TargetController targetController;
public AddPoisonCounterAllEffect(TargetController targetController) {
this(1, targetController);
}
public AddPoisonCounterAllEffect(int amount, TargetController targetController) {
public AddCountersPlayersEffect(Counter counter, TargetController targetController) {
super(Outcome.Benefit);
this.amount = amount;
this.counter = counter;
this.targetController = targetController;
staticText = makeText();
}
private AddPoisonCounterAllEffect(final AddPoisonCounterAllEffect effect) {
private AddCountersPlayersEffect(final AddCountersPlayersEffect effect) {
super(effect);
this.amount = effect.amount;
this.counter = effect.counter;
this.targetController = effect.targetController;
}
@Override
public AddPoisonCounterAllEffect copy() {
return new AddPoisonCounterAllEffect(this);
public AddCountersPlayersEffect copy() {
return new AddCountersPlayersEffect(this);
}
private Collection<UUID> getPlayers(Game game, Ability source) {
@ -71,7 +65,7 @@ public class AddPoisonCounterAllEffect extends OneShotEffect {
for (UUID playerId : getPlayers(game, source)) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.addCounters(CounterType.POISON.createInstance(amount), source.getControllerId(), source, game);
player.addCounters(counter, source.getControllerId(), source, game);
}
}
return true;
@ -96,10 +90,8 @@ public class AddPoisonCounterAllEffect extends OneShotEffect {
default:
throw new UnsupportedOperationException(targetController + " not supported");
}
sb.append(' ' + CardUtil.numberToText(amount, "a") + " poison counter");
if (amount > 1) {
sb.append('s');
}
sb.append(' ');
sb.append(counter.getDescription());
return sb.toString();
}
}