Some cleanups/remanes for attack/block restrict effects.

This commit is contained in:
LevelX2 2015-06-30 16:07:39 +02:00
parent 77673ba49f
commit 312a9fd7af
16 changed files with 183 additions and 172 deletions

View file

@ -25,16 +25,15 @@
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.MageInt;
import mage.abilities.common.AttacksEachTurnStaticAbility;
import mage.abilities.keyword.BushidoAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
/**
*
@ -42,7 +41,7 @@ import mage.cards.CardImpl;
*/
public class BattleMadRonin extends CardImpl {
public BattleMadRonin (UUID ownerId) {
public BattleMadRonin(UUID ownerId) {
super(ownerId, 156, "Battle-Mad Ronin", Rarity.COMMON, new CardType[]{CardType.CREATURE}, "{1}{R}");
this.expansionSetCode = "CHK";
this.subtype.add("Human");
@ -50,11 +49,15 @@ public class BattleMadRonin extends CardImpl {
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// Bushido 2 (When this blocks or becomes blocked, it gets +2/+2 until end of turn.)
this.addAbility(new BushidoAbility(2));
// Battle-Mad Ronin attacks each turn if able.
this.addAbility(new AttacksEachTurnStaticAbility());
}
public BattleMadRonin (final BattleMadRonin card) {
public BattleMadRonin(final BattleMadRonin card) {
super(card);
}

View file

@ -28,13 +28,12 @@
package mage.sets.commander;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.CounterUnlessPaysEffect;
import mage.abilities.keyword.StormAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Rarity;
import mage.filter.FilterSpell;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
@ -47,15 +46,15 @@ import mage.target.TargetSpell;
public class Flusterstorm extends CardImpl {
private static final FilterSpell filter = new FilterSpell("instant or sorcery spell");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.INSTANT), new CardTypePredicate(CardType.SORCERY)));
}
public Flusterstorm(UUID ownerId) {
super(ownerId, 46, "Flusterstorm", Rarity.RARE, new CardType[]{CardType.INSTANT}, "{U}");
this.expansionSetCode = "CMD";
// Counter target instant or sorcery spell unless its controller pays {1}.
this.getSpellAbility().addEffect(new CounterUnlessPaysEffect(new ManaCostsImpl("{1}")));
this.getSpellAbility().addTarget(new TargetSpell(filter));

View file

@ -29,23 +29,19 @@ package mage.sets.fifthedition;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByCreaturesSourceEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SubtypePredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.filter.predicate.permanent.ControllerPredicate;
/**
*
@ -53,12 +49,15 @@ import mage.game.permanent.Permanent;
*/
public class EvilEyeOfOrmsByGore extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("except by Walls");
private static final FilterCreaturePermanent cantAttackFilter = new FilterCreaturePermanent("Non-Eye creatures you control");
private static final FilterCreaturePermanent cantBeBlockedByFilter = new FilterCreaturePermanent("except by Walls");
static {
filter.add(Predicates.not(new SubtypePredicate("Wall")));
cantBeBlockedByFilter.add(Predicates.not(new SubtypePredicate("Wall")));
cantAttackFilter.add(Predicates.not((new SubtypePredicate("Eye"))));
cantAttackFilter.add(new ControllerPredicate(TargetController.YOU));
}
public EvilEyeOfOrmsByGore(UUID ownerId) {
super(ownerId, 21, "Evil Eye of Orms-by-Gore", Rarity.UNCOMMON, new CardType[]{CardType.CREATURE}, "{4}{B}");
this.expansionSetCode = "5ED";
@ -68,10 +67,10 @@ public class EvilEyeOfOrmsByGore extends CardImpl {
this.toughness = new MageInt(6);
// Non-Eye creatures you control can't attack.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EvilEyeOfOrmsByGoreEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, cantAttackFilter)));
// Evil Eye of Orms-by-Gore can't be blocked except by Walls.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(filter, Duration.WhileOnBattlefield)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantBeBlockedByCreaturesSourceEffect(cantBeBlockedByFilter, Duration.WhileOnBattlefield)));
}
public EvilEyeOfOrmsByGore(final EvilEyeOfOrmsByGore card) {
@ -83,43 +82,3 @@ public class EvilEyeOfOrmsByGore extends CardImpl {
return new EvilEyeOfOrmsByGore(this);
}
}
class EvilEyeOfOrmsByGoreEffect extends ReplacementEffectImpl {
public EvilEyeOfOrmsByGoreEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Non-Eye creatures you control can't attack";
}
public EvilEyeOfOrmsByGoreEffect(final EvilEyeOfOrmsByGoreEffect effect) {
super(effect);
}
@Override
public EvilEyeOfOrmsByGoreEffect copy() {
return new EvilEyeOfOrmsByGoreEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null) {
if (permanent.getControllerId().equals(source.getControllerId())) {
if (!permanent.hasSubtype("Eye")) {
return true;
}
}
}
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
}

View file

@ -30,7 +30,7 @@ package mage.sets.futuresight;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -62,7 +62,7 @@ public class MagusOfTheMoat extends CardImpl {
this.toughness = new MageInt(3);
// Creatures without flying can't attack.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
}
public MagusOfTheMoat(final MagusOfTheMoat card) {

View file

@ -33,14 +33,19 @@ import mage.abilities.Ability;
import mage.abilities.abilityword.GrandeurAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PreventDamageToTargetEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerIdPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -68,10 +73,9 @@ public class OrissSamiteGuardian extends CardImpl {
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PreventDamageToTargetEffect(Duration.EndOfTurn, Integer.MAX_VALUE), new TapSourceCost());
ability.addTarget(new TargetCreaturePermanent());
this.addAbility(ability);
// Grandeur - Discard another card named Oriss, Samite Guardian: Target player can't cast spells this turn, and creatures that player controls can't attack this turn.
ability = new GrandeurAbility(new OrissSamiteGuardianCantCastEffect(), "Oriss, Samite Guardian");
ability.addEffect(new OrissSamiteGuardianCantAttackEffect());
ability.addTarget(new TargetPlayer());
this.addAbility(ability);
}
@ -86,6 +90,37 @@ public class OrissSamiteGuardian extends CardImpl {
}
}
class OrissSamiteGuardianEffect extends OneShotEffect {
public OrissSamiteGuardianEffect() {
super(Outcome.Benefit);
this.staticText = "Target player can't cast spells this turn, and creatures that player controls can't attack this turn";
}
public OrissSamiteGuardianEffect(final OrissSamiteGuardianEffect effect) {
super(effect);
}
@Override
public OrissSamiteGuardianEffect copy() {
return new OrissSamiteGuardianEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
game.addEffect(new OrissSamiteGuardianCantCastEffect(), source);
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures that player controls");
filter.add(new ControllerIdPredicate(getTargetPointer().getFirst(game, source)));
ContinuousEffect effect = new CantAttackAnyPlayerAllEffect(Duration.EndOfTurn, filter);
game.addEffect(effect, source);
return true;
}
return false;
}
}
class OrissSamiteGuardianCantCastEffect extends ContinuousRuleModifyingEffectImpl {
OrissSamiteGuardianCantCastEffect() {
@ -106,38 +141,10 @@ class OrissSamiteGuardianCantCastEffect extends ContinuousRuleModifyingEffectImp
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.CAST_SPELL;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
return player != null && player.getId().equals(event.getPlayerId());
}
}
class OrissSamiteGuardianCantAttackEffect extends ContinuousRuleModifyingEffectImpl {
OrissSamiteGuardianCantAttackEffect() {
super(Duration.EndOfTurn, Outcome.Detriment);
staticText = ", and creatures that player controls can't attack this turn";
}
OrissSamiteGuardianCantAttackEffect(final OrissSamiteGuardianCantAttackEffect effect) {
super(effect);
}
@Override
public OrissSamiteGuardianCantAttackEffect copy() {
return new OrissSamiteGuardianCantAttackEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
return player != null && player.getId().equals(event.getPlayerId());
}
}

