- Fixed Selvala, Heart of the Wilds.

This commit is contained in:
Jeff 2017-03-09 10:15:57 -06:00
parent 17aa9e3f6c
commit 691c590e68

View file

@ -29,22 +29,22 @@ package mage.cards.s;
import java.util.UUID; import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.Mana;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility; import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.dynamicvalue.DynamicValue; import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.GreatestPowerAmongControlledCreaturesValue;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.mana.DynamicManaAbility; import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.*; import mage.constants.*;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreaturePermanent; import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.ObjectSourcePlayer; import mage.filter.predicate.Predicate;
import mage.filter.predicate.ObjectSourcePlayerPredicate;
import mage.filter.predicate.permanent.AnotherPredicate; import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
@ -60,10 +60,10 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
static { static {
filter.add(new AnotherPredicate()); filter.add(new AnotherPredicate());
filter.add(new GreatestPowerPredicate());
} }
private static final String rule = "Whenever another creature enters the battlefield, its controller may draw a card if its power is greater than each other creature's power."; private static final String rule = "Whenever another creature enters the battlefield, its controller may draw a card if its power is greater than each other creature's power.";
private static final String rule2 = "Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control.";
public SelvalaHeartOfTheWilds(UUID ownerId, CardSetInfo setInfo) { public SelvalaHeartOfTheWilds(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}"); super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}");
@ -77,8 +77,8 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
this.addAbility(new EntersBattlefieldAllTriggeredAbility(Zone.BATTLEFIELD, new SelvalaHeartOfTheWildsEffect(), filter, false, SetTargetPointer.PERMANENT, rule)); 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. // {G}, {T}: Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control.
Ability ability = new DynamicManaAbility(new Mana(0, 0, 0, 0, 0, 0, 1, 0), new GreatestPowerYouControlValue(), new ManaCostsImpl<>("{G}"), Effect effect = new AddManaInAnyCombinationEffect(new GreatestPowerAmongControlledCreaturesValue(), rule2, ColoredManaSymbol.B, ColoredManaSymbol.U, ColoredManaSymbol.R, ColoredManaSymbol.W, ColoredManaSymbol.G);
"Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control."); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{G}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
@ -96,6 +96,12 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
class SelvalaHeartOfTheWildsEffect extends OneShotEffect { class SelvalaHeartOfTheWildsEffect extends OneShotEffect {
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent();
static {
filter2.add(new GreatestPowerPredicate());
}
public SelvalaHeartOfTheWildsEffect() { public SelvalaHeartOfTheWildsEffect() {
super(Outcome.Benefit); super(Outcome.Benefit);
this.staticText = "that creature's controller may draw a card"; this.staticText = "that creature's controller may draw a card";
@ -116,27 +122,28 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect {
if (permanent == null) { if (permanent == null) {
permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD); permanent = (Permanent) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.BATTLEFIELD);
} }
if (permanent != null) { if (permanent != null
Player cardowner = game.getPlayer(permanent.getControllerId()); && filter2.match(permanent, game)) {
if (cardowner.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)) { Player permanentController = game.getPlayer(permanent.getControllerId());
cardowner.drawCards(1, game); if (permanentController.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)) {
} permanentController.drawCards(1, game);
}
return true; return true;
} }
} }
return false;
}
}
class GreatestPowerPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Permanent>> { class GreatestPowerPredicate implements Predicate<Permanent> {
@Override @Override
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) { public boolean apply(Permanent input, Game game) {
int pow = input.getObject().getPower().getValue(); int power = input.getPower().getValue();
for (UUID playerId : game.getPlayerList()) {
for (UUID id : game.getPlayerList()) { Player player = game.getPlayer(playerId);
Player player = game.getPlayer(id);
if (player != null) { if (player != null) {
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), id, game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), playerId, game)) {
if (p.getPower().getValue() >= pow && !p.equals(input.getObject())) { if (permanent.getPower().getValue() >= power && !permanent.equals(input)) {
return false; //we found something with equal/more power return false; //we found something with equal/more power
} }
} }
@ -158,9 +165,9 @@ class GreatestPowerYouControlValue implements DynamicValue {
Player player = game.getPlayer(sourceAbility.getControllerId()); Player player = game.getPlayer(sourceAbility.getControllerId());
int amount = 0; int amount = 0;
if (player != null) { if (player != null) {
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), sourceAbility.getControllerId(), game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), sourceAbility.getControllerId(), game)) {
if (p.getPower().getValue() > amount) { if (permanent.getPower().getValue() > amount) {
amount = p.getPower().getValue(); amount = permanent.getPower().getValue();
} }
} }
} }
@ -174,6 +181,6 @@ class GreatestPowerYouControlValue implements DynamicValue {
@Override @Override
public String getMessage() { public String getMessage() {
return "Add X mana in any combination of colors to your mana pool, where X is the number of creatures with defender you control."; return "Add X mana in any combination of colors to your mana pool, where X is the greatest power among creatures you control.";
} }
} }