mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
- Fixed Selvala, Heart of the Wilds.
This commit is contained in:
parent
17aa9e3f6c
commit
691c590e68
1 changed files with 32 additions and 25 deletions
|
@ -29,22 +29,22 @@ package mage.cards.s;
|
|||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.Mana;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldAllTriggeredAbility;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.dynamicvalue.common.GreatestPowerAmongControlledCreaturesValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.mana.DynamicManaAbility;
|
||||
import mage.abilities.effects.common.AddManaInAnyCombinationEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.ObjectSourcePlayer;
|
||||
import mage.filter.predicate.ObjectSourcePlayerPredicate;
|
||||
import mage.filter.predicate.Predicate;
|
||||
import mage.filter.predicate.permanent.AnotherPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
@ -60,13 +60,13 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
|
|||
|
||||
static {
|
||||
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 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) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{G}{G}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{G}");
|
||||
this.supertype.add("Legendary");
|
||||
this.subtype.add("Elf");
|
||||
this.subtype.add("Scout");
|
||||
|
@ -77,8 +77,8 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
|
|||
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.
|
||||
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.");
|
||||
Effect effect = new AddManaInAnyCombinationEffect(new GreatestPowerAmongControlledCreaturesValue(), rule2, ColoredManaSymbol.B, ColoredManaSymbol.U, ColoredManaSymbol.R, ColoredManaSymbol.W, ColoredManaSymbol.G);
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, effect, new ManaCostsImpl("{G}"));
|
||||
ability.addCost(new TapSourceCost());
|
||||
this.addAbility(ability);
|
||||
|
||||
|
@ -96,6 +96,12 @@ public class SelvalaHeartOfTheWilds extends CardImpl {
|
|||
|
||||
class SelvalaHeartOfTheWildsEffect extends OneShotEffect {
|
||||
|
||||
private static final FilterCreaturePermanent filter2 = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter2.add(new GreatestPowerPredicate());
|
||||
}
|
||||
|
||||
public SelvalaHeartOfTheWildsEffect() {
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "that creature's controller may draw a card";
|
||||
|
@ -116,27 +122,28 @@ class SelvalaHeartOfTheWildsEffect extends OneShotEffect {
|
|||
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)) {
|
||||
cardowner.drawCards(1, game);
|
||||
}
|
||||
}
|
||||
if (permanent != null
|
||||
&& filter2.match(permanent, game)) {
|
||||
Player permanentController = game.getPlayer(permanent.getControllerId());
|
||||
if (permanentController.chooseUse(Outcome.DrawCard, "Would you like to draw a card?", source, game)) {
|
||||
permanentController.drawCards(1, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
class GreatestPowerPredicate implements ObjectSourcePlayerPredicate<ObjectSourcePlayer<Permanent>> {
|
||||
class GreatestPowerPredicate implements Predicate<Permanent> {
|
||||
|
||||
@Override
|
||||
public boolean apply(ObjectSourcePlayer<Permanent> input, Game game) {
|
||||
int pow = input.getObject().getPower().getValue();
|
||||
|
||||
for (UUID id : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(id);
|
||||
public boolean apply(Permanent input, Game game) {
|
||||
int power = input.getPower().getValue();
|
||||
for (UUID playerId : game.getPlayerList()) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), id, game)) {
|
||||
if (p.getPower().getValue() >= pow && !p.equals(input.getObject())) {
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), playerId, game)) {
|
||||
if (permanent.getPower().getValue() >= power && !permanent.equals(input)) {
|
||||
return false; //we found something with equal/more power
|
||||
}
|
||||
}
|
||||
|
@ -158,9 +165,9 @@ class GreatestPowerYouControlValue implements DynamicValue {
|
|||
Player player = game.getPlayer(sourceAbility.getControllerId());
|
||||
int amount = 0;
|
||||
if (player != null) {
|
||||
for (Permanent p : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), sourceAbility.getControllerId(), game)) {
|
||||
if (p.getPower().getValue() > amount) {
|
||||
amount = p.getPower().getValue();
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), sourceAbility.getControllerId(), game)) {
|
||||
if (permanent.getPower().getValue() > amount) {
|
||||
amount = permanent.getPower().getValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -174,6 +181,6 @@ class GreatestPowerYouControlValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
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.";
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue