From ac3789f4805919caa720beeacbb88fec56be469e Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Tue, 26 Apr 2022 21:32:20 -0400 Subject: [PATCH] [NCC] Implemented Aven Courier --- Mage.Sets/src/mage/cards/a/AvenCourier.java | 119 ++++++++++++++++++ .../src/mage/sets/NewCapennaCommander.java | 1 + 2 files changed, 120 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AvenCourier.java diff --git a/Mage.Sets/src/mage/cards/a/AvenCourier.java b/Mage.Sets/src/mage/cards/a/AvenCourier.java new file mode 100644 index 00000000000..559b52d0fdb --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AvenCourier.java @@ -0,0 +1,119 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.AttacksTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.choices.Choice; +import mage.choices.ChoiceImpl; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.counters.CounterType; +import mage.filter.StaticFilters; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; +import mage.target.common.TargetControlledPermanent; +import mage.util.CardUtil; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class AvenCourier extends CardImpl { + + public AvenCourier(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}"); + + this.subtype.add(SubType.BIRD); + this.subtype.add(SubType.ADVISOR); + this.power = new MageInt(1); + this.toughness = new MageInt(1); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever Aven Courier attacks, choose a counter on a permanent you control. Put a counter of that kind on target permanent you control if it doesn't have a counter of that kind on it. + Ability ability = new AttacksTriggeredAbility(new AvenCourierEffect()); + ability.addTarget(new TargetControlledPermanent()); + this.addAbility(ability); + } + + private AvenCourier(final AvenCourier card) { + super(card); + } + + @Override + public AvenCourier copy() { + return new AvenCourier(this); + } +} + +class AvenCourierEffect extends OneShotEffect { + + AvenCourierEffect() { + super(Outcome.Benefit); + staticText = "choose a counter on a permanent you control. Put a counter of that kind " + + "on target permanent you control if it doesn't have a counter of that kind on it"; + } + + private AvenCourierEffect(final AvenCourierEffect effect) { + super(effect); + } + + @Override + public AvenCourierEffect copy() { + return new AvenCourierEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source)); + if (player == null || permanent == null) { + return false; + } + Set counterTypes = game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_PERMANENT, + source.getControllerId(), source, game + ).stream() + .map(p -> p.getCounters(game)) + .map(HashMap::keySet) + .flatMap(Collection::stream) + .distinct() + .collect(Collectors.toSet()); + String counterType; + switch (counterTypes.size()) { + case 0: + return false; + case 1: + counterType = counterTypes.iterator().next(); + break; + case 2: + Iterator iterator = counterTypes.iterator(); + String type1 = iterator.next(); + String type2 = iterator.next(); + counterType = player.chooseUse( + outcome, "Choose a counter to put on " + permanent.getName(), null, + CardUtil.getTextWithFirstCharUpperCase(type1), + CardUtil.getTextWithFirstCharUpperCase(type2), source, game + ) ? type1 : type2; + break; + default: + Choice choice = new ChoiceImpl(true); + choice.setChoices(counterTypes); + player.choose(outcome, choice, game); + counterType = choice.getChoice(); + } + return permanent.getCounters(game).getCount(counterType) < 1 + && permanent.addCounters(CounterType.findByName(counterType).createInstance(), source, game); + } +} diff --git a/Mage.Sets/src/mage/sets/NewCapennaCommander.java b/Mage.Sets/src/mage/sets/NewCapennaCommander.java index 5f3fd585557..85226e82bf2 100644 --- a/Mage.Sets/src/mage/sets/NewCapennaCommander.java +++ b/Mage.Sets/src/mage/sets/NewCapennaCommander.java @@ -36,6 +36,7 @@ public final class NewCapennaCommander extends ExpansionSet { cards.add(new SetCardInfo("Audacious Swap", 44, Rarity.RARE, mage.cards.a.AudaciousSwap.class)); cards.add(new SetCardInfo("Aura Mutation", 328, Rarity.RARE, mage.cards.a.AuraMutation.class)); cards.add(new SetCardInfo("Austere Command", 193, Rarity.RARE, mage.cards.a.AustereCommand.class)); + cards.add(new SetCardInfo("Aven Courier", 22, Rarity.RARE, mage.cards.a.AvenCourier.class)); cards.add(new SetCardInfo("Aven Mimeomancer", 329, Rarity.RARE, mage.cards.a.AvenMimeomancer.class)); cards.add(new SetCardInfo("Avenger of Zendikar", 280, Rarity.MYTHIC, mage.cards.a.AvengerOfZendikar.class)); cards.add(new SetCardInfo("Avenging Huntbonder", 194, Rarity.RARE, mage.cards.a.AvengingHuntbonder.class));