diff --git a/Mage.Sets/src/mage/cards/f/FrayingLine.java b/Mage.Sets/src/mage/cards/f/FrayingLine.java new file mode 100644 index 00000000000..ec9f66253a0 --- /dev/null +++ b/Mage.Sets/src/mage/cards/f/FrayingLine.java @@ -0,0 +1,122 @@ +package mage.cards.f; + +import mage.abilities.Ability; +import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.costs.Cost; +import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.cards.Cards; +import mage.cards.CardsImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; +import mage.target.common.TargetControlledCreaturePermanent; + +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class FrayingLine extends CardImpl { + + public FrayingLine(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}"); + + // When Fraying Line enters the battlefield, put a rope counter on target creature you control. + Ability ability = new EntersBattlefieldTriggeredAbility( + new AddCountersTargetEffect(CounterType.ROPE.createInstance()) + ); + ability.addTarget(new TargetControlledCreaturePermanent()); + this.addAbility(ability); + + // At the beginning of each player's upkeep, that player may pay {2}. If they do, they put a rope counter on a creature they control. Otherwise, exile Fraying Line and each creature without a rope counter on it, then remove all rope counters from all creatures. + this.addAbility(new BeginningOfUpkeepTriggeredAbility( + new FrayingLineEffect(), TargetController.ACTIVE, true + )); + } + + private FrayingLine(final FrayingLine card) { + super(card); + } + + @Override + public FrayingLine copy() { + return new FrayingLine(this); + } +} + +class FrayingLineEffect extends OneShotEffect { + + private static final FilterPermanent filter = new FilterCreaturePermanent(); + + static { + filter.add(Predicates.not(CounterType.ROPE.getPredicate())); + } + + FrayingLineEffect() { + super(Outcome.Benefit); + staticText = "that player may pay {2}. If they do, they put a rope counter on a creature they control. " + + "Otherwise, exile {this} and each creature without a rope counter on it, " + + "then remove all rope counters from all creatures"; + } + + private FrayingLineEffect(final FrayingLineEffect effect) { + super(effect); + } + + @Override + public FrayingLineEffect copy() { + return new FrayingLineEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(game.getActivePlayerId()); + if (player == null) { + return false; + } + Cost cost = new GenericManaCost(2); + if (cost.canPay(source, source, player.getId(), game) + && player.chooseUse(outcome, "Pay {2}?", source, game) + && cost.pay(source, game, source, player.getId(), false)) { + if (!game.getBattlefield().contains(StaticFilters.FILTER_CONTROLLED_CREATURE, source, game, 1)) { + return true; + } + TargetPermanent target = new TargetControlledCreaturePermanent(); + target.setNotTarget(true); + player.choose(outcome, target, source, game); + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + permanent.addCounters(CounterType.ROPE.createInstance(), player.getId(), source, game); + } + return true; + } + Cards cards = new CardsImpl(source.getSourcePermanentIfItStillExists(game)); + cards.addAll(game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source, game)); + player.moveCards(cards, Zone.EXILED, source, game); + for (Permanent permanent : game.getBattlefield().getActivePermanents( + StaticFilters.FILTER_PERMANENT_CREATURE, + source.getControllerId(), source, game + )) { + int counters = permanent.getCounters(game).getCount(CounterType.ROPE); + if (counters > 0) { + permanent.removeCounters(CounterType.ROPE.createInstance(counters), source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index 4ef5bcc63f8..cbb6f121b6b 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -233,6 +233,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Forest", 467, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); cards.add(new SetCardInfo("Forgotten Creation", 721, Rarity.RARE, mage.cards.f.ForgottenCreation.class)); cards.add(new SetCardInfo("Fractured Sanity", 722, Rarity.RARE, mage.cards.f.FracturedSanity.class)); + cards.add(new SetCardInfo("Fraying Line", 314, Rarity.RARE, mage.cards.f.FrayingLine.class)); cards.add(new SetCardInfo("Frontline Medic", 693, Rarity.RARE, mage.cards.f.FrontlineMedic.class)); cards.add(new SetCardInfo("Galepowder Mage", 694, Rarity.RARE, mage.cards.g.GalepowderMage.class)); cards.add(new SetCardInfo("Game Trail", 894, Rarity.RARE, mage.cards.g.GameTrail.class)); diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index 860ae153df8..32ed2e9d7a0 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -151,6 +151,7 @@ public enum CounterType { REACH("reach"), REPAIR("repair"), RITUAL("ritual"), + ROPE("rope"), RUST("rust"), QUEST("quest"), SILVER("silver"),