diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfLifesWeb.java b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfLifesWeb.java index 1bae38bda5e..a05533cee27 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfLifesWeb.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/MyojinOfLifesWeb.java @@ -28,8 +28,6 @@ package mage.sets.championsofkamigawa; import java.util.UUID; - -import mage.constants.*; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAbility; @@ -40,15 +38,17 @@ import mage.abilities.condition.common.SourceHasCounterCondition; import mage.abilities.costs.common.RemoveCountersSourceCost; import mage.abilities.decorator.ConditionalContinuousEffect; import mage.abilities.decorator.ConditionalOneShotEffect; -import mage.abilities.effects.common.PutOntoBattlefieldTargetEffect; +import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.continuous.GainAbilitySourceEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; +import mage.cards.CardsImpl; +import mage.constants.*; import mage.counters.CounterType; -import mage.filter.FilterCard; -import mage.filter.predicate.mageobject.CardTypePredicate; -import mage.filter.predicate.other.OwnerPredicate; +import mage.filter.common.FilterCreatureCard; +import mage.game.Game; +import mage.players.Player; import mage.target.common.TargetCardInHand; import mage.watchers.common.CastFromHandWatcher; @@ -57,12 +57,6 @@ import mage.watchers.common.CastFromHandWatcher; */ public class MyojinOfLifesWeb extends CardImpl { - private static final FilterCard filter = new FilterCard("any number of creature cards from your hand"); - static { - filter.add(new CardTypePredicate(CardType.CREATURE)); - filter.add(new OwnerPredicate(TargetController.YOU)); - } - public MyojinOfLifesWeb(UUID ownerId) { super(ownerId, 229, "Myojin of Life's Web", Rarity.RARE, new CardType[]{CardType.CREATURE}, "{6}{G}{G}{G}"); this.expansionSetCode = "CHK"; @@ -79,10 +73,10 @@ public class MyojinOfLifesWeb extends CardImpl { // Myojin of Life's Web is indestructible as long as it has a divinity counter on it. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ConditionalContinuousEffect(new GainAbilitySourceEffect(IndestructibleAbility.getInstance(), Duration.WhileOnBattlefield), - new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it"))); + new SourceHasCounterCondition(CounterType.DIVINITY), "{this} is indestructible as long as it has a divinity counter on it"))); // Remove a divinity counter from Myojin of Life's Web: Put any number of creature cards from your hand onto the battlefield. - Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutOntoBattlefieldTargetEffect(false), new RemoveCountersSourceCost(CounterType.DIVINITY.createInstance())); - ability.addTarget(new TargetCardInHand(0, Integer.MAX_VALUE, filter)); + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new MyojinOfLifesWebPutCreatureOnBattlefieldEffect(), new RemoveCountersSourceCost(CounterType.DIVINITY.createInstance())); + this.addAbility(ability); } @@ -95,3 +89,35 @@ public class MyojinOfLifesWeb extends CardImpl { return new MyojinOfLifesWeb(this); } } + +class MyojinOfLifesWebPutCreatureOnBattlefieldEffect extends OneShotEffect { + + public MyojinOfLifesWebPutCreatureOnBattlefieldEffect() { + super(Outcome.PutCreatureInPlay); + this.staticText = "Put any number of creature cards from your hand onto the battlefield"; + } + + public MyojinOfLifesWebPutCreatureOnBattlefieldEffect(final MyojinOfLifesWebPutCreatureOnBattlefieldEffect effect) { + super(effect); + } + + @Override + public MyojinOfLifesWebPutCreatureOnBattlefieldEffect copy() { + return new MyojinOfLifesWebPutCreatureOnBattlefieldEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Player controller = game.getPlayer(source.getControllerId()); + if (controller == null) { + return false; + } + + TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, new FilterCreatureCard("creature cards from your hand to put onto the battlefield")); + if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + return controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), + Zone.BATTLEFIELD, source, game, false, false, false, null); + } + return false; + } +} diff --git a/Mage.Sets/src/mage/sets/conspiracytakethecrown/SelvalaHeartOfTheWilds.java b/Mage.Sets/src/mage/sets/conspiracytakethecrown/SelvalaHeartOfTheWilds.java index d092cf4b3e7..6aff8f6068c 100644 --- a/Mage.Sets/src/mage/sets/conspiracytakethecrown/SelvalaHeartOfTheWilds.java +++ b/Mage.Sets/src/mage/sets/conspiracytakethecrown/SelvalaHeartOfTheWilds.java @@ -33,13 +33,13 @@ import mage.Mana; import mage.abilities.Ability; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; import mage.abilities.costs.common.TapSourceCost; +import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; import mage.abilities.mana.DynamicManaAbility; import mage.cards.CardImpl; import mage.constants.*; -import mage.filter.FilterPermanent; import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterCreaturePermanent; import mage.filter.predicate.ObjectSourcePlayer; @@ -48,7 +48,6 @@ import mage.filter.predicate.permanent.AnotherPredicate; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; -import mage.target.targetpointer.FixedTarget; /** * @@ -56,8 +55,8 @@ import mage.target.targetpointer.FixedTarget; */ public class SelvalaHeartOfTheWilds extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("another creature"); + static { filter.add(new AnotherPredicate()); filter.add(new GreatestPowerPredicate()); @@ -75,12 +74,14 @@ public class SelvalaHeartOfTheWilds extends CardImpl { this.toughness = new MageInt(3); // Whenever another creature enters the battlefield, its controller may draw a card if its power is greater than each other creature's power. - this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new SelvalaHeartOfTheWildsEffect(), filter, false, SetTargetPointer.PERMANENT, rule)); // {G}, {T}: Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control. - this.addAbility(new DynamicManaAbility(new Mana(0,0,0,0,0,0,1, 0), new GreatestPowerYouControlValue(), new TapSourceCost(), - "Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control.")); + Ability ability = new DynamicManaAbility(new Mana(0, 0, 0, 0, 0, 0, 1, 0), new GreatestPowerYouControlValue(), new ManaCostsImpl<>("{G}"), + "Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control."); + ability.addCost(new TapSourceCost()); + this.addAbility(ability); + } public SelvalaHeartOfTheWilds(final SelvalaHeartOfTheWilds card) { @@ -112,12 +113,12 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); - if(permanent == null){ - permanent = (Permanent)game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); + if (permanent == null) { + permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); } if (permanent != null) { Player cardowner = game.getPlayer(permanent.getControllerId()); - if(cardowner.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)){ + if (cardowner.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)) { cardowner.drawCards(1, game); } } @@ -125,18 +126,17 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect { } } - class GreatestPowerPredicate implements ObjectSourcePlayerPredicate> { @Override public boolean apply(ObjectSourcePlayer input, Game game) { int pow = input.getObject().getPower().getValue(); - for (UUID id :game.getPlayerList()){ + for (UUID id : game.getPlayerList()) { Player player = game.getPlayer(id); if (player != null) { for (Permanent p : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), id, game)) { - if(p.getPower().getValue() >= pow && !p.equals(input.getObject())){ + if (p.getPower().getValue() >= pow && !p.equals(input.getObject())) { return false; //we found something with equal/more power } } @@ -144,6 +144,7 @@ class GreatestPowerPredicate implements ObjectSourcePlayerPredicate 0) { + sumPower += powerToAdd; + } if (sumPower >= value) { return true; }