View file

@ -33,7 +33,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.effects.common.PreventAllDamageToControllerEffect;
import mage.abilities.effects.common.SacrificeControllerEffect;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.keyword.CumulativeUpkeepAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -62,7 +62,7 @@ public class GlacialChasm extends CardImpl {
// Creatures you control can't attack.
FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures you control");
filter.add(new ControllerPredicate(TargetController.YOU));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
// Prevent all damage that would be dealt to you.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PreventAllDamageToControllerEffect(Duration.WhileOnBattlefield)));
}

View file

@ -31,7 +31,7 @@ import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
@ -67,7 +67,7 @@ public class AkronLegionnaire extends CardImpl {
this.toughness = new MageInt(4);
// Except for creatures named Akron Legionnaire and artifact creatures, creatures you control can't attack.
Effect effect = new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter);
Effect effect = new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter);
effect.setText("Except for creatures named Akron Legionnaire and artifact creatures, creatures you control can't attack");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));

View file

@ -29,7 +29,7 @@ package mage.sets.legends;
import java.util.UUID;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -58,7 +58,7 @@ public class Moat extends CardImpl {
// Creatures without flying can't attack.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
}
public Moat(final Moat card) {

View file

@ -33,7 +33,7 @@ import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.IslandwalkAbility;
import mage.abilities.mana.BlueManaAbility;
@ -80,7 +80,7 @@ public class StormtideLeviathan extends CardImpl {
// All lands are Islands in addition to their other types.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StormtideLeviathanEffect()));
// Creatures without flying or islandwalk can't attack.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAllAnyPlayerEffect(Duration.WhileOnBattlefield, filter)));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackAnyPlayerAllEffect(Duration.WhileOnBattlefield, filter)));
}

View file

@ -33,7 +33,7 @@ import mage.abilities.Ability;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.combat.CantAttackAllAnyPlayerEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerAllEffect;
import mage.abilities.keyword.KickerAbility;
import mage.cards.CardImpl;
import mage.constants.CardType;
@ -126,7 +126,7 @@ class OrimsChantEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && KickedCondition.getInstance().apply(game, source)) {
game.addEffect(new CantAttackAllAnyPlayerEffect(Duration.EndOfTurn, new FilterCreaturePermanent("creatures")), source);
game.addEffect(new CantAttackAnyPlayerAllEffect(Duration.EndOfTurn, new FilterCreaturePermanent("creatures")), source);
return true;
}
return false;

