From a34747257c1f335afc5c65a13e60d1dcce742f35 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Sun, 10 Apr 2022 21:40:41 -0400 Subject: [PATCH] [SNC] Implemented Exotic Pets --- Mage.Sets/src/mage/cards/e/ExoticPets.java | 123 ++++++++++++++++++ .../src/mage/sets/StreetsOfNewCapenna.java | 1 + .../mage/game/permanent/token/FishToken.java | 31 +++++ Utils/mtg-cards-data.txt | 1 + 4 files changed, 156 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/e/ExoticPets.java create mode 100644 Mage/src/main/java/mage/game/permanent/token/FishToken.java diff --git a/Mage.Sets/src/mage/cards/e/ExoticPets.java b/Mage.Sets/src/mage/cards/e/ExoticPets.java new file mode 100644 index 00000000000..41bf2012dfe --- /dev/null +++ b/Mage.Sets/src/mage/cards/e/ExoticPets.java @@ -0,0 +1,123 @@ +package mage.cards.e; + +import mage.MageItem; +import mage.abilities.Ability; +import mage.abilities.effects.OneShotEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.StaticFilters; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.permanent.PermanentIdPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.permanent.token.FishToken; +import mage.game.permanent.token.Token; +import mage.players.Player; +import mage.target.TargetPermanent; + +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class ExoticPets extends CardImpl { + + public ExoticPets(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{W}{U}"); + + // Create two 1/1 blue Fish creature tokens with "This creature can't be blocked." Then for each kind of counter among creatures you control, put a counter of that kind on either of those tokens. + this.getSpellAbility().addEffect(new ExoticPetsEffect()); + } + + private ExoticPets(final ExoticPets card) { + super(card); + } + + @Override + public ExoticPets copy() { + return new ExoticPets(this); + } +} + +class ExoticPetsEffect extends OneShotEffect { + + ExoticPetsEffect() { + super(Outcome.Benefit); + staticText = "create two 1/1 blue Fish creature tokens with \"This creature can't be blocked.\" " + + "Then for each kind of counter among creatures you control, " + + "put a counter of that kind on either of those tokens"; + } + + private ExoticPetsEffect(final ExoticPetsEffect effect) { + super(effect); + } + + @Override + public ExoticPetsEffect copy() { + return new ExoticPetsEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player player = game.getPlayer(source.getControllerId()); + if (player == null) { + return false; + } + Token token = new FishToken(); + token.putOntoBattlefield(2, game, source); + List permanents = token + .getLastAddedTokenIds() + .stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + if (permanents.isEmpty()) { + return false; + } + Set counterTypes = game + .getBattlefield() + .getActivePermanents( + StaticFilters.FILTER_CONTROLLED_CREATURE, + source.getControllerId(), source, game + ).stream() + .map(permanent -> permanent.getCounters(game)) + .map(HashMap::keySet) + .flatMap(Collection::stream) + .distinct() + .map(CounterType::findByName) + .collect(Collectors.toSet()); + if (counterTypes.isEmpty()) { + return true; + } + if (permanents.size() == 1) { + Permanent permanent = permanents.get(0); + for (CounterType counterType : counterTypes) { + permanent.addCounters(counterType.createInstance(), source, game); + } + return true; + } + FilterPermanent filter = new FilterPermanent("creature"); + filter.add(Predicates.or(permanents + .stream() + .map(MageItem::getId) + .map(PermanentIdPredicate::new) + .collect(Collectors.toSet()))); + TargetPermanent target = new TargetPermanent(filter); + target.setNotTarget(true); + for (CounterType counterType : counterTypes) { + target.clearChosen(); + target.withChooseHint("to add " + counterType.getArticle() + ' ' + counterType + " counter to"); + player.choose(Outcome.BoostCreature, target, source, game); + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + permanent.addCounters(counterType.createInstance(), source, game); + } + } + return true; + } +} diff --git a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java index 5567c73a599..a1080eb5a1f 100644 --- a/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java +++ b/Mage.Sets/src/mage/sets/StreetsOfNewCapenna.java @@ -41,6 +41,7 @@ public final class StreetsOfNewCapenna extends ExpansionSet { cards.add(new SetCardInfo("Disciplined Duelist", 182, Rarity.UNCOMMON, mage.cards.d.DisciplinedDuelist.class)); cards.add(new SetCardInfo("Errant, Street Artist", 41, Rarity.RARE, mage.cards.e.ErrantStreetArtist.class)); cards.add(new SetCardInfo("Evolving Door", 144, Rarity.RARE, mage.cards.e.EvolvingDoor.class)); + cards.add(new SetCardInfo("Exotic Pets", 185, Rarity.UNCOMMON, mage.cards.e.ExoticPets.class)); cards.add(new SetCardInfo("Faerie Vandal", 44, Rarity.UNCOMMON, mage.cards.f.FaerieVandal.class)); cards.add(new SetCardInfo("Fight Rigging", 430, Rarity.RARE, mage.cards.f.FightRigging.class)); cards.add(new SetCardInfo("Forest", 270, Rarity.LAND, mage.cards.basiclands.Forest.class, NON_FULL_USE_VARIOUS)); diff --git a/Mage/src/main/java/mage/game/permanent/token/FishToken.java b/Mage/src/main/java/mage/game/permanent/token/FishToken.java new file mode 100644 index 00000000000..7688aec0972 --- /dev/null +++ b/Mage/src/main/java/mage/game/permanent/token/FishToken.java @@ -0,0 +1,31 @@ +package mage.game.permanent.token; + +import mage.MageInt; +import mage.abilities.keyword.CantBeBlockedSourceAbility; +import mage.constants.CardType; +import mage.constants.SubType; + +/** + * @author TheElk801 + */ +public final class FishToken extends TokenImpl { + + public FishToken() { + super("Fish Token", "1/1 blue Fish creature token with \"This creature can't be blocked.\""); + cardType.add(CardType.CREATURE); + subtype.add(SubType.FISH); + color.setBlue(true); + power = new MageInt(1); + toughness = new MageInt(1); + + addAbility(new CantBeBlockedSourceAbility("this creature can't be blocked")); + } + + public FishToken(final FishToken token) { + super(token); + } + + public FishToken copy() { + return new FishToken(this); + } +} diff --git a/Utils/mtg-cards-data.txt b/Utils/mtg-cards-data.txt index 6cfa0ece71d..f334417cc7b 100644 --- a/Utils/mtg-cards-data.txt +++ b/Utils/mtg-cards-data.txt @@ -43958,6 +43958,7 @@ Cabaretti Charm|Streets of New Capenna|173|U|{R}{G}{W}|Instant|||Choose one —$ Cormela, Glamour Thief|Streets of New Capenna|177|U|{1}{U}{B}{R}|Legendary Creature - Vampire Rogue|2|4|Haste${1}, {T}: Add {U}{B}{R}. Spend this mana only to cast instant and/or sorcery spells.$When Cormela, Glamour Thief dies, return up to one target instant or sorcery card from your graveyard to your hand.| Disciplined Duelist|Streets of New Capenna|182|U|{G}{W}{U}|Creature - Human Citizen|2|1|Double strike$Disciplined Duelist enters the battlefield with a shield counter on it.| Evelyn, the Covetous|Streets of New Capenna|184|R|{2}{U/B}{B}{B/R}|Legendary Creature - Vampire Rogue|2|5|Flash$Whenever Evelyn, the Covetous or another vampire enters the battlefield under your control, exile the top card of each player's library with a collection counter on it.$Once each turn, you may play a card from exile with a collection counter on it if it was exiled by an ability you controlled, and you may spend mana as though it were any color to cast it.| +Exotic Pets|Streets of New Capenna|185|U|{1}{W}{U}|Instant|||Create two 1/1 blue Fish creature tokens with "This creature can't be blocked." Then for each kind of counter among creatures you control, put a counter of that kind on either of those tokens.| Falco Spara, Pactweaver|Streets of New Capenna|186|M|{1}{G}{W}{U}|Legendary Creature - Bird Demon|3|3|Flying, trample$Falco Spara, Pactweaver enters the battlefield with a shield counter on it.$You may look at the top card of your library any time.$You may cast spells from the top of your library by removing a counter from a creature you control in addition to paying their other costs.| Jetmir, Nexus of Revels|Streets of New Capenna|193|M|{1}{R}{G}{W}|Legendary Creature - Cat Demon|5|4|Creatures you control get +1/+0 and have vigilance as long as you control three or more creatures.$Creatures you control also get +1/+0 and have trample as long as you control six or more creatures.$Creatures you control also get +1/+0 and have double strike as long as you control nine or more creatures.| Lord Xander, the Collector|Streets of New Capenna|197|M|{4}{U}{B}{R}|Legendary Creature - Vampire Demon Noble|6|6|When Lord Xander, the Collector enters the battlefield, target opponent discards half the cards in their hand, rounded down.$Whenever Lord Xander attacks, defending player mills half their library, rounded down.$When Lord Xander dies, target opponent sacrifices half the nonland permanents they control, rounded down.|