diff --git a/Mage.Sets/src/mage/cards/a/AspectOfWolf.java b/Mage.Sets/src/mage/cards/a/AspectOfWolf.java index 0121c26c2b..8eb1359d2d 100644 --- a/Mage.Sets/src/mage/cards/a/AspectOfWolf.java +++ b/Mage.Sets/src/mage/cards/a/AspectOfWolf.java @@ -1,7 +1,5 @@ - package mage.cards.a; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.dynamicvalue.DynamicValue; @@ -11,24 +9,27 @@ import mage.abilities.effects.common.continuous.BoostEnchantedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; -import mage.filter.common.FilterLandPermanent; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.SubType; +import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledPermanent; import mage.game.Game; import mage.target.TargetPermanent; import mage.target.common.TargetCreaturePermanent; -/** - * - * @author KholdFuzion +import java.util.UUID; +/** + * @author KholdFuzion */ public final class AspectOfWolf extends CardImpl { public AspectOfWolf(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}"); this.subtype.add(SubType.AURA); - // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); @@ -36,7 +37,10 @@ public final class AspectOfWolf extends CardImpl { Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); // Enchanted creature gets +X/+Y, where X is half the number of Forests you control, rounded down, and Y is half the number of Forests you control, rounded up. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEnchantedEffect(new HalfForestsDownCount(), new HalfForestsUpCount(), Duration.WhileOnBattlefield))); + this.addAbility(new SimpleStaticAbility(new BoostEnchantedEffect( + AspectOfWolfValue.UP, AspectOfWolfValue.DOWN, Duration.WhileOnBattlefield + ).setText("enchanted creature gets +X/+Y, where X is half the number of Forests you control, " + + "rounded down, and Y is half the number of Forests you control, rounded up"))); } private AspectOfWolf(final AspectOfWolf card) { @@ -49,61 +53,36 @@ public final class AspectOfWolf extends CardImpl { } } -class HalfForestsDownCount implements DynamicValue { +enum AspectOfWolfValue implements DynamicValue { + UP(true), DOWN(false); - private static final FilterLandPermanent filter = new FilterLandPermanent(); + private static final FilterPermanent filter = new FilterControlledPermanent(SubType.FOREST); + private final boolean up; - static { - filter.add(SubType.FOREST.getPredicate()); + AspectOfWolfValue(boolean up) { + this.up = up; } @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { - return game.getBattlefield().countAll(filter, sourceAbility.getControllerId(), game) / 2; + int forestCount = game.getBattlefield().count( + filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game + ); + return forestCount / 2 + (up ? forestCount % 2 : 0); } @Override - public HalfForestsDownCount copy() { - return new HalfForestsDownCount(); + public AspectOfWolfValue copy() { + return this; } @Override public String toString() { - return "X"; + return up ? "X" : "Y"; } @Override public String getMessage() { - return "half the number of Forests you control, rounded down"; - } -} - -class HalfForestsUpCount implements DynamicValue { - - private static final FilterLandPermanent filter = new FilterLandPermanent(); - - static { - filter.add(SubType.FOREST.getPredicate()); - } - - @Override - public int calculate(Game game, Ability sourceAbility, Effect effect) { - int amount = (int) Math.ceil(game.getBattlefield().countAll(filter, sourceAbility.getControllerId(), game) / 2f); - return amount; - } - - @Override - public HalfForestsUpCount copy() { - return new HalfForestsUpCount(); - } - - @Override - public String toString() { - return "Y"; - } - - @Override - public String getMessage() { - return "half the number of Forests you control, rounded up"; + return "half the number of Forests you control, rounded " + (up ? "up" : "down"); } }