Added UnblockableAllEffect and used it where necessary

This commit is contained in:
North 2012-09-06 16:58:21 +03:00
parent 41a80dcd5f
commit dbb782569b
3 changed files with 82 additions and 12 deletions

View file

@ -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<VenserTheSojourner> {
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);

View file

@ -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<DeepchannelMentor> {
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<DeepchannelMentor> {
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) {

View file

@ -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<UnblockableAllEffect> {
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);
}
}