View file

@ -28,20 +28,16 @@
package mage.sets.tempest;
import java.util.UUID;
import mage.abilities.Ability;
import mage.ObjectColor;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.combat.CantAttackBlockAllEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
@ -49,13 +45,19 @@ import mage.players.Player;
*/
public class LightOfDay extends CardImpl {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Black creatures");
static {
filter.add(new ColorPredicate(ObjectColor.BLACK));
}
public LightOfDay(UUID ownerId) {
super(ownerId, 239, "Light of Day", Rarity.UNCOMMON, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}");
this.expansionSetCode = "TMP";
// Black creatures can't attack or block.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LightOfDayEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantAttackBlockAllEffect(Duration.WhileOnBattlefield, filter)));
}
public LightOfDay(final LightOfDay card) {
@ -67,45 +69,3 @@ public class LightOfDay extends CardImpl {
return new LightOfDay(this);
}
}
class LightOfDayEffect extends ReplacementEffectImpl {
public LightOfDayEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Black creatures can't attack or block";
}
public LightOfDayEffect(final LightOfDayEffect effect) {
super(effect);
}
@Override
public LightOfDayEffect copy() {
return new LightOfDayEffect(this);
}
@Override
public boolean checksEventType(GameEvent event, Game game) {
return event.getType() == EventType.DECLARE_ATTACKER || event.getType() == EventType.DECLARE_BLOCKER;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null) {
Player player = game.getPlayer(source.getControllerId());
if (player.getInRange().contains(permanent.getControllerId())) {
if (permanent.getColor(game).isBlack()) {
return true;
}
}
}
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
}

View file

@ -35,7 +35,7 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.condition.Condition;
import mage.abilities.decorator.ConditionalRestrictionEffect;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.combat.CantAttackAllSourceEffect;
import mage.abilities.effects.common.combat.CantAttackAnyPlayerSourceEffect;
import mage.abilities.effects.common.turn.AddExtraTurnControllerEffect;
import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl;
@ -65,7 +65,7 @@ public class MedomaiTheAgeless extends CardImpl {
// Whenever Medomai the Ageless deals combat damage to a player, take an extra turn after this one.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new AddExtraTurnControllerEffect(), false));
// Medomai the Ageless can't attack during extra turns.
Effect effect = new ConditionalRestrictionEffect(new CantAttackAllSourceEffect(Duration.WhileOnBattlefield), ExtraTurnCondition.getInstance());
Effect effect = new ConditionalRestrictionEffect(new CantAttackAnyPlayerSourceEffect(Duration.WhileOnBattlefield), ExtraTurnCondition.getInstance());
effect.setText("{this} can't attack during extra turns");
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
}

