From 91faa1a4de216c7df18e5496bc559d2fabdf7f11 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 3 Nov 2022 20:35:01 -0400 Subject: [PATCH] [BRO] Implement Mishra's Domination --- .../src/mage/cards/m/MishrasDomination.java | 83 +++++++++++++++++++ Mage.Sets/src/mage/sets/TheBrothersWar.java | 1 + 2 files changed, 84 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/m/MishrasDomination.java diff --git a/Mage.Sets/src/mage/cards/m/MishrasDomination.java b/Mage.Sets/src/mage/cards/m/MishrasDomination.java new file mode 100644 index 0000000000..1cdd06465a --- /dev/null +++ b/Mage.Sets/src/mage/cards/m/MishrasDomination.java @@ -0,0 +1,83 @@ +package mage.cards.m; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.decorator.ConditionalContinuousEffect; +import mage.abilities.decorator.ConditionalRestrictionEffect; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.combat.CantBlockSourceEffect; +import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.abilities.keyword.EnchantAbility; +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.Controllable; +import mage.game.Game; +import mage.target.TargetPermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.Objects; +import java.util.Optional; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class MishrasDomination extends CardImpl { + + public MishrasDomination(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{R}"); + + this.subtype.add(SubType.AURA); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.addAbility(new EnchantAbility(auraTarget)); + + // As long as you control enchanted creature, it gets +2/+2. Otherwise, it can't block. + Ability ability = new SimpleStaticAbility(new ConditionalContinuousEffect( + new BoostEnchantedEffect(2, 2), MishrasDominationCondition.TRUE, + "as long as you control enchanted creature, it gets +2/+2" + )); + ability.addEffect(new ConditionalRestrictionEffect( + new CantBlockSourceEffect(Duration.WhileOnBattlefield), + MishrasDominationCondition.FALSE, "otherwise, it can't block" + )); + this.addAbility(ability); + } + + private MishrasDomination(final MishrasDomination card) { + super(card); + } + + @Override + public MishrasDomination copy() { + return new MishrasDomination(this); + } +} + +enum MishrasDominationCondition implements Condition { + TRUE(true), + FALSE(false); + private final boolean value; + + MishrasDominationCondition(boolean value) { + this.value = value; + } + + @Override + public boolean apply(Game game, Ability source) { + return Optional + .ofNullable(source.getSourcePermanentIfItStillExists(game)) + .filter(Objects::nonNull) + .map(Controllable::getControllerId) + .map(source::isControlledBy) + .equals(value); + } +} diff --git a/Mage.Sets/src/mage/sets/TheBrothersWar.java b/Mage.Sets/src/mage/sets/TheBrothersWar.java index dd48110df9..f2ee0c072d 100644 --- a/Mage.Sets/src/mage/sets/TheBrothersWar.java +++ b/Mage.Sets/src/mage/sets/TheBrothersWar.java @@ -101,6 +101,7 @@ public final class TheBrothersWar extends ExpansionSet { cards.add(new SetCardInfo("Mass Production", 15, Rarity.UNCOMMON, mage.cards.m.MassProduction.class)); cards.add(new SetCardInfo("Mine Worker", 239, Rarity.COMMON, mage.cards.m.MineWorker.class)); cards.add(new SetCardInfo("Mishra's Command", 141, Rarity.RARE, mage.cards.m.MishrasCommand.class)); + cards.add(new SetCardInfo("Mishra's Domination", 142, Rarity.COMMON, mage.cards.m.MishrasDomination.class)); cards.add(new SetCardInfo("Mishra's Foundry", 265, Rarity.RARE, mage.cards.m.MishrasFoundry.class)); cards.add(new SetCardInfo("Mishra's Juggernaut", 161, Rarity.COMMON, mage.cards.m.MishrasJuggernaut.class)); cards.add(new SetCardInfo("Mishra's Onslaught", 143, Rarity.COMMON, mage.cards.m.MishrasOnslaught.class));