diff --git a/Mage.Sets/src/mage/cards/r/RavenousGigantotherium.java b/Mage.Sets/src/mage/cards/r/RavenousGigantotherium.java new file mode 100644 index 0000000000..268f4085c4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RavenousGigantotherium.java @@ -0,0 +1,134 @@ +package mage.cards.r; + +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.common.EntersBattlefieldTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.DamageMultiEffect; +import mage.abilities.effects.common.DevourEffect; +import mage.abilities.keyword.DevourAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.game.events.GameEvent; +import mage.game.permanent.Permanent; +import mage.target.Target; +import mage.target.common.TargetCreaturePermanentAmount; + +import java.util.Collection; +import java.util.List; +import java.util.Objects; +import java.util.UUID; +import java.util.stream.Collectors; + +/** + * @author TheElk801 + */ +public final class RavenousGigantotherium extends CardImpl { + + public RavenousGigantotherium(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{G}{G}"); + + this.subtype.add(SubType.BEAST); + this.power = new MageInt(3); + this.toughness = new MageInt(3); + + // Devour 3 + this.addAbility(new DevourAbility(DevourEffect.DevourFactor.Devour3)); + + // When Ravenous Gigantotherium enters the battlefield, it deals X damage divided as you choose among up to X target creatures, where X is its power. Each of those creatures deals damage equal to its power to Ravenous Gigantotherium. + this.addAbility(new RavenousGigantotheriumAbility()); + } + + private RavenousGigantotherium(final RavenousGigantotherium card) { + super(card); + } + + @Override + public RavenousGigantotherium copy() { + return new RavenousGigantotherium(this); + } +} + +class RavenousGigantotheriumAbility extends EntersBattlefieldTriggeredAbility { + + RavenousGigantotheriumAbility() { + super(null, false); + } + + private RavenousGigantotheriumAbility(final RavenousGigantotheriumAbility ability) { + super(ability); + } + + @Override + public boolean checkTrigger(GameEvent event, Game game) { + if (!super.checkTrigger(event, game)) { + return false; + } + Permanent permanent = game.getPermanentOrLKIBattlefield(event.getTargetId()); + if (permanent == null) { + return false; + } + int power = Math.min(permanent.getPower().getValue(), 0); + this.getEffects().clear(); + this.addEffect(new DamageMultiEffect(power)); + this.addEffect(new RavenousGigantotheriumEffect()); + this.getTargets().clear(); + if (power < 1) { + return true; + } + this.addTarget(new TargetCreaturePermanentAmount(power)); + return true; + } + + @Override + public String getRule() { + return "When {this} enters the battlefield, it deals X damage " + + "divided as you choose among up to X target creatures, where X is its power. " + + "Each of those creatures deals damage equal to its power to {this}."; + } + + @Override + public RavenousGigantotheriumAbility copy() { + return new RavenousGigantotheriumAbility(this); + } +} + +class RavenousGigantotheriumEffect extends OneShotEffect { + + RavenousGigantotheriumEffect() { + super(Outcome.Benefit); + } + + private RavenousGigantotheriumEffect(final RavenousGigantotheriumEffect effect) { + super(effect); + } + + @Override + public RavenousGigantotheriumEffect copy() { + return new RavenousGigantotheriumEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent sourcePerm = game.getPermanent(source.getSourceId()); + if (sourcePerm == null) { + return false; + } + List permanentList = source + .getTargets() + .stream() + .map(Target::getTargets) + .flatMap(Collection::stream) + .map(game::getPermanent) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + for (Permanent permanent : permanentList) { + sourcePerm.damage(permanent.getPower().getValue(), permanent.getId(), game); + } + return true; + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/Commander2020Edition.java b/Mage.Sets/src/mage/sets/Commander2020Edition.java index e2fc80b67f..ac981efe65 100644 --- a/Mage.Sets/src/mage/sets/Commander2020Edition.java +++ b/Mage.Sets/src/mage/sets/Commander2020Edition.java @@ -235,6 +235,7 @@ public final class Commander2020Edition extends ExpansionSet { cards.add(new SetCardInfo("Rakdos Carnarium", 300, Rarity.COMMON, mage.cards.r.RakdosCarnarium.class)); cards.add(new SetCardInfo("Rakdos Signet", 249, Rarity.UNCOMMON, mage.cards.r.RakdosSignet.class)); cards.add(new SetCardInfo("Rashmi, Eternities Crafter", 229, Rarity.MYTHIC, mage.cards.r.RashmiEternitiesCrafter.class)); + cards.add(new SetCardInfo("Ravenous Gigantotherium", 63, Rarity.RARE, mage.cards.r.RavenousGigantotherium.class)); cards.add(new SetCardInfo("Reclamation Sage", 186, Rarity.UNCOMMON, mage.cards.r.ReclamationSage.class)); cards.add(new SetCardInfo("Reliquary Tower", 301, Rarity.UNCOMMON, mage.cards.r.ReliquaryTower.class)); cards.add(new SetCardInfo("Remote Isle", 302, Rarity.COMMON, mage.cards.r.RemoteIsle.class));