From f409a72221ff666595db528e857182b6bcae0ea4 Mon Sep 17 00:00:00 2001 From: theelk801 Date: Wed, 5 Apr 2023 09:30:17 -0400 Subject: [PATCH] [MOM] Implement Enduring Bondwarden --- .../src/mage/cards/e/EnduringBondwarden.java | 47 +++++++++++++++++ .../src/mage/cards/p/ParishBladeTrainee.java | 39 +-------------- Mage.Sets/src/mage/cards/s/SpitefulSquad.java | 39 +-------------- Mage.Sets/src/mage/cards/s/StarPupil.java | 39 +-------------- .../src/mage/sets/MarchOfTheMachine.java | 1 + .../PutSourceCountersOnTargetEffect.java | 50 +++++++++++++++++++ 6 files changed, 104 insertions(+), 111 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/e/EnduringBondwarden.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/PutSourceCountersOnTargetEffect.java diff --git a/Mage.Sets/src/mage/cards/e/EnduringBondwarden.java b/Mage.Sets/src/mage/cards/e/EnduringBondwarden.java new file mode 100644 index 0000000000..1808175367 --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/EnduringBondwarden.java @@ -0,0 +1,47 @@ +package mage.cards.e; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.DiesSourceTriggeredAbility; +import mage.abilities.effects.common.PutSourceCountersOnTargetEffect; +import mage.abilities.keyword.BackupAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.SubType; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class EnduringBondwarden extends CardImpl { + + public EnduringBondwarden(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.SCOUT); + this.power = new MageInt(0); + this.toughness = new MageInt(1); + + // Backup 1 + BackupAbility backupAbility = new BackupAbility(this, 1); + this.addAbility(backupAbility); + + // When this creature dies, put its counters on target creature you control. + Ability ability = new DiesSourceTriggeredAbility(new PutSourceCountersOnTargetEffect()).setTriggerPhrase("When this creature dies, "); + ability.addTarget(new TargetControlledCreaturePermanent()); + backupAbility.addAbility(ability); + } + + private EnduringBondwarden(final EnduringBondwarden card) { + super(card); + } + + @Override + public EnduringBondwarden copy() { + return new EnduringBondwarden(this); + } +} diff --git a/Mage.Sets/src/mage/cards/p/ParishBladeTrainee.java b/Mage.Sets/src/mage/cards/p/ParishBladeTrainee.java index 996ecaac37..a9b8528d5d 100644 --- a/Mage.Sets/src/mage/cards/p/ParishBladeTrainee.java +++ b/Mage.Sets/src/mage/cards/p/ParishBladeTrainee.java @@ -3,15 +3,12 @@ package mage.cards.p; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesSourceTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutSourceCountersOnTargetEffect; import mage.abilities.keyword.TrainingAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; import java.util.UUID; @@ -33,7 +30,7 @@ public final class ParishBladeTrainee extends CardImpl { this.addAbility(new TrainingAbility()); // When Parish-Blade Trainee dies, put its counters on target creature you control. - Ability ability = new DiesSourceTriggeredAbility(new ParishBladeTraineeEffect()); + Ability ability = new DiesSourceTriggeredAbility(new PutSourceCountersOnTargetEffect()); ability.addTarget(new TargetControlledCreaturePermanent()); this.addAbility(ability); } @@ -47,35 +44,3 @@ public final class ParishBladeTrainee extends CardImpl { return new ParishBladeTrainee(this); } } - -class ParishBladeTraineeEffect extends OneShotEffect { - - ParishBladeTraineeEffect() { - super(Outcome.Benefit); - staticText = "put its counters on target creature you control"; - } - - private ParishBladeTraineeEffect(final ParishBladeTraineeEffect effect) { - super(effect); - } - - @Override - public ParishBladeTraineeEffect copy() { - return new ParishBladeTraineeEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent sourcePermanent = (Permanent) getValue("permanentLeftBattlefield"); - Permanent permanent = game.getPermanent(source.getFirstTarget()); - if (sourcePermanent == null || permanent == null) { - return false; - } - sourcePermanent - .getCounters(game) - .values() - .stream() - .forEach(counter -> permanent.addCounters(counter, source.getControllerId(), source, game)); - return true; - } -} diff --git a/Mage.Sets/src/mage/cards/s/SpitefulSquad.java b/Mage.Sets/src/mage/cards/s/SpitefulSquad.java index f7b642060a..bc90cfd4ca 100644 --- a/Mage.Sets/src/mage/cards/s/SpitefulSquad.java +++ b/Mage.Sets/src/mage/cards/s/SpitefulSquad.java @@ -4,17 +4,14 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutSourceCountersOnTargetEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.DeathtouchAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; import java.util.UUID; @@ -42,7 +39,7 @@ public final class SpitefulSquad extends CardImpl { )); // When Spiteful Squad dies, put its counters on target creature you control. - Ability ability = new DiesSourceTriggeredAbility(new SpitefulSquadEffect()); + Ability ability = new DiesSourceTriggeredAbility(new PutSourceCountersOnTargetEffect()); ability.addTarget(new TargetControlledCreaturePermanent()); this.addAbility(ability); } @@ -56,35 +53,3 @@ public final class SpitefulSquad extends CardImpl { return new SpitefulSquad(this); } } - -class SpitefulSquadEffect extends OneShotEffect { - - SpitefulSquadEffect() { - super(Outcome.Benefit); - staticText = "put its counters on target creature you control"; - } - - private SpitefulSquadEffect(final SpitefulSquadEffect effect) { - super(effect); - } - - @Override - public SpitefulSquadEffect copy() { - return new SpitefulSquadEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent sourcePermanent = (Permanent) getValue("permanentLeftBattlefield"); - Permanent permanent = game.getPermanent(source.getFirstTarget()); - if (sourcePermanent == null || permanent == null) { - return false; - } - sourcePermanent - .getCounters(game) - .values() - .stream() - .forEach(counter -> permanent.addCounters(counter, source.getControllerId(), source, game)); - return true; - } -} diff --git a/Mage.Sets/src/mage/cards/s/StarPupil.java b/Mage.Sets/src/mage/cards/s/StarPupil.java index 544edcb677..8a7d3c4e85 100644 --- a/Mage.Sets/src/mage/cards/s/StarPupil.java +++ b/Mage.Sets/src/mage/cards/s/StarPupil.java @@ -4,16 +4,13 @@ import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.DiesSourceTriggeredAbility; import mage.abilities.common.EntersBattlefieldAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.PutSourceCountersOnTargetEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.constants.SubType; import mage.counters.CounterType; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; import java.util.UUID; @@ -38,7 +35,7 @@ public final class StarPupil extends CardImpl { )); // When Star Pupil dies, put its counters on target creature you control. - Ability ability = new DiesSourceTriggeredAbility(new StarPupilEffect()); + Ability ability = new DiesSourceTriggeredAbility(new PutSourceCountersOnTargetEffect()); ability.addTarget(new TargetControlledCreaturePermanent()); this.addAbility(ability); } @@ -52,35 +49,3 @@ public final class StarPupil extends CardImpl { return new StarPupil(this); } } - -class StarPupilEffect extends OneShotEffect { - - StarPupilEffect() { - super(Outcome.Benefit); - staticText = "put its counters on target creature you control"; - } - - private StarPupilEffect(final StarPupilEffect effect) { - super(effect); - } - - @Override - public StarPupilEffect copy() { - return new StarPupilEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent sourcePermanent = (Permanent) getValue("permanentLeftBattlefield"); - Permanent permanent = game.getPermanent(source.getFirstTarget()); - if (sourcePermanent == null || permanent == null) { - return false; - } - sourcePermanent - .getCounters(game) - .values() - .stream() - .forEach(counter -> permanent.addCounters(counter, source.getControllerId(), source, game)); - return true; - } -} diff --git a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java index cef20f34ab..eead8a544a 100644 --- a/Mage.Sets/src/mage/sets/MarchOfTheMachine.java +++ b/Mage.Sets/src/mage/sets/MarchOfTheMachine.java @@ -54,6 +54,7 @@ public final class MarchOfTheMachine extends ExpansionSet { cards.add(new SetCardInfo("Dusk Legion Duelist", 11, Rarity.RARE, mage.cards.d.DuskLegionDuelist.class)); cards.add(new SetCardInfo("Elspeth's Smite", 13, Rarity.UNCOMMON, mage.cards.e.ElspethsSmite.class)); cards.add(new SetCardInfo("Elvish Vatkeeper", 223, Rarity.UNCOMMON, mage.cards.e.ElvishVatkeeper.class)); + cards.add(new SetCardInfo("Enduring Bondwarden", 14, Rarity.COMMON, mage.cards.e.EnduringBondwarden.class)); cards.add(new SetCardInfo("Errant and Giada", 224, Rarity.RARE, mage.cards.e.ErrantAndGiada.class)); cards.add(new SetCardInfo("Essence of Orthodoxy", 323, Rarity.RARE, mage.cards.e.EssenceOfOrthodoxy.class)); cards.add(new SetCardInfo("Faerie Mastermind", 58, Rarity.RARE, mage.cards.f.FaerieMastermind.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/PutSourceCountersOnTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/PutSourceCountersOnTargetEffect.java new file mode 100644 index 0000000000..fcde03a8b6 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/PutSourceCountersOnTargetEffect.java @@ -0,0 +1,50 @@ +package mage.abilities.effects.common; + +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * @author TheElk801 + */ +public class PutSourceCountersOnTargetEffect extends OneShotEffect { + + public PutSourceCountersOnTargetEffect() { + super(Outcome.Benefit); + } + + private PutSourceCountersOnTargetEffect(final PutSourceCountersOnTargetEffect effect) { + super(effect); + } + + @Override + public PutSourceCountersOnTargetEffect copy() { + return new PutSourceCountersOnTargetEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sourcePermanent = (Permanent) getValue("permanentLeftBattlefield"); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (sourcePermanent == null || permanent == null) { + return false; + } + sourcePermanent + .getCounters(game) + .values() + .stream() + .forEach(counter -> permanent.addCounters(counter, source.getControllerId(), source, game)); + return true; + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + return "put its counters on target " + mode.getTargets().get(0).getTargetName(); + } +}