From dbb782569b79c3977186c5d70d4bf5f7e4a51264 Mon Sep 17 00:00:00 2001 From: North Date: Thu, 6 Sep 2012 16:58:21 +0300 Subject: [PATCH] Added UnblockableAllEffect and used it where necessary --- .../scarsofmirrodin/VenserTheSojourner.java | 11 +-- .../sets/shadowmoor/DeepchannelMentor.java | 9 +-- .../effects/common/UnblockableAllEffect.java | 74 +++++++++++++++++++ 3 files changed, 82 insertions(+), 12 deletions(-) create mode 100644 Mage/src/mage/abilities/effects/common/UnblockableAllEffect.java diff --git a/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java b/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java index ffda6eadd0a..a9e7d4a1ac2 100644 --- a/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java +++ b/Mage.Sets/src/mage/sets/scarsofmirrodin/VenserTheSojourner.java @@ -28,8 +28,10 @@ package mage.sets.scarsofmirrodin; +import java.util.UUID; import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; import mage.Constants.Zone; import mage.abilities.Ability; @@ -42,9 +44,8 @@ import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.ExileTargetEffect; import mage.abilities.effects.common.GetEmblemEffect; import mage.abilities.effects.common.ReturnFromExileEffect; -import mage.abilities.effects.common.continious.GainAbilityAllEffect; +import mage.abilities.effects.common.UnblockableAllEffect; import mage.abilities.effects.common.counter.AddCountersSourceEffect; -import mage.abilities.keyword.UnblockableAbility; import mage.cards.CardImpl; import mage.counters.CounterType; import mage.filter.FilterSpell; @@ -59,8 +60,6 @@ import mage.target.TargetPermanent; import mage.target.common.TargetControlledPermanent; import mage.target.targetpointer.FixedTarget; -import java.util.UUID; - /** * @author nantuko */ @@ -79,10 +78,8 @@ public class VenserTheSojourner extends CardImpl { ability1.addTarget(new TargetControlledPermanent()); this.addAbility(ability1); - //TODO: Venser's second ability doesn't lock in what it applies to. That's because the effect states a true thing about creatures, - // but doesn't actually change the characteristics of those creatures. As a result, all creatures are unblockable that turn, including creatures you don't control, creatures that weren't on the battlefield at the time the ability resolved, and creatures that have lost all abilities. // -1: Creatures are unblockable this turn. - this.addAbility(new LoyaltyAbility(new GainAbilityAllEffect(UnblockableAbility.getInstance(), Constants.Duration.EndOfTurn, new FilterCreaturePermanent()), -1)); + this.addAbility(new LoyaltyAbility(new UnblockableAllEffect(new FilterCreaturePermanent("Creatures"), Duration.EndOfTurn), -1)); // -8: You get an emblem with "Whenever you cast a spell, exile target permanent." LoyaltyAbility ability2 = new LoyaltyAbility(new GetEmblemEffect(new VenserTheSojournerEmblem()), -8); diff --git a/Mage.Sets/src/mage/sets/shadowmoor/DeepchannelMentor.java b/Mage.Sets/src/mage/sets/shadowmoor/DeepchannelMentor.java index 04477c78d42..a0dfce78cc9 100644 --- a/Mage.Sets/src/mage/sets/shadowmoor/DeepchannelMentor.java +++ b/Mage.Sets/src/mage/sets/shadowmoor/DeepchannelMentor.java @@ -35,10 +35,9 @@ import mage.Constants.Zone; import mage.MageInt; import mage.ObjectColor; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.common.continious.GainAbilityControlledEffect; -import mage.abilities.keyword.UnblockableAbility; +import mage.abilities.effects.common.UnblockableAllEffect; import mage.cards.CardImpl; -import mage.filter.FilterPermanent; +import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.predicate.mageobject.ColorPredicate; /** @@ -47,7 +46,7 @@ import mage.filter.predicate.mageobject.ColorPredicate; */ public class DeepchannelMentor extends CardImpl { - private static final FilterPermanent filter = new FilterPermanent("Blue creatures"); + private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("Blue creatures you control"); static { filter.add(new ColorPredicate(ObjectColor.BLUE)); @@ -64,7 +63,7 @@ public class DeepchannelMentor extends CardImpl { this.toughness = new MageInt(2); // Blue creatures you control are unblockable. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityControlledEffect(UnblockableAbility.getInstance(), Duration.WhileOnBattlefield, filter))); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new UnblockableAllEffect(filter, Duration.WhileOnBattlefield))); } public DeepchannelMentor(final DeepchannelMentor card) { diff --git a/Mage/src/mage/abilities/effects/common/UnblockableAllEffect.java b/Mage/src/mage/abilities/effects/common/UnblockableAllEffect.java new file mode 100644 index 00000000000..69540d120d5 --- /dev/null +++ b/Mage/src/mage/abilities/effects/common/UnblockableAllEffect.java @@ -0,0 +1,74 @@ +/* + * Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of BetaSteward_at_googlemail.com. + */ +package mage.abilities.effects.common; + +import mage.Constants.Duration; +import mage.abilities.Ability; +import mage.abilities.effects.RestrictionEffect; +import mage.filter.FilterPermanent; +import mage.game.Game; +import mage.game.permanent.Permanent; + +/** + * + * @author North + */ +public class UnblockableAllEffect extends RestrictionEffect { + + private FilterPermanent filter; + + public UnblockableAllEffect(FilterPermanent filter, Duration duration) { + super(duration); + this.filter = filter; + + this.staticText = filter.getMessage() + " are unblockable"; + if (duration.equals(Duration.EndOfTurn)) { + this.staticText += " this turn"; + } + } + + public UnblockableAllEffect(UnblockableAllEffect effect) { + super(effect); + this.filter = effect.filter; + } + + @Override + public UnblockableAllEffect copy() { + return new UnblockableAllEffect(this); + } + + @Override + public boolean canBeBlocked(Permanent attacker, Permanent blocker, Ability source, Game game) { + return false; + } + + @Override + public boolean applies(Permanent permanent, Ability source, Game game) { + return filter.match(permanent, source.getSourceId(), source.getControllerId(), game); + } +}