diff --git a/Mage.Sets/src/mage/cards/b/BecomeThePilot.java b/Mage.Sets/src/mage/cards/b/BecomeThePilot.java new file mode 100644 index 00000000000..314f35ebabf --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/BecomeThePilot.java @@ -0,0 +1,102 @@ +package mage.cards.b; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalRestrictionEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.combat.CantBeBlockedAttachedEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.abilities.effects.common.continuous.ControlEnchantedEffect; +import mage.abilities.hint.ConditionHint; +import mage.abilities.hint.Hint; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.CommanderPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class BecomeThePilot extends CardImpl { + + private static final FilterPermanent filter = new FilterCreaturePermanent("noncommander creature"); + + static { + filter.add(Predicates.not(CommanderPredicate.instance)); + } + + public BecomeThePilot(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}"); + + this.subtype.add(SubType.AURA); + + // Enchant noncommander creature + TargetPermanent auraTarget = new TargetPermanent(filter); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.addAbility(new EnchantAbility(auraTarget)); + + // You control enchanted creature. + this.addAbility(new SimpleStaticAbility(new ControlEnchantedEffect())); + + // Enchanted creature gets +2/+2 and can't be blocked unless it's attacking its owner or a permanent its owner controls. + Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(2, 2)); + ability.addEffect(new ConditionalRestrictionEffect( + new CantBeBlockedAttachedEffect(AttachmentType.AURA), BecomeThePilotCondition.instance, + "and can't be blocked unless it's attacking its owner or a permanent its owner controls" + )); + this.addAbility(ability.addHint(BecomeThePilotCondition.getHint())); + } + + private BecomeThePilot(final BecomeThePilot card) { + super(card); + } + + @Override + public BecomeThePilot copy() { + return new BecomeThePilot(this); + } +} + +enum BecomeThePilotCondition implements Condition { + instance; + private static final Hint hint = new ConditionHint( + instance, "Enchanted creature is not " + + "attacking its owner or a permanent its owner controls" + ); + + public static Hint getHint() { + return hint; + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent permanent = Optional + .ofNullable(source.getSourcePermanentIfItStillExists(game)) + .filter(Objects::nonNull) + .map(Permanent::getAttachedTo) + .map(game::getPermanent) + .orElse(null); + if (permanent == null) { + return false; + } + UUID defenderId = game.getCombat().getDefenderId(permanent.getId()); + return defenderId == null + || (!permanent.isOwnedBy(defenderId) && !permanent.isOwnedBy(game.getControllerId(defenderId))); + } +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/DoctorWho.java b/Mage.Sets/src/mage/sets/DoctorWho.java index de0bb19d805..5125eb0795f 100644 --- a/Mage.Sets/src/mage/sets/DoctorWho.java +++ b/Mage.Sets/src/mage/sets/DoctorWho.java @@ -29,6 +29,7 @@ public final class DoctorWho extends ExpansionSet { cards.add(new SetCardInfo("Atraxi Warden", 12, Rarity.UNCOMMON, mage.cards.a.AtraxiWarden.class)); cards.add(new SetCardInfo("Banish to Another Universe", 13, Rarity.UNCOMMON, mage.cards.b.BanishToAnotherUniverse.class)); cards.add(new SetCardInfo("Beast Within", 228, Rarity.UNCOMMON, mage.cards.b.BeastWithin.class)); + cards.add(new SetCardInfo("Become the Pilot", 37, Rarity.RARE, mage.cards.b.BecomeThePilot.class)); cards.add(new SetCardInfo("Bessie, the Doctor's Roadster", 171, Rarity.RARE, mage.cards.b.BessieTheDoctorsRoadster.class)); cards.add(new SetCardInfo("Blasphemous Act", 224, Rarity.RARE, mage.cards.b.BlasphemousAct.class)); cards.add(new SetCardInfo("Canopy Vista", 258, Rarity.RARE, mage.cards.c.CanopyVista.class));