diff --git a/Mage.Sets/src/mage/sets/magic2010/PalaceGuard.java b/Mage.Sets/src/mage/sets/magic2010/PalaceGuard.java index 53315c5ae5..b91eea1934 100644 --- a/Mage.Sets/src/mage/sets/magic2010/PalaceGuard.java +++ b/Mage.Sets/src/mage/sets/magic2010/PalaceGuard.java @@ -30,19 +30,12 @@ package mage.sets.magic2010; import java.util.UUID; import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; import mage.Constants.Rarity; -import mage.Constants.SubLayer; import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continious.CanBlockAdditionalCreatureEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.game.permanent.Permanent; /** * @@ -59,7 +52,8 @@ public class PalaceGuard extends CardImpl { this.power = new MageInt(1); this.toughness = new MageInt(4); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PalaceGuardEffect())); + // Palace Guard can block any number of creatures. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockAdditionalCreatureEffect(0))); } public PalaceGuard(final PalaceGuard card) { @@ -70,47 +64,4 @@ public class PalaceGuard extends CardImpl { public PalaceGuard copy() { return new PalaceGuard(this); } - - class PalaceGuardEffect extends ContinuousEffectImpl { - - public PalaceGuardEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = "{this} can block any number of creatures"; - } - - public PalaceGuardEffect(final PalaceGuardEffect effect) { - super(effect); - } - - @Override - public PalaceGuardEffect copy() { - return new PalaceGuardEffect(this); - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - Permanent perm = game.getPermanent(source.getSourceId()); - if (perm != null) { - switch (layer) { - case RulesEffects: - perm.setMaxBlocks(0); - break; - } - return true; - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.RulesEffects; - } - - } } - diff --git a/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java b/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java index 8bbf2dba29..f199faa50a 100644 --- a/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java +++ b/Mage.Sets/src/mage/sets/prophecy/AvatarOfHope.java @@ -30,11 +30,7 @@ package mage.sets.prophecy; import java.util.UUID; import mage.Constants; import mage.Constants.CardType; -import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; import mage.Constants.Rarity; -import mage.Constants.SubLayer; import mage.Constants.Zone; import mage.MageInt; import mage.Mana; @@ -42,12 +38,11 @@ import mage.abilities.Ability; import mage.abilities.SpellAbility; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.AdjustingSourceCosts; -import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.CostModificationEffectImpl; +import mage.abilities.effects.common.continious.CanBlockAdditionalCreatureEffect; import mage.abilities.keyword.FlyingAbility; import mage.cards.CardImpl; import mage.game.Game; -import mage.game.permanent.Permanent; import mage.players.Player; import mage.util.CardUtil; @@ -71,7 +66,7 @@ public class AvatarOfHope extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); // Avatar of Hope can block any number of creatures. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new AvatarOfHopeEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CanBlockAdditionalCreatureEffect(0))); } public AvatarOfHope(final AvatarOfHope card) { @@ -84,11 +79,8 @@ public class AvatarOfHope extends CardImpl { } } - class AdjustingCostsAbility extends SimpleStaticAbility implements AdjustingSourceCosts { - - public AdjustingCostsAbility() { super(Constants.Zone.OUTSIDE, new AdjustingCostsEffect()); } @@ -134,7 +126,9 @@ class AdjustingCostsEffect extends CostModificationEffectImpl 0 && player != null && player.getLife() < 4) { int newCount = mana.getColorless() - 6; - if (newCount < 0) newCount = 0; + if (newCount < 0) { + newCount = 0; + } mana.setColorless(newCount); spellAbility.getManaCostsToPay().load(mana.toString()); return true; @@ -155,45 +149,3 @@ class AdjustingCostsEffect extends CostModificationEffectImpl { - - public AvatarOfHopeEffect() { - super(Duration.WhileOnBattlefield, Outcome.Benefit); - staticText = "{this} can block any number of creatures"; - } - - public AvatarOfHopeEffect(final AvatarOfHopeEffect effect) { - super(effect); - } - - @Override - public AvatarOfHopeEffect copy() { - return new AvatarOfHopeEffect(this); - } - - @Override - public boolean apply(Layer layer, SubLayer sublayer, Ability source, Game game) { - Permanent perm = game.getPermanent(source.getSourceId()); - if (perm != null) { - switch (layer) { - case RulesEffects: - perm.setMaxBlocks(0); - break; - } - return true; - } - return false; - } - - @Override - public boolean apply(Game game, Ability source) { - return false; - } - - @Override - public boolean hasLayer(Layer layer) { - return layer == Layer.RulesEffects; - } - -} \ No newline at end of file diff --git a/Mage/src/mage/abilities/effects/common/continious/CanBlockAdditionalCreatureEffect.java b/Mage/src/mage/abilities/effects/common/continious/CanBlockAdditionalCreatureEffect.java index 5e1976eba0..100dd0957c 100644 --- a/Mage/src/mage/abilities/effects/common/continious/CanBlockAdditionalCreatureEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/CanBlockAdditionalCreatureEffect.java @@ -49,6 +49,11 @@ public class CanBlockAdditionalCreatureEffect extends ContinuousEffectImpl 0) { perm.setMaxBlocks(perm.getMaxBlocks() + 1); + } else { + perm.setMaxBlocks(0); } break; } return true; } - return false; } @@ -92,6 +98,21 @@ public class CanBlockAdditionalCreatureEffect extends ContinuousEffectImpl