diff --git a/Mage.Sets/src/mage/cards/h/HotPursuit.java b/Mage.Sets/src/mage/cards/h/HotPursuit.java new file mode 100644 index 00000000000..33e8df8c392 --- /dev/null +++ b/Mage.Sets/src/mage/cards/h/HotPursuit.java @@ -0,0 +1,111 @@ +package mage.cards.h; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfCombatTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalInterveningIfTriggeredAbility; +import mage.abilities.effects.common.SuspectTargetEffect; +import mage.abilities.effects.common.combat.GoadTargetEffect; +import mage.abilities.effects.common.continuous.GainControlAllUntapGainHasteEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.TargetController; +import mage.constants.WatcherScope; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.GoadedPredicate; +import mage.filter.predicate.permanent.SuspectedPredicate; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.target.common.TargetOpponentsCreaturePermanent; +import mage.watchers.Watcher; + +import java.util.HashSet; +import java.util.Set; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class HotPursuit extends CardImpl { + + private static final FilterPermanent filter = new FilterCreaturePermanent("goaded and/or suspected creatures"); + + static { + filter.add(Predicates.or( + GoadedPredicate.instance, + SuspectedPredicate.instance + )); + } + + public HotPursuit(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}"); + + // When Hot Pursuit enters the battlefield, suspect target creature an opponent controls. As long as Hot Pursuit remains on the battlefield, that creature is also goaded. + Ability ability = new EntersBattlefieldTriggeredAbility(new SuspectTargetEffect()); + ability.addEffect(new GoadTargetEffect(Duration.UntilSourceLeavesBattlefield) + .setText("as long as {this} remains on the battlefield, that creature is also goaded")); + ability.addTarget(new TargetOpponentsCreaturePermanent()); + this.addAbility(ability); + + // At the beginning of combat on your turn, if two or more players have lost the game, gain control of all goaded and/or suspected creatures until end of turn. Untap them. They gain haste until end of turn. + this.addAbility(new ConditionalInterveningIfTriggeredAbility( + new BeginningOfCombatTriggeredAbility( + new GainControlAllUntapGainHasteEffect(filter), + TargetController.YOU, false + ), HotPursuitCondition.instance, "At the beginning of combat on your turn, " + + "if two or more players have lost the game, gain control of all goaded and/or " + + "suspected creatures until end of turn. Untap them. They gain haste until end of turn." + ), new HotPursuitWatcher()); + } + + private HotPursuit(final HotPursuit card) { + super(card); + } + + @Override + public HotPursuit copy() { + return new HotPursuit(this); + } +} + +enum HotPursuitCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + return HotPursuitWatcher.checkCondition(game); + } +} + +class HotPursuitWatcher extends Watcher { + + private final Set players = new HashSet<>(); + + HotPursuitWatcher() { + super(WatcherScope.GAME); + } + + @Override + public void watch(GameEvent event, Game game) { + switch (event.getType()) { + case BEGINNING_PHASE_PRE: + players.clear(); + return; + case LOST: + players.add(event.getPlayerId()); + } + } + + static boolean checkCondition(Game game) { + return game + .getState() + .getWatcher(HotPursuitWatcher.class) + .players + .size() >= 2; + } +} diff --git a/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java b/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java index b9e201f507f..4694248767f 100644 --- a/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java +++ b/Mage.Sets/src/mage/sets/MurdersAtKarlovManorCommander.java @@ -129,6 +129,7 @@ public final class MurdersAtKarlovManorCommander extends ExpansionSet { cards.add(new SetCardInfo("Hooded Hydra", 171, Rarity.MYTHIC, mage.cards.h.HoodedHydra.class)); cards.add(new SetCardInfo("Hornet Queen", 172, Rarity.RARE, mage.cards.h.HornetQueen.class)); cards.add(new SetCardInfo("Hostile Desert", 266, Rarity.RARE, mage.cards.h.HostileDesert.class)); + cards.add(new SetCardInfo("Hot Pursuit", 32, Rarity.RARE, mage.cards.h.HotPursuit.class)); cards.add(new SetCardInfo("Hydroid Krasis", 212, Rarity.RARE, mage.cards.h.HydroidKrasis.class)); cards.add(new SetCardInfo("Idol of Oblivion", 229, Rarity.RARE, mage.cards.i.IdolOfOblivion.class)); cards.add(new SetCardInfo("Imperial Hellkite", 155, Rarity.RARE, mage.cards.i.ImperialHellkite.class)); diff --git a/Mage/src/main/java/mage/abilities/effects/common/combat/GoadTargetEffect.java b/Mage/src/main/java/mage/abilities/effects/common/combat/GoadTargetEffect.java index a570d04c5d1..dc944f0add3 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/combat/GoadTargetEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/combat/GoadTargetEffect.java @@ -26,7 +26,11 @@ public class GoadTargetEffect extends ContinuousEffectImpl { * each combat if able and attacks a player other than that player if able. */ public GoadTargetEffect() { - super(Duration.UntilYourNextTurn, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment); + this(Duration.UntilYourNextTurn); + } + + public GoadTargetEffect(Duration duration) { + super(duration, Layer.RulesEffects, SubLayer.NA, Outcome.Detriment); } private GoadTargetEffect(final GoadTargetEffect effect) {