diff --git a/Mage.Sets/src/mage/cards/l/LivioOathswornSentinel.java b/Mage.Sets/src/mage/cards/l/LivioOathswornSentinel.java new file mode 100644 index 0000000000..f09e409f14 --- /dev/null +++ b/Mage.Sets/src/mage/cards/l/LivioOathswornSentinel.java @@ -0,0 +1,146 @@ +package mage.cards.l; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.PartnerAbility; +import mage.cards.Card; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.AnotherPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class LivioOathswornSentinel extends CardImpl { + + private static final FilterPermanent filter = new FilterCreaturePermanent("another creature"); + + static { + filter.add(AnotherPredicate.instance); + } + + public LivioOathswornSentinel(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}"); + + this.addSuperType(SuperType.LEGENDARY); + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.KNIGHT); + this.power = new MageInt(2); + this.toughness = new MageInt(2); + + // {1}{W}: Choose another target creature. Its controller may exile it with an aegis counter on it. + Ability ability = new SimpleActivatedAbility( + new LivioOathswornSentinelExileEffect(), new ManaCostsImpl("{1}{W}") + ); + ability.addTarget(new TargetPermanent(filter)); + this.addAbility(ability); + + // {2}{W}, {T}: Return all exiled cards with aegis counters on them to the battlefield under their owners' control. + ability = new SimpleActivatedAbility(new LivioOathswornSentinelReturnEffect(), new ManaCostsImpl("{2}{W}")); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + + // Partner + this.addAbility(PartnerAbility.getInstance()); + } + + private LivioOathswornSentinel(final LivioOathswornSentinel card) { + super(card); + } + + @Override + public LivioOathswornSentinel copy() { + return new LivioOathswornSentinel(this); + } +} + +class LivioOathswornSentinelExileEffect extends OneShotEffect { + + LivioOathswornSentinelExileEffect() { + super(Outcome.Exile); + staticText = "choose another target creature. Its controller may exile it with an aegis counter on it"; + } + + private LivioOathswornSentinelExileEffect(final LivioOathswornSentinelExileEffect effect) { + super(effect); + } + + @Override + public LivioOathswornSentinelExileEffect copy() { + return new LivioOathswornSentinelExileEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = game.getPermanent(source.getFirstTarget()); + if (permanent == null) { + return false; + } + Player player = game.getPlayer(permanent.getControllerId()); + if (player == null || !player.chooseUse( + outcome, "Exile " + permanent.getName() + " with an aegis counter on it?", source, game + )) { + return false; + } + Card card = game.getCard(permanent.getId()); + player.moveCards(permanent, Zone.EXILED, source, game); + if (card == null || game.getState().getZone(card.getId()) != Zone.EXILED) { + return false; + } + card.addCounters(CounterType.AEGIS.createInstance(), source, game); + return true; + } +} + +class LivioOathswornSentinelReturnEffect extends OneShotEffect { + + LivioOathswornSentinelReturnEffect() { + super(Outcome.Benefit); + staticText = "return all exiled cards with aegis counters on them to the battlefield under their owners' control"; + } + + private LivioOathswornSentinelReturnEffect(final LivioOathswornSentinelReturnEffect effect) { + super(effect); + } + + @Override + public LivioOathswornSentinelReturnEffect copy() { + return new LivioOathswornSentinelReturnEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Set cards = game + .getExile() + .getAllCards(game) + .stream() + .filter(Objects::nonNull) + .filter(card -> card.getCounters(game).containsKey(CounterType.AEGIS)) + .collect(Collectors.toSet()); + return player.moveCards( + cards, Zone.BATTLEFIELD, source, game, false, + false, true, null + ); + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegends.java b/Mage.Sets/src/mage/sets/CommanderLegends.java index 1e55c235ae..9376473f30 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegends.java +++ b/Mage.Sets/src/mage/sets/CommanderLegends.java @@ -91,6 +91,7 @@ public final class CommanderLegends extends ExpansionSet { cards.add(new SetCardInfo("Kor Cartographer", 30, Rarity.COMMON, mage.cards.k.KorCartographer.class)); cards.add(new SetCardInfo("Krark, the Thumbless", 189, Rarity.RARE, mage.cards.k.KrarkTheThumbless.class)); cards.add(new SetCardInfo("Kydele, Chosen of Kruphix", 524, Rarity.MYTHIC, mage.cards.k.KydeleChosenOfKruphix.class)); + cards.add(new SetCardInfo("Livio, Oathsworn Sentinel", 31, Rarity.RARE, mage.cards.l.LivioOathswornSentinel.class)); cards.add(new SetCardInfo("Ludevic, Necro-Alchemist", 525, Rarity.MYTHIC, mage.cards.l.LudevicNecroAlchemist.class)); cards.add(new SetCardInfo("Maelstrom Colossus", 322, Rarity.COMMON, mage.cards.m.MaelstromColossus.class)); cards.add(new SetCardInfo("Maelstrom Wanderer", 526, Rarity.MYTHIC, mage.cards.m.MaelstromWanderer.class)); diff --git a/Mage/src/main/java/mage/counters/CounterType.java b/Mage/src/main/java/mage/counters/CounterType.java index 9492c1d1eb..93c9c57164 100644 --- a/Mage/src/main/java/mage/counters/CounterType.java +++ b/Mage/src/main/java/mage/counters/CounterType.java @@ -12,6 +12,7 @@ import mage.game.Game; */ public enum CounterType { + AEGIS("aegis"), AGE("age"), AIM("aim"), ARROW("arrow"),