View file

@ -33,7 +33,6 @@ import mage.abilities.condition.FixedCondition;
import mage.abilities.condition.LockedInCondition;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.constants.EffectType;
import mage.game.Game;
import mage.game.permanent.Permanent;
@ -56,7 +55,6 @@ public class ConditionalRestrictionEffect extends RestrictionEffect {
public ConditionalRestrictionEffect(Duration duration, RestrictionEffect effect, Condition condition, RestrictionEffect otherwiseEffect) {
super(duration);
this.effectType = EffectType.RESTRICTION;
this.effect = effect;
this.baseCondition = condition;
this.otherwiseEffect = otherwiseEffect;

View file

@ -40,11 +40,11 @@ import mage.game.permanent.Permanent;
*
* @author LevelX2
*/
public class CantAttackAllAnyPlayerEffect extends RestrictionEffect {
public class CantAttackAnyPlayerAllEffect extends RestrictionEffect {
private final FilterCreaturePermanent filter;
public CantAttackAllAnyPlayerEffect(Duration duration, FilterCreaturePermanent filter) {
public CantAttackAnyPlayerAllEffect(Duration duration, FilterCreaturePermanent filter) {
super(duration);
this.filter = filter;
StringBuilder sb = new StringBuilder(filter.getMessage()).append(" can't attack");
@ -59,7 +59,7 @@ public class CantAttackAllAnyPlayerEffect extends RestrictionEffect {
staticText = sb.toString();
}
public CantAttackAllAnyPlayerEffect(final CantAttackAllAnyPlayerEffect effect) {
public CantAttackAnyPlayerAllEffect(final CantAttackAnyPlayerAllEffect effect) {
super(effect);
this.filter = effect.filter;
}
@ -75,8 +75,8 @@ public class CantAttackAllAnyPlayerEffect extends RestrictionEffect {
}
@Override
public CantAttackAllAnyPlayerEffect copy() {
return new CantAttackAllAnyPlayerEffect(this);
public CantAttackAnyPlayerAllEffect copy() {
return new CantAttackAnyPlayerAllEffect(this);
}
}

View file

@ -39,13 +39,13 @@ import mage.game.permanent.Permanent;
*
* @author BetaSteward_at_googlemail.com
*/
public class CantAttackAllSourceEffect extends RestrictionEffect {
public class CantAttackAnyPlayerSourceEffect extends RestrictionEffect {
public CantAttackAllSourceEffect(Duration duration) {
public CantAttackAnyPlayerSourceEffect(Duration duration) {
super(duration);
}
public CantAttackAllSourceEffect(final CantAttackAllSourceEffect effect) {
public CantAttackAnyPlayerSourceEffect(final CantAttackAnyPlayerSourceEffect effect) {
super(effect);
}
@ -60,8 +60,8 @@ public class CantAttackAllSourceEffect extends RestrictionEffect {
}
@Override
public CantAttackAllSourceEffect copy() {
return new CantAttackAllSourceEffect(this);
public CantAttackAnyPlayerSourceEffect copy() {
return new CantAttackAnyPlayerSourceEffect(this);
}
}

View file

@ -0,0 +1,85 @@
/*
* 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.combat;
import mage.abilities.Ability;
import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration;
import mage.filter.common.FilterCreaturePermanent;
import mage.game.Game;
import mage.game.permanent.Permanent;
/**
*
* @author LevelX2
*/
public class CantAttackBlockAllEffect extends RestrictionEffect {
private final FilterCreaturePermanent filter;
public CantAttackBlockAllEffect(Duration duration, FilterCreaturePermanent filter) {
super(duration);
this.filter = filter;
StringBuilder sb = new StringBuilder(filter.getMessage()).append(" can't attack or block");
if (!duration.toString().isEmpty()) {
sb.append(" ");
if (duration.equals(Duration.EndOfTurn)) {
sb.append(" this turn");
} else {
sb.append(" ").append(duration.toString());
}
}
staticText = sb.toString();
}
public CantAttackBlockAllEffect(final CantAttackBlockAllEffect effect) {
super(effect);
this.filter = effect.filter;
}
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return filter.match(permanent, source.getSourceId(), source.getControllerId(), game);
}
@Override
public boolean canAttack(Game game) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}
@Override
public CantAttackBlockAllEffect copy() {
return new CantAttackBlockAllEffect(this);
}
}