From ce610be087d8f7ba16f4949c1b83c03e95639e8b Mon Sep 17 00:00:00 2001 From: "Alex W. Jackson" Date: Sat, 3 Sep 2022 05:46:59 -0400 Subject: [PATCH] [ONS] Implement Crown of Ascension, Crown of Suspicion and Crown of Vigor --- Mage.Sets/src/mage/cards/c/CrownOfAwe.java | 127 +++++------------- Mage.Sets/src/mage/cards/c/CrownOfFury.java | 95 +++---------- Mage.Sets/src/mage/sets/Onslaught.java | 3 + .../main/java/mage/filter/StaticFilters.java | 8 ++ 4 files changed, 68 insertions(+), 165 deletions(-) diff --git a/Mage.Sets/src/mage/cards/c/CrownOfAwe.java b/Mage.Sets/src/mage/cards/c/CrownOfAwe.java index bdadc29a46..cb8d624ecb 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfAwe.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfAwe.java @@ -1,116 +1,61 @@ package mage.cards.c; -import mage.MageObjectReference; -import mage.abilities.Ability; +import mage.ObjectColor; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.SacrificeSourceCost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.continuous.GainAbilityAllEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; -import mage.cards.Card; +import mage.abilities.keyword.ProtectionAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicate; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.MageObjectReferencePredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.constants.*; +import mage.filter.StaticFilters; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; -import mage.ObjectColor; -import mage.abilities.keyword.ProtectionAbility; -import mage.constants.AttachmentType; -import mage.constants.CardType; -import mage.constants.SubType; -import mage.constants.Duration; -import mage.constants.Outcome; import java.util.UUID; /** - * @author BlueElectivire + * @author awjackson */ public final class CrownOfAwe extends CardImpl { - public CrownOfAwe(UUID ownerId, CardSetInfo setInfo) { - super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + public CrownOfAwe(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{W}"); + this.subtype.add(SubType.AURA); - this.subtype.add(SubType.AURA); + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility)); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); - // Enchant creature - TargetPermanent auraTarget = new TargetCreaturePermanent(); - this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility)); - Ability ability = new EnchantAbility(auraTarget.getTargetName()); - this.addAbility(ability); + // Enchanted creature has protection from black and from red. + this.addAbility(new SimpleStaticAbility(new GainAbilityAttachedEffect( + ProtectionAbility.from(ObjectColor.BLACK, ObjectColor.RED), AttachmentType.AURA + ))); - // Enchanted Creature has protection from black and from red. - ability = new SimpleStaticAbility(new GainAbilityAttachedEffect(ProtectionAbility.from(ObjectColor.BLACK, ObjectColor.RED), - AttachmentType.AURA, Duration.WhileOnBattlefield)); - this.addAbility(ability); + // Sacrifice Crown of Awe: Enchanted creature and other creatures that share a creature type with it + // gain protection from black and from red until end of turn. + this.addAbility(new SimpleActivatedAbility( + new GainAbilityAllEffect( + ProtectionAbility.from(ObjectColor.BLACK, ObjectColor.RED), + Duration.EndOfTurn, + StaticFilters.FILTER_CREATURE_ENCHANTED_AND_SHARE_TYPE + ), + new SacrificeSourceCost() + )); + } - // Sacrifice Crown of Awe: Enchanted creature and other creatures that share a creature type with it gain protection from black and from red until end of turn. - ability = new SimpleActivatedAbility(new CrownOfAweEffect(), new SacrificeSourceCost()); - this.addAbility(ability); - } + private CrownOfAwe(final CrownOfAwe card) { + super(card); + } - private CrownOfAwe(final CrownOfAwe card){ - super(card); - } - - @Override - public CrownOfAwe copy(){ - return new CrownOfAwe(this); - } + @Override + public CrownOfAwe copy() { + return new CrownOfAwe(this); + } } - -class CrownOfAweEffect extends OneShotEffect { - - private static class CrownOfAwePredicate implements Predicate { - private final Card card; - - private CrownOfAwePredicate(Card card){ - this.card = card; - } - - @Override - public boolean apply(Card input, Game game){ - return input.shareCreatureTypes(game, card); - } - } - - public CrownOfAweEffect() { - super(Outcome.Benefit); - this.staticText = "Sacrifice {this}: Enchanted creature and other creatures that share a creature type with it gain protection from black and from red until end of turn."; - } - - public CrownOfAweEffect(final CrownOfAweEffect effect) { - super(effect); - } - - @Override - public CrownOfAweEffect copy() { - return new CrownOfAweEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - // Enchanted creature - ContinuousEffect effect = new GainAbilityAttachedEffect(ProtectionAbility.from(ObjectColor.BLACK, ObjectColor.RED), AttachmentType.AURA, Duration.EndOfTurn); - game.addEffect(effect, source); - - // and other creatures that share a creature type with it - Permanent enchantedCreature = game.getPermanent(source.getSourcePermanentOrLKI(game).getAttachedTo()); - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.add(new CrownOfAwePredicate(enchantedCreature)); - filter.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(enchantedCreature, game)))); - game.addEffect(effect, source); - - // have protection from black and from red until end of turn. - return true; - } -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/c/CrownOfFury.java b/Mage.Sets/src/mage/cards/c/CrownOfFury.java index bc6076f799..102589db7b 100644 --- a/Mage.Sets/src/mage/cards/c/CrownOfFury.java +++ b/Mage.Sets/src/mage/cards/c/CrownOfFury.java @@ -1,37 +1,27 @@ package mage.cards.c; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.common.SacrificeSourceCost; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.Effect; -import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.continuous.BoostAllEffect; import mage.abilities.effects.common.continuous.BoostEnchantedEffect; +import mage.abilities.effects.common.continuous.BoostAllEffect; import mage.abilities.effects.common.continuous.GainAbilityAllEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.FirstStrikeAbility; -import mage.cards.Card; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; -import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.Predicate; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.MageObjectReferencePredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; +import mage.filter.StaticFilters; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; import java.util.UUID; /** - * @author t-schroeder + * @author awjackson */ public final class CrownOfFury extends CardImpl { @@ -39,23 +29,31 @@ public final class CrownOfFury extends CardImpl { 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)); - Ability ability = new EnchantAbility(auraTarget.getTargetName()); - this.addAbility(ability); + this.addAbility(new EnchantAbility(auraTarget.getTargetName())); // Enchanted creature gets +1/+0 and has first strike. - Effect effect = new BoostEnchantedEffect(1, 0, Duration.WhileOnBattlefield); - effect.setText("enchanted creature gets +1/+0"); - ability = new SimpleStaticAbility(Zone.BATTLEFIELD, effect); - effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA); - effect.setText("and has first strike"); - ability.addEffect(effect); + Ability ability = new SimpleStaticAbility(new BoostEnchantedEffect(1, 0)); + ability.addEffect(new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA).setText("and has first strike")); this.addAbility(ability); - // Sacrifice Crown of Fury: Enchanted creature and other creatures that share a creature type with it get +1/+0 and gain first strike until end of turn. - ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new CrownOfFuryEffect(), new SacrificeSourceCost()); + // Sacrifice Crown of Fury: Enchanted creature and other creatures that share a creature type with it + // get +1/+0 and gain first strike until end of turn. + ability = new SimpleActivatedAbility( + new BoostAllEffect(1, 0, Duration.EndOfTurn, StaticFilters.FILTER_CREATURE_ENCHANTED_AND_SHARE_TYPE, false) + .setText("enchanted creature and other creatures that share a creature type with it get +1/+0"), + new SacrificeSourceCost() + ); + ability.addEffect( + new GainAbilityAllEffect( + FirstStrikeAbility.getInstance(), + Duration.EndOfTurn, + StaticFilters.FILTER_CREATURE_ENCHANTED_AND_SHARE_TYPE + ).setText("and gain first strike until end of turn") + ); this.addAbility(ability); } @@ -68,54 +66,3 @@ public final class CrownOfFury extends CardImpl { return new CrownOfFury(this); } } - -class CrownOfFuryEffect extends OneShotEffect { - - private static class CrownOfFuryPredicate implements Predicate { - private final Card card; - - private CrownOfFuryPredicate(Card card) { - this.card = card; - } - - @Override - public boolean apply(Card input, Game game) { - return input.shareCreatureTypes(game, card); - } - } - - public CrownOfFuryEffect() { - super(Outcome.Benefit); - this.staticText = "Enchanted creature and other creatures that share a creature type with it get +1/+0 and gain first strike until end of turn."; - } - - public CrownOfFuryEffect(final CrownOfFuryEffect effect) { - super(effect); - } - - @Override - public CrownOfFuryEffect copy() { - return new CrownOfFuryEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - - // Enchanted creature ... - ContinuousEffect effect = new BoostEnchantedEffect(1, 0, Duration.EndOfTurn); - game.addEffect(effect, source); - effect = new GainAbilityAttachedEffect(FirstStrikeAbility.getInstance(), AttachmentType.AURA, Duration.EndOfTurn); - game.addEffect(effect, source); - - // ... and other creatures that share a creature type with it ... - Permanent enchantedCreature = game.getPermanent(source.getSourcePermanentOrLKI(game).getAttachedTo()); - FilterCreaturePermanent filter = new FilterCreaturePermanent(); - filter.add(new CrownOfFuryPredicate(enchantedCreature)); - filter.add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(enchantedCreature, game)))); - game.addEffect(new BoostAllEffect(1, 0, Duration.EndOfTurn, filter, false), source); - game.addEffect(new GainAbilityAllEffect(FirstStrikeAbility.getInstance(), Duration.EndOfTurn, filter), source); - - // ... get +1/+0 and gain first strike until end of turn. - return true; - } -} diff --git a/Mage.Sets/src/mage/sets/Onslaught.java b/Mage.Sets/src/mage/sets/Onslaught.java index 01391ae58c..c5d61e63b3 100644 --- a/Mage.Sets/src/mage/sets/Onslaught.java +++ b/Mage.Sets/src/mage/sets/Onslaught.java @@ -86,8 +86,11 @@ public final class Onslaught extends ExpansionSet { cards.add(new SetCardInfo("Cover of Darkness", 133, Rarity.RARE, mage.cards.c.CoverOfDarkness.class)); cards.add(new SetCardInfo("Crafty Pathmage", 77, Rarity.COMMON, mage.cards.c.CraftyPathmage.class)); cards.add(new SetCardInfo("Crowd Favorites", 15, Rarity.UNCOMMON, mage.cards.c.CrowdFavorites.class)); + cards.add(new SetCardInfo("Crown of Ascension", 78, Rarity.COMMON, mage.cards.c.CrownOfAscension.class)); cards.add(new SetCardInfo("Crown of Awe", 16, Rarity.COMMON, mage.cards.c.CrownOfAwe.class)); cards.add(new SetCardInfo("Crown of Fury", 196, Rarity.COMMON, mage.cards.c.CrownOfFury.class)); + cards.add(new SetCardInfo("Crown of Suspicion", 134, Rarity.COMMON, mage.cards.c.CrownOfSuspicion.class)); + cards.add(new SetCardInfo("Crown of Vigor", 253, Rarity.COMMON, mage.cards.c.CrownOfVigor.class)); cards.add(new SetCardInfo("Crude Rampart", 17, Rarity.UNCOMMON, mage.cards.c.CrudeRampart.class)); cards.add(new SetCardInfo("Cruel Revival", 135, Rarity.COMMON, mage.cards.c.CruelRevival.class)); cards.add(new SetCardInfo("Cryptic Gateway", 306, Rarity.RARE, mage.cards.c.CrypticGateway.class)); diff --git a/Mage/src/main/java/mage/filter/StaticFilters.java b/Mage/src/main/java/mage/filter/StaticFilters.java index b85ebfbe6f..6ce0d9cd5f 100644 --- a/Mage/src/main/java/mage/filter/StaticFilters.java +++ b/Mage/src/main/java/mage/filter/StaticFilters.java @@ -10,6 +10,7 @@ import mage.filter.common.*; import mage.filter.predicate.Predicates; import mage.filter.predicate.mageobject.*; import mage.filter.predicate.other.AnotherTargetPredicate; +import mage.filter.predicate.permanent.AttachedOrShareCreatureTypePredicate; import mage.filter.predicate.permanent.TappedPredicate; import mage.filter.predicate.permanent.TokenPredicate; @@ -892,6 +893,13 @@ public final class StaticFilters { FILTER_CREATURE_TOKENS.setLockedFilter(true); } + public static final FilterCreaturePermanent FILTER_CREATURE_ENCHANTED_AND_SHARE_TYPE = new FilterCreaturePermanent("enchanted creature and other creatures that share a creature type with it"); + + static { + FILTER_CREATURE_ENCHANTED_AND_SHARE_TYPE.add(AttachedOrShareCreatureTypePredicate.instance); + FILTER_CREATURE_ENCHANTED_AND_SHARE_TYPE.setLockedFilter(true); + } + public static final FilterAttackingCreature FILTER_ATTACKING_CREATURE = new FilterAttackingCreature(); static {