From 7188373246be45f3bc54193557875e6f4eb30e00 Mon Sep 17 00:00:00 2001 From: Oleg Agafonov Date: Fri, 24 May 2019 14:52:03 +0400 Subject: [PATCH] [G18] added Angelic Guardian --- .../src/mage/cards/a/AngelicGuardian.java | 88 +++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/a/AngelicGuardian.java diff --git a/Mage.Sets/src/mage/cards/a/AngelicGuardian.java b/Mage.Sets/src/mage/cards/a/AngelicGuardian.java new file mode 100644 index 0000000000..a37e642365 --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AngelicGuardian.java @@ -0,0 +1,88 @@ +package mage.cards.a; + +import mage.MageInt; +import mage.MageObject; +import mage.abilities.Ability; +import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; +import mage.abilities.keyword.FlyingAbility; +import mage.abilities.keyword.IndestructibleAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.game.Game; +import mage.players.Player; +import mage.target.targetpointer.FixedTarget; + +import java.util.Objects; +import java.util.UUID; + +/** + * @author JayDi85 + */ +public final class AngelicGuardian extends CardImpl { + + public AngelicGuardian(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{W}{W}"); + this.subtype.add(SubType.ANGEL); + + this.power = new MageInt(5); + this.toughness = new MageInt(5); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Whenever one or more creatures you control attack, they gain indestructible until end of turn + this.addAbility(new AttacksWithCreaturesTriggeredAbility(new AngelicGuardianGainEffect(), 1)); + } + + public AngelicGuardian(final AngelicGuardian card) { + super(card); + } + + @Override + public AngelicGuardian copy() { + return new AngelicGuardian(this); + } +} + +class AngelicGuardianGainEffect extends OneShotEffect { + + public AngelicGuardianGainEffect() { + super(Outcome.Benefit); + staticText = "they gain indestructible until end of turn"; + } + + public AngelicGuardianGainEffect(final AngelicGuardianGainEffect effect) { + super(effect); + } + + @Override + public AngelicGuardianGainEffect copy() { + return new AngelicGuardianGainEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player you = game.getPlayer(source.getControllerId()); + if (you != null) { + game.getCombat().getAttackers().stream() + .map(game::getPermanent) + .filter(Objects::nonNull) + .filter(permanent -> permanent.isControlledBy(you.getId())) + .filter(MageObject::isCreature) + .forEach(permanent -> { + ContinuousEffect effect = new GainAbilityTargetEffect(IndestructibleAbility.getInstance(), Duration.EndOfTurn); + effect.setTargetPointer(new FixedTarget(permanent, game)); + game.addEffect(effect, source); + }); + return true; + } + return false; + } +}