diff --git a/Mage.Sets/src/mage/cards/i/IngeniousArtillerist.java b/Mage.Sets/src/mage/cards/i/IngeniousArtillerist.java new file mode 100644 index 00000000000..cef253dd440 --- /dev/null +++ b/Mage.Sets/src/mage/cards/i/IngeniousArtillerist.java @@ -0,0 +1,95 @@ +package mage.cards.i; + +import mage.MageInt; +import mage.MageItem; +import mage.abilities.TriggeredAbilityImpl; +import mage.abilities.dynamicvalue.common.SavedDamageValue; +import mage.abilities.effects.common.DamagePlayersEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.*; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.events.ZoneChangeGroupEvent; + +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Stream; + +/** + * @author TheElk801 + */ +public final class IngeniousArtillerist extends CardImpl { + + public IngeniousArtillerist(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}"); + + this.subtype.add(SubType.HUMAN); + this.subtype.add(SubType.ARTIFICER); + this.power = new MageInt(3); + this.toughness = new MageInt(1); + + // Whenever one or more artifacts enter the battlefield under you control, Ingenious Artillerist deals that much damage to each opponent. + this.addAbility(new IngeniousArtilleristTriggeredAbility()); + } + + private IngeniousArtillerist(final IngeniousArtillerist card) { + super(card); + } + + @Override + public IngeniousArtillerist copy() { + return new IngeniousArtillerist(this); + } +} + +class IngeniousArtilleristTriggeredAbility extends TriggeredAbilityImpl { + + IngeniousArtilleristTriggeredAbility() { + super(Zone.BATTLEFIELD, new DamagePlayersEffect( + Outcome.Benefit, SavedDamageValue.MANY, TargetController.OPPONENT + ), false); + } + + private IngeniousArtilleristTriggeredAbility(final IngeniousArtilleristTriggeredAbility ability) { + super(ability); + } + + @Override + public boolean checkEventType(GameEvent event, Game game) { + return event.getType() == GameEvent.EventType.ZONE_CHANGE_GROUP; + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + ZoneChangeGroupEvent zEvent = (ZoneChangeGroupEvent) event; + if (zEvent.getToZone() != Zone.BATTLEFIELD) { + return false; + } + int artifacts = Stream.concat( + zEvent.getTokens() + .stream(), + zEvent.getCards() + .stream() + .map(MageItem::getId) + .map(game::getPermanent) + .filter(Objects::nonNull) + ).filter(permanent -> permanent.isArtifact(game)).mapToInt(x -> 1).sum(); + if (artifacts > 0) { + this.getEffects().setValue("damage", artifacts); + return true; + } + return false; + } + + @Override + public IngeniousArtilleristTriggeredAbility copy() { + return new IngeniousArtilleristTriggeredAbility(this); + } + + @Override + public String getRule() { + return "Whenever one or more artifacts enter the battlefield under your control, " + + "{this} deals that much damage to each opponent."; + } +} diff --git a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java index af2040c5308..19bb5b58f1b 100644 --- a/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java +++ b/Mage.Sets/src/mage/sets/CommanderLegendsBattleForBaldursGate.java @@ -171,6 +171,7 @@ public final class CommanderLegendsBattleForBaldursGate extends ExpansionSet { cards.add(new SetCardInfo("Horn of Valhalla", 26, Rarity.RARE, mage.cards.h.HornOfValhalla.class)); cards.add(new SetCardInfo("Icewind Stalwart", 27, Rarity.COMMON, mage.cards.i.IcewindStalwart.class)); cards.add(new SetCardInfo("Imoen, Mystic Trickster", 77, Rarity.UNCOMMON, mage.cards.i.ImoenMysticTrickster.class)); + cards.add(new SetCardInfo("Ingenious Artillerist", 182, Rarity.COMMON, mage.cards.i.IngeniousArtillerist.class)); cards.add(new SetCardInfo("Inspired Tinkering", 183, Rarity.UNCOMMON, mage.cards.i.InspiredTinkering.class)); cards.add(new SetCardInfo("Inspiring Leader", 28, Rarity.UNCOMMON, mage.cards.i.InspiringLeader.class)); cards.add(new SetCardInfo("Insufferable Balladeer", 184, Rarity.COMMON, mage.cards.i.InsufferableBalladeer.class));