diff --git a/Mage.Sets/src/mage/cards/r/RaphaelTagTeamTough.java b/Mage.Sets/src/mage/cards/r/RaphaelTagTeamTough.java new file mode 100644 index 00000000000..92e837b15af --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RaphaelTagTeamTough.java @@ -0,0 +1,116 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.MageObjectReference; +import mage.abilities.Ability; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.effects.common.AdditionalCombatPhaseEffect; +import mage.abilities.effects.common.UntapAllEffect; +import mage.abilities.keyword.MenaceAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.events.DamagedPlayerEvent; +import mage.game.events.GameEvent; +import mage.watchers.Watcher; + +import java.util.HashMap; +import java.util.Map; +import java.util.Objects; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class RaphaelTagTeamTough extends CardImpl { + + public RaphaelTagTeamTough(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}"); + + this.supertype.add(SuperType.LEGENDARY); + this.subtype.add(SubType.MUTANT); + this.subtype.add(SubType.NINJA); + this.subtype.add(SubType.TURTLE); + this.power = new MageInt(5); + this.toughness = new MageInt(6); + + // Menace + this.addAbility(new MenaceAbility()); + + // Whenever Raphael deals combat damage to a player for the first time each turn, untap all attacking creatures. After this combat phase, there is an additional combat phase. + this.addAbility(new RaphaelTagTeamToughTriggeredAbility()); + } + + private RaphaelTagTeamTough(final RaphaelTagTeamTough card) { + super(card); + } + + @Override + public RaphaelTagTeamTough copy() { + return new RaphaelTagTeamTough(this); + } +} + +class RaphaelTagTeamToughTriggeredAbility extends TriggeredAbilityImpl { + + RaphaelTagTeamToughTriggeredAbility() { + super(Zone.BATTLEFIELD, new UntapAllEffect(StaticFilters.FILTER_ATTACKING_CREATURES)); + this.addEffect(new AdditionalCombatPhaseEffect().setText("After this combat phase, there is an additional combat phase")); + this.setTriggerPhrase("Whenever {this} deals combat damage to a player for the first time each turn, "); + this.addWatcher(new RaphaelTagTeamToughWatcher()); + } + + private RaphaelTagTeamToughTriggeredAbility(final RaphaelTagTeamToughTriggeredAbility ability) { + super(ability); + } + + @Override + public RaphaelTagTeamToughTriggeredAbility copy() { + return new RaphaelTagTeamToughTriggeredAbility(this); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.DAMAGED_PLAYER; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + return RaphaelTagTeamToughWatcher.checkEvent(event, this, game); + } +} + +class RaphaelTagTeamToughWatcher extends Watcher { + + private final Map map = new HashMap<>(); + + RaphaelTagTeamToughWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + if (event.getType() == GameEvent.EventType.DAMAGED_PLAYER + && ((DamagedPlayerEvent) event).isCombatDamage()) { + map.putIfAbsent(new MageObjectReference(event.getSourceId(), game), event.getId()); + } + } + + @Override + public void reset() { + super.reset(); + map.clear(); + } + + static boolean checkEvent(GameEvent event, Ability source, Game game) { + return Objects.equals( + event.getId(), + game.getState() + .getWatcher(RaphaelTagTeamToughWatcher.class) + .map + .get(new MageObjectReference(source.getSourceId(), game)) + ); + } +} diff --git a/Mage.Sets/src/mage/sets/TeenageMutantNinjaTurtlesEternal.java b/Mage.Sets/src/mage/sets/TeenageMutantNinjaTurtlesEternal.java index 8cf1cab7b4b..e1cc6eae17e 100644 --- a/Mage.Sets/src/mage/sets/TeenageMutantNinjaTurtlesEternal.java +++ b/Mage.Sets/src/mage/sets/TeenageMutantNinjaTurtlesEternal.java @@ -28,6 +28,7 @@ public final class TeenageMutantNinjaTurtlesEternal extends ExpansionSet { cards.add(new SetCardInfo("Leonardo, the Balance", 1, Rarity.MYTHIC, mage.cards.l.LeonardoTheBalance.class)); cards.add(new SetCardInfo("Michelangelo, On the Scene", 124, Rarity.MYTHIC, mage.cards.m.MichelangeloOnTheScene.class)); cards.add(new SetCardInfo("Michelangelo, the Heart", 5, Rarity.MYTHIC, mage.cards.m.MichelangeloTheHeart.class)); + cards.add(new SetCardInfo("Raphael, Tag Team Tough", 118, Rarity.MYTHIC, mage.cards.r.RaphaelTagTeamTough.class)); cards.add(new SetCardInfo("Raphael, the Muscle", 4, Rarity.MYTHIC, mage.cards.r.RaphaelTheMuscle.class)); cards.add(new SetCardInfo("Splinter, the Mentor", 3, Rarity.MYTHIC, mage.cards.s.SplinterTheMentor.class)); } diff --git a/Mage/src/main/java/mage/abilities/effects/common/AdditionalCombatPhaseEffect.java b/Mage/src/main/java/mage/abilities/effects/common/AdditionalCombatPhaseEffect.java index 273fcbe3cff..0ac46edfd12 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/AdditionalCombatPhaseEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/AdditionalCombatPhaseEffect.java @@ -13,9 +13,7 @@ public class AdditionalCombatPhaseEffect extends OneShotEffect { private final int additionalPhases; public AdditionalCombatPhaseEffect() { - super(Outcome.Benefit); - this.additionalPhases = 1; - staticText = "after this phase, there is an additional combat phase"; + this(1); } public AdditionalCombatPhaseEffect(int additionalPhases) { @@ -23,13 +21,11 @@ public class AdditionalCombatPhaseEffect extends OneShotEffect { if (additionalPhases < 1) { throw new IllegalArgumentException("Number of additional phases must be at least 1"); } - if (additionalPhases == 1) { - this.additionalPhases = 1; - staticText = "after this phase, there is an additional combat phase"; - } else { - this.additionalPhases = additionalPhases; - staticText = "after this phase, there are " + additionalPhases + " additional combat phases"; - } + this.additionalPhases = additionalPhases; + staticText = "after this phase, there " + + (additionalPhases > 1 ? "are " + additionalPhases : "is an") + + " additional combat phase" + + (additionalPhases > 1 ? "s" : ""); } protected AdditionalCombatPhaseEffect(final AdditionalCombatPhaseEffect effect) {