Replaced more replacement effects by ContinuousRuleModifyingEffects or RestrictionEffects.

This commit is contained in:
LevelX2 2014-08-02 11:21:28 +02:00
parent b195b81316
commit df3b6afc8d
38 changed files with 285 additions and 434 deletions

View file

@ -38,7 +38,6 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.mana.ColorlessManaAbility; import mage.abilities.mana.ColorlessManaAbility;
import mage.abilities.mana.ConditionalAnyColorManaAbility; import mage.abilities.mana.ConditionalAnyColorManaAbility;
import mage.abilities.mana.builder.ConditionalManaBuilder; import mage.abilities.mana.builder.ConditionalManaBuilder;

View file

@ -32,6 +32,7 @@ import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -116,10 +117,10 @@ class SpiritOfTheLabyrinthWatcher extends Watcher {
} }
class SpiritOfTheLabyrinthEffect extends ReplacementEffectImpl { class SpiritOfTheLabyrinthEffect extends ContinuousRuleModifiyingEffectImpl {
public SpiritOfTheLabyrinthEffect() { public SpiritOfTheLabyrinthEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield, Outcome.Detriment, false, false);
staticText = "Each player can't draw more than one card each turn"; staticText = "Each player can't draw more than one card each turn";
} }
@ -137,11 +138,6 @@ class SpiritOfTheLabyrinthEffect extends ReplacementEffectImpl {
return true; return true;
} }
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DRAW_CARD) { if (event.getType() == GameEvent.EventType.DRAW_CARD) {

View file

@ -38,7 +38,6 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.common.PayLifeCost; import mage.abilities.costs.common.PayLifeCost;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.mana.SimpleManaAbility; import mage.abilities.mana.SimpleManaAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
@ -52,7 +51,6 @@ import mage.filter.common.FilterInstantOrSorceryCard;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.stack.Spell; import mage.game.stack.Spell;
import mage.players.Player;
import mage.watchers.Watcher; import mage.watchers.Watcher;
/** /**

View file

@ -79,7 +79,7 @@ class ShimatsuTheBloodcloakedEffect extends ReplacementEffectImpl {
public ShimatsuTheBloodcloakedEffect() { public ShimatsuTheBloodcloakedEffect() {
super(Duration.WhileOnBattlefield, Outcome.BoostCreature); super(Duration.WhileOnBattlefield, Outcome.BoostCreature);
this.staticText = "As Shimatsu the Bloodcloaked enters the battlefield, sacrifice any number of permanents. Shimatsu enters the battlefield with that many +1/+1 counters on it"; this.staticText = "As {this} enters the battlefield, sacrifice any number of permanents. {this} enters the battlefield with that many +1/+1 counters on it";
} }
public ShimatsuTheBloodcloakedEffect(final ShimatsuTheBloodcloakedEffect effect) { public ShimatsuTheBloodcloakedEffect(final ShimatsuTheBloodcloakedEffect effect) {

View file

@ -34,8 +34,8 @@ import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.RequirementEffect; import mage.abilities.effects.RequirementEffect;
import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
@ -143,7 +143,7 @@ class IllusionistsGambitRemoveFromCombatEffect extends OneShotEffect {
game.getState().getTurnMods().add(new TurnMod(game.getActivePlayerId(), TurnPhase.COMBAT, null, false)); game.getState().getTurnMods().add(new TurnMod(game.getActivePlayerId(), TurnPhase.COMBAT, null, false));
ContinuousEffect effect = new IllusionistsGambitRequirementEffect(attackers, phase); ContinuousEffect effect = new IllusionistsGambitRequirementEffect(attackers, phase);
game.addEffect(effect, source); game.addEffect(effect, source);
effect = new IllusionistsGambitReplacementEffect(attackers, phase); effect = new IllusionistsGambitRestrictionEffect(attackers, phase);
game.addEffect(effect, source); game.addEffect(effect, source);
} }
@ -203,32 +203,27 @@ class IllusionistsGambitRequirementEffect extends RequirementEffect {
} }
} }
class IllusionistsGambitReplacementEffect extends ReplacementEffectImpl { class IllusionistsGambitRestrictionEffect extends RestrictionEffect {
private final List attackers; private final List attackers;
private final Phase phase; private final Phase phase;
IllusionistsGambitReplacementEffect(List attackers, Phase phase) { public IllusionistsGambitRestrictionEffect(List attackers, Phase phase) {
super(Duration.Custom, Outcome.Benefit); super(Duration.Custom, Outcome.Benefit);
this.attackers = attackers; this.attackers = attackers;
this.phase = phase; this.phase = phase;
staticText = "They can't attack you or a planeswalker you control that combat"; staticText = "They can't attack you or a planeswalker you control that combat";
} }
IllusionistsGambitReplacementEffect(IllusionistsGambitReplacementEffect effect) { public IllusionistsGambitRestrictionEffect(final IllusionistsGambitRestrictionEffect effect) {
super(effect); super(effect);
this.attackers = effect.attackers; this.attackers = effect.attackers;
this.phase = effect.phase; this.phase = effect.phase;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean applies(Permanent permanent, Ability source, Game game) {
throw new UnsupportedOperationException("Not supported."); return attackers.contains(permanent.getId());
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
} }
@Override @Override
@ -242,24 +237,37 @@ class IllusionistsGambitReplacementEffect extends ReplacementEffectImpl {
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean canAttack(Game game) {
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER && attackers.contains(event.getSourceId())) {
if (event.getTargetId().equals(source.getControllerId()) ) {
return true;
}
// planeswalker
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())
&& permanent.getCardType().contains(CardType.PLANESWALKER)) {
return true;
}
}
return false; return false;
} }
@Override @Override
public IllusionistsGambitReplacementEffect copy() { public boolean canAttack(UUID defenderId, Ability source, Game game) {
return new IllusionistsGambitReplacementEffect(this); if (defenderId.equals(source.getControllerId()) ) {
return false;
}
// planeswalker
Permanent permanent = game.getPermanent(defenderId);
if (permanent != null && permanent.getControllerId().equals(source.getControllerId())
&& permanent.getCardType().contains(CardType.PLANESWALKER)) {
return false;
}
return true;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return false;
}
@Override
public IllusionistsGambitRestrictionEffect copy() {
return new IllusionistsGambitRestrictionEffect(this);
} }
} }

View file

@ -119,7 +119,7 @@ class MysticBarrierTriggeredAbility extends TriggeredAbilityImpl {
class MysticBarrierChooseEffect extends OneShotEffect { class MysticBarrierChooseEffect extends OneShotEffect {
public static final String[] SET_VALUES = new String[] { MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT }; public static final String[] SET_VALUES = new String[] { MysticBarrier.ALLOW_ATTACKING_LEFT, MysticBarrier.ALLOW_ATTACKING_RIGHT };
public static final Set<String> CHOICES = new HashSet<String>(Arrays.asList(SET_VALUES)); public static final Set<String> CHOICES = new HashSet<>(Arrays.asList(SET_VALUES));
final static Choice DIRECTION_CHOICE = new ChoiceImpl(true); final static Choice DIRECTION_CHOICE = new ChoiceImpl(true);
static { static {
DIRECTION_CHOICE.setChoices(CHOICES); DIRECTION_CHOICE.setChoices(CHOICES);

View file

@ -35,7 +35,6 @@ import mage.abilities.dynamicvalue.DynamicValue;
import mage.abilities.dynamicvalue.common.ManacostVariableValue; import mage.abilities.dynamicvalue.common.ManacostVariableValue;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;

View file

@ -33,7 +33,6 @@ import mage.constants.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;

View file

@ -38,6 +38,7 @@ import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffec
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;

View file

@ -42,6 +42,7 @@ import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffec
import mage.abilities.effects.common.counter.AddPlusOneCountersAttachedEffect; import mage.abilities.effects.common.counter.AddPlusOneCountersAttachedEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;

View file

@ -89,7 +89,7 @@ public class FullMoonsRise extends CardImpl {
class FullMoonsRiseEffect extends OneShotEffect { class FullMoonsRiseEffect extends OneShotEffect {
private FilterPermanent filter; private final FilterPermanent filter;
public FullMoonsRiseEffect(FilterPermanent filter) { public FullMoonsRiseEffect(FilterPermanent filter) {
super(Outcome.Regenerate); super(Outcome.Regenerate);

View file

@ -30,16 +30,13 @@ package mage.sets.innistrad;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
@ -55,7 +52,7 @@ public class StonySilence extends CardImpl {
this.color.setWhite(true); this.color.setWhite(true);
// Activated abilities of artifacts can't be activated. // Activated abilities of artifacts can't be activated.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StonySilenceEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new StonySilenceCantActivateEffect()));
} }
@ -69,41 +66,30 @@ public class StonySilence extends CardImpl {
} }
} }
class StonySilenceEffect extends ReplacementEffectImpl { class StonySilenceCantActivateEffect extends RestrictionEffect {
public StonySilenceEffect() { public StonySilenceCantActivateEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield);
staticText = "Activated abilities of artifacts can't be activated"; staticText = "Activated abilities of artifacts can't be activated";
} }
public StonySilenceEffect(final StonySilenceEffect effect) { public StonySilenceCantActivateEffect(final StonySilenceCantActivateEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean applies(Permanent permanent, Ability source, Game game) {
return true; return permanent.getCardType().contains(CardType.ARTIFACT);
} }
@Override @Override
public StonySilenceEffect copy() { public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return new StonySilenceEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.ACTIVATE_ABILITY) {
Permanent artifact = game.getPermanent(event.getSourceId());
if (artifact != null && artifact.getCardType().contains(CardType.ARTIFACT)) {
return true;
}
}
return false; return false;
} }
@Override
public StonySilenceCantActivateEffect copy() {
return new StonySilenceCantActivateEffect(this);
}
} }

View file

@ -32,8 +32,10 @@ import java.util.UUID;
import mage.constants.*; import mage.constants.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.CantActivateAbilitiesAttachedEffect;
import mage.abilities.effects.common.SkipEnchantedUntapEffect; import mage.abilities.effects.common.SkipEnchantedUntapEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -74,8 +76,10 @@ public class Encrust extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Enchanted permanent doesn't untap during its controller's untap step and its activated abilities can't be activated. // Enchanted permanent doesn't untap during its controller's untap step and its activated abilities can't be activated.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipEnchantedUntapEffect())); ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new SkipEnchantedUntapEffect());
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EncrustEffect())); Effect effect = new CantActivateAbilitiesAttachedEffect();
effect.setText("and its activated abilities can't be activated");
this.addAbility(ability);
} }
public Encrust(final Encrust card) { public Encrust(final Encrust card) {
@ -87,43 +91,3 @@ public class Encrust extends CardImpl {
return new Encrust(this); return new Encrust(this);
} }
} }
class EncrustEffect extends ReplacementEffectImpl {
public EncrustEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Its activated abilities can't be activated";
}
public EncrustEffect(final EncrustEffect effect) {
super(effect);
}
@Override
public EncrustEffect copy() {
return new EncrustEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
Permanent enchantment = game.getPermanent(source.getSourceId());
Permanent enchanted = game.getPermanent(enchantment.getAttachedTo());
if (event.getSourceId().equals(enchanted.getId())) {
return true;
}
}
return false;
}
}

View file

@ -35,7 +35,7 @@ import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.continious.AddCardTypeTargetEffect; import mage.abilities.effects.common.continious.AddCardTypeTargetEffect;
import mage.abilities.effects.common.continious.GainAbilityTargetEffect; import mage.abilities.effects.common.continious.GainAbilityTargetEffect;
import mage.abilities.effects.common.continious.SetCardColorTargetEffect; import mage.abilities.effects.common.continious.SetCardColorTargetEffect;
@ -45,12 +45,10 @@ import mage.abilities.keyword.DefenderAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
@ -83,7 +81,7 @@ public class XathridGorgon extends CardImpl {
effect.setText("and becomes a colorless artifact in addition to its other types"); effect.setText("and becomes a colorless artifact in addition to its other types");
ability.addEffect(effect); ability.addEffect(effect);
ability.addEffect(new SetCardColorTargetEffect(new ObjectColor(), Duration.Custom, "")); ability.addEffect(new SetCardColorTargetEffect(new ObjectColor(), Duration.Custom, ""));
ability.addEffect(new XathridGorgonEffect()); ability.addEffect(new XathridGorgonCantActivateEffect());
this.addAbility(ability); this.addAbility(ability);
} }
@ -98,43 +96,36 @@ public class XathridGorgon extends CardImpl {
} }
} }
class XathridGorgonEffect extends ReplacementEffectImpl { class XathridGorgonCantActivateEffect extends RestrictionEffect {
public XathridGorgonEffect() { public XathridGorgonCantActivateEffect() {
super(Duration.Custom, Outcome.Detriment); super(Duration.Custom);
staticText = "Its activated abilities can't be activated"; staticText = "Its activated abilities can't be activated";
} }
public XathridGorgonEffect(final XathridGorgonEffect effect) { public XathridGorgonCantActivateEffect(final XathridGorgonCantActivateEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public XathridGorgonEffect copy() { public boolean applies(Permanent permanent, Ability source, Game game) {
return new XathridGorgonEffect(this); Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source));
} if (target != null) {
return true;
@Override } else {
public boolean apply(Game game, Ability source) { this.discard();
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType().equals(GameEvent.EventType.ACTIVATE_ABILITY) && event.getSourceId().equals(targetPointer.getFirst(game, source))) {
Permanent target = game.getPermanent(targetPointer.getFirst(game, source));
if (target != null) {
return true;
} else {
this.discard();
}
} }
return false; return false;
} }
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return false;
}
@Override
public XathridGorgonCantActivateEffect copy() {
return new XathridGorgonCantActivateEffect(this);
}
} }

View file

@ -28,18 +28,15 @@
package mage.sets.mirage; package mage.sets.mirage;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
@ -53,7 +50,7 @@ public class CursedTotem extends CardImpl {
this.expansionSetCode = "MIR"; this.expansionSetCode = "MIR";
// Activated abilities of creatures can't be activated. // Activated abilities of creatures can't be activated.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CursedTotemEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CursedTotemCantActivateEffect()));
} }
public CursedTotem(final CursedTotem card) { public CursedTotem(final CursedTotem card) {
@ -66,41 +63,30 @@ public class CursedTotem extends CardImpl {
} }
} }
class CursedTotemEffect extends ReplacementEffectImpl { class CursedTotemCantActivateEffect extends RestrictionEffect {
public CursedTotemEffect() { public CursedTotemCantActivateEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield);
staticText = "Activated abilities of creatures can't be activated"; staticText = "Activated abilities of creatures can't be activated";
} }
public CursedTotemEffect(final CursedTotemEffect effect) { public CursedTotemCantActivateEffect(final CursedTotemCantActivateEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean applies(Permanent permanent, Ability source, Game game) {
return true; return permanent.getCardType().contains(CardType.CREATURE);
} }
@Override @Override
public CursedTotemEffect copy() { public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return new CursedTotemEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.ACTIVATE_ABILITY) {
Permanent creature = game.getPermanent(event.getSourceId());
if (creature != null && creature.getCardType().contains(CardType.CREATURE)) {
return true;
}
}
return false; return false;
} }
@Override
public CursedTotemCantActivateEffect copy() {
return new CursedTotemCantActivateEffect(this);
}
} }

View file

@ -39,6 +39,7 @@ import mage.abilities.effects.common.AttachEffect;
import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffect; import mage.abilities.effects.common.combat.CantBlockAttackActivateAttachedEffect;
import mage.abilities.keyword.EnchantAbility; import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.target.TargetPermanent; import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;

View file

@ -148,7 +148,7 @@ class PhyrexianRevokerEffect2 extends ContinuousRuleModifiyingEffectImpl {
public String getInfoMessage(Ability source, GameEvent event, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
MageObject mageObject = game.getObject(source.getSourceId()); MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) { if (mageObject != null) {
return "You can't activate sources with that name (" + mageObject.getLogName() + " in play)."; return "You can't activate abilities of sources with that name (" + mageObject.getLogName() + " in play).";
} }
return null; return null;
} }

View file

@ -34,7 +34,6 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost; import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;

View file

@ -37,7 +37,6 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
@ -45,6 +44,7 @@ import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.util.CardUtil; import mage.util.CardUtil;
@ -71,7 +71,7 @@ public class VoidstoneGargoyle extends CardImpl {
// The named card can't be cast. // The named card can't be cast.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect1())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect1()));
// Activated abilities of sources with the chosen name can't be activated. // Activated abilities of sources with the chosen name can't be activated.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleReplacementEffect2())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new VoidstoneGargoyleRuleModifyingEffect2()));
} }
public VoidstoneGargoyle(final VoidstoneGargoyle card) { public VoidstoneGargoyle(final VoidstoneGargoyle card) {
@ -167,14 +167,14 @@ class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifiyingEffect
} }
class VoidstoneGargoyleReplacementEffect2 extends ReplacementEffectImpl { class VoidstoneGargoyleRuleModifyingEffect2 extends ContinuousRuleModifiyingEffectImpl {
public VoidstoneGargoyleReplacementEffect2() { public VoidstoneGargoyleRuleModifyingEffect2() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield, Outcome.Detriment);
staticText = "Activated abilities of sources with the chosen name can't be activated."; staticText = "Activated abilities of sources with the chosen name can't be activated";
} }
public VoidstoneGargoyleReplacementEffect2(final VoidstoneGargoyleReplacementEffect2 effect) { public VoidstoneGargoyleRuleModifyingEffect2(final VoidstoneGargoyleRuleModifyingEffect2 effect) {
super(effect); super(effect);
} }
@ -184,18 +184,22 @@ class VoidstoneGargoyleReplacementEffect2 extends ReplacementEffectImpl {
} }
@Override @Override
public VoidstoneGargoyleReplacementEffect2 copy() { public VoidstoneGargoyleRuleModifyingEffect2 copy() {
return new VoidstoneGargoyleReplacementEffect2(this); return new VoidstoneGargoyleRuleModifyingEffect2(this);
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
return true; MageObject mageObject = game.getObject(source.getSourceId());
if (mageObject != null) {
return "You can't activate abilities of sources with that name (" + mageObject.getLogName() + " in play).";
}
return null;
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { if (event.getType() == EventType.ACTIVATE_ABILITY) {
MageObject object = game.getObject(event.getSourceId()); MageObject object = game.getObject(event.getSourceId());
if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) { if (object != null && object.getName().equals(game.getState().getValue(source.getSourceId().toString()))) {
return true; return true;

View file

@ -29,23 +29,19 @@
package mage.sets.riseoftheeldrazi; package mage.sets.riseoftheeldrazi;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
* *
* @author Loki * @author Loki
@ -60,8 +56,10 @@ public class LinvalaKeeperOfSilence extends CardImpl {
this.color.setWhite(true); this.color.setWhite(true);
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(4); this.toughness = new MageInt(4);
this.addAbility(FlyingAbility.getInstance()); this.addAbility(FlyingAbility.getInstance());
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LinvalaKeeperOfSilenceEffect()));
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new LinvalaKeeperOfSilenceCantActivateEffect()));
} }
public LinvalaKeeperOfSilence (final LinvalaKeeperOfSilence card) { public LinvalaKeeperOfSilence (final LinvalaKeeperOfSilence card) {
@ -74,39 +72,30 @@ public class LinvalaKeeperOfSilence extends CardImpl {
} }
} }
class LinvalaKeeperOfSilenceEffect extends ReplacementEffectImpl { class LinvalaKeeperOfSilenceCantActivateEffect extends RestrictionEffect {
LinvalaKeeperOfSilenceEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); public LinvalaKeeperOfSilenceCantActivateEffect() {
super(Duration.WhileOnBattlefield);
staticText = "Activated abilities of creatures your opponents control can't be activated"; staticText = "Activated abilities of creatures your opponents control can't be activated";
} }
LinvalaKeeperOfSilenceEffect(final LinvalaKeeperOfSilenceEffect effect) { public LinvalaKeeperOfSilenceCantActivateEffect(final LinvalaKeeperOfSilenceCantActivateEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean applies(Permanent permanent, Ability source, Game game) {
return true; return permanent.getCardType().contains(CardType.CREATURE) && game.getOpponents(source.getControllerId()).contains(permanent.getControllerId());
} }
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
Permanent p = game.getPermanent(event.getSourceId());
if ( event.getType() == GameEvent.EventType.ACTIVATE_ABILITY && game.getOpponents(source.getControllerId()).contains(event.getPlayerId())
&& p != null && p.getCardType().contains(CardType.CREATURE)) {
return true;
}
return false; return false;
} }
@Override @Override
public boolean apply(Game game, Ability source) { public LinvalaKeeperOfSilenceCantActivateEffect copy() {
return true; return new LinvalaKeeperOfSilenceCantActivateEffect(this);
}
@Override
public LinvalaKeeperOfSilenceEffect copy() {
return new LinvalaKeeperOfSilenceEffect(this);
} }
} }

View file

@ -28,18 +28,22 @@
package mage.sets.saviorsofkamigawa; package mage.sets.saviorsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.constants.*;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository; import mage.cards.repository.CardRepository;
import mage.choices.Choice; import mage.choices.Choice;
import mage.choices.ChoiceImpl; import mage.choices.ChoiceImpl;
import mage.constants.AbilityType;
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.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.players.Player; import mage.players.Player;
@ -108,7 +112,7 @@ class NameCard extends OneShotEffect {
} }
class PithingNeedleEffect extends ReplacementEffectImpl { class PithingNeedleEffect extends ContinuousRuleModifiyingEffectImpl {
public PithingNeedleEffect() { public PithingNeedleEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -129,11 +133,6 @@ class PithingNeedleEffect extends ReplacementEffectImpl {
return true; return true;
} }
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) { if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {

View file

@ -35,7 +35,6 @@ import mage.abilities.common.CantCounterAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;

View file

@ -32,7 +32,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BecomesMonstrousSourceTriggeredAbility; import mage.abilities.common.BecomesMonstrousSourceTriggeredAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.TapTargetEffect; import mage.abilities.effects.common.TapTargetEffect;
import mage.abilities.keyword.MonstrosityAbility; import mage.abilities.keyword.MonstrosityAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;

View file

@ -33,7 +33,6 @@ import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility; import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.ExileSourceEffect; import mage.abilities.effects.common.ExileSourceEffect;
import mage.abilities.effects.common.ReturnToHandFromGraveyardAllEffect; import mage.abilities.effects.common.ReturnToHandFromGraveyardAllEffect;
import mage.abilities.effects.common.combat.CantBeBlockedByOneEffect; import mage.abilities.effects.common.combat.CantBeBlockedByOneEffect;

View file

@ -37,7 +37,6 @@ import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.VigilanceAbility; import mage.abilities.keyword.VigilanceAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;

View file

@ -34,7 +34,6 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlashAbility; import mage.abilities.keyword.FlashAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;

View file

@ -28,17 +28,17 @@
package mage.sets.timespiral; package mage.sets.timespiral;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.RestrictionEffect;
import mage.abilities.keyword.SplitSecondAbility;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.SplitSecondAbility;
import mage.cards.CardImpl;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.permanent.Permanent;
import mage.game.stack.StackObject; import mage.game.stack.StackObject;
import mage.target.common.TargetActivatedOrTriggeredAbility; import mage.target.common.TargetActivatedOrTriggeredAbility;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
@ -93,7 +93,7 @@ class TrickbindCounterEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget()); StackObject stackObject = game.getStack().getStackObject(source.getFirstTarget());
if(stackObject != null && game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) { if(stackObject != null && game.getStack().counter(source.getFirstTarget(), source.getSourceId(), game)) {
TrickbindReplacementEffect effect = new TrickbindReplacementEffect(); TrickbindCantActivateEffect effect = new TrickbindCantActivateEffect();
effect.setTargetPointer(new FixedTarget(stackObject.getSourceId())); effect.setTargetPointer(new FixedTarget(stackObject.getSourceId()));
game.getContinuousEffects().addEffect(effect, source); game.getContinuousEffects().addEffect(effect, source);
return true; return true;
@ -103,39 +103,33 @@ class TrickbindCounterEffect extends OneShotEffect {
} }
class TrickbindReplacementEffect extends ReplacementEffectImpl { class TrickbindCantActivateEffect extends RestrictionEffect {
public TrickbindReplacementEffect() { public TrickbindCantActivateEffect() {
super(Duration.EndOfTurn, Outcome.LoseAbility); super(Duration.EndOfTurn);
staticText = "Activated abilities of that permanent can't be activated this turn"; staticText = "Activated abilities of that permanent can't be activated this turn";
} }
public TrickbindReplacementEffect(final TrickbindReplacementEffect effect) { public TrickbindCantActivateEffect(final TrickbindCantActivateEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public TrickbindReplacementEffect copy() { public boolean applies(Permanent permanent, Ability source, Game game) {
return new TrickbindReplacementEffect(this); if (getTargetPointer().getFirst(game, source).equals(permanent.getId())) {
} return true;
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
if (this.targetPointer.getFirst(game, source).equals(event.getSourceId())) {
return true;
}
} }
return false; return false;
} }
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return false;
}
@Override
public TrickbindCantActivateEffect copy() {
return new TrickbindCantActivateEffect(this);
}
} }

View file

@ -30,15 +30,13 @@ package mage.sets.weatherlight;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
@ -52,7 +50,7 @@ public class NullRod extends CardImpl {
this.expansionSetCode = "WTH"; this.expansionSetCode = "WTH";
// Activated abilities of artifacts can't be activated. // Activated abilities of artifacts can't be activated.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new CantActivateAbilitiesEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new NullRodCantActivateEffect()));
} }
public NullRod(final NullRod card) { public NullRod(final NullRod card) {
@ -65,40 +63,30 @@ public class NullRod extends CardImpl {
} }
} }
class CantActivateAbilitiesEffect extends ReplacementEffectImpl { class NullRodCantActivateEffect extends RestrictionEffect {
public CantActivateAbilitiesEffect() { public NullRodCantActivateEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield);
staticText = "Activated abilities of artifacts can't be activated."; staticText = "Activated abilities of artifacts can't be activated";
} }
public CantActivateAbilitiesEffect(final CantActivateAbilitiesEffect effect) { public NullRodCantActivateEffect(final NullRodCantActivateEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public CantActivateAbilitiesEffect copy() { public boolean applies(Permanent permanent, Ability source, Game game) {
return new CantActivateAbilitiesEffect(this); return permanent.getCardType().contains(CardType.ARTIFACT);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent.getCardType().contains(CardType.ARTIFACT)) {
return true;
}
}
return false; return false;
} }
@Override
public NullRodCantActivateEffect copy() {
return new NullRodCantActivateEffect(this);
}
} }

View file

@ -33,19 +33,17 @@ import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect; import mage.abilities.effects.common.SacrificeSourceUnlessPaysEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
@ -79,38 +77,25 @@ public class Peacekeeper extends CardImpl {
} }
} }
class PeacekeeperCantAttackEffect extends ReplacementEffectImpl { class PeacekeeperCantAttackEffect extends RestrictionEffect {
private static final String effectText = "Creatures can't attack"; public PeacekeeperCantAttackEffect() {
super(Duration.WhileOnBattlefield);
PeacekeeperCantAttackEffect ( ) { staticText = "Creatures can't attack";
super(Duration.WhileOnBattlefield, Outcome.Benefit);
staticText = effectText;
} }
PeacekeeperCantAttackEffect (final PeacekeeperCantAttackEffect effect ) { public PeacekeeperCantAttackEffect(final PeacekeeperCantAttackEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean applies(Permanent permanent, Ability source, Game game) {
throw new UnsupportedOperationException("Not supported."); return permanent.getCardType().contains(CardType.CREATURE);
} }
@Override @Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) { public boolean canAttack(Game game) {
Player atackingPlayer = game.getPlayer(event.getPlayerId()); return false;
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null && atackingPlayer != null) {
game.informPlayer(atackingPlayer, new StringBuilder(sourcePermanent.getName()).append(" prevents you from attacking with this creature.").toString());
}
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
return event.getType() == GameEvent.EventType.DECLARE_ATTACKER;
} }
@Override @Override

View file

@ -36,7 +36,7 @@ import mage.constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.abilities.keyword.TrampleAbility; import mage.abilities.keyword.TrampleAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -73,7 +73,7 @@ public class AbyssalPersecutor extends CardImpl {
} }
} }
class AbyssalPersecutorCannotWinEffect extends ReplacementEffectImpl { class AbyssalPersecutorCannotWinEffect extends ContinuousRuleModifiyingEffectImpl {
AbyssalPersecutorCannotWinEffect() { AbyssalPersecutorCannotWinEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -93,16 +93,6 @@ class AbyssalPersecutorCannotWinEffect extends ReplacementEffectImpl {
return false; return false;
} }
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override @Override
public AbyssalPersecutorCannotWinEffect copy() { public AbyssalPersecutorCannotWinEffect copy() {
return new AbyssalPersecutorCannotWinEffect(this); return new AbyssalPersecutorCannotWinEffect(this);

View file

@ -80,7 +80,7 @@ public class OmnathLocusOfMana extends CardImpl {
class OmnathReplacementEffect extends ReplacementEffectImpl { class OmnathReplacementEffect extends ReplacementEffectImpl {
private static final List<ManaType> manaTypes = new ArrayList<ManaType>(); private static final List<ManaType> manaTypes = new ArrayList<>();
static { static {
manaTypes.add(ManaType.BLACK); manaTypes.add(ManaType.BLACK);
manaTypes.add(ManaType.BLUE); manaTypes.add(ManaType.BLUE);

View file

@ -35,14 +35,17 @@ import mage.ObjectColor;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.costs.AlternativeCostImpl; import mage.abilities.costs.AlternativeCostImpl;
import mage.abilities.costs.mana.ColoredManaCost; import mage.abilities.costs.mana.ColoredManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.effects.common.SkipNextUntapTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.*; import mage.constants.*;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget;
import mage.watchers.Watcher; import mage.watchers.Watcher;
/** /**
@ -158,11 +161,13 @@ class PermafrostTrapEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
for (UUID target : this.targetPointer.getTargets(game, source)) { for (UUID targetId : this.targetPointer.getTargets(game, source)) {
Permanent creature = game.getPermanent(target); Permanent creature = game.getPermanent(targetId);
if (creature != null) { if (creature != null) {
creature.tap(game); creature.tap(game);
game.addEffect(new PermafrostEffect2(creature.getId()), source); SkipNextUntapTargetEffect effect = new SkipNextUntapTargetEffect();
effect.setTargetPointer(new FixedTarget(targetId));
game.addEffect(effect, source);
} }
} }
return false; return false;
@ -173,44 +178,3 @@ class PermafrostTrapEffect extends OneShotEffect {
return new PermafrostTrapEffect(this); return new PermafrostTrapEffect(this);
} }
} }
class PermafrostEffect2 extends ReplacementEffectImpl {
protected UUID creatureId;
public PermafrostEffect2(UUID creatureId) {
super(Duration.OneUse, Outcome.Detriment);
this.creatureId = creatureId;
}
public PermafrostEffect2(final PermafrostEffect2 effect) {
super(effect);
creatureId = effect.creatureId;
}
@Override
public PermafrostEffect2 copy() {
return new PermafrostEffect2(this);
}
@Override
public boolean apply(Game game, Ability source) {
return false;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
used = true;
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (game.getTurn().getStepType() == PhaseStep.UNTAP
&& event.getType() == GameEvent.EventType.UNTAP
&& event.getTargetId().equals(creatureId)) {
return true;
}
return false;
}
}

View file

@ -137,7 +137,7 @@ class WrexialEffect extends OneShotEffect {
class WrexialReplacementEffect extends ReplacementEffectImpl { class WrexialReplacementEffect extends ReplacementEffectImpl {
private UUID cardid; private final UUID cardid;
public WrexialReplacementEffect(UUID cardid) { public WrexialReplacementEffect(UUID cardid) {
super(Duration.EndOfTurn, Outcome.Exile); super(Duration.EndOfTurn, Outcome.Exile);

View file

@ -28,8 +28,6 @@
package mage.sets.zendikar; package mage.sets.zendikar;
import java.util.UUID; import java.util.UUID;
import mage.constants.*;
import mage.MageInt; import mage.MageInt;
import mage.MageObject; import mage.MageObject;
import mage.ObjectColor; import mage.ObjectColor;
@ -38,11 +36,15 @@ import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.choices.ChoiceColor; import mage.choices.ChoiceColor;
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.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;

View file

@ -78,6 +78,11 @@ public abstract class ContinuousRuleModifiyingEffectImpl extends ContinuousEffec
this.messageToGameLog = effect.messageToGameLog; this.messageToGameLog = effect.messageToGameLog;
} }
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override @Override
public String getInfoMessage(Ability source, GameEvent event, Game game) { public String getInfoMessage(Ability source, GameEvent event, Game game) {
if (infoMessage == null) { if (infoMessage == null) {

View file

@ -28,25 +28,26 @@
package mage.abilities.effects.common.combat; package mage.abilities.effects.common.combat;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome;
import mage.filter.FilterPermanent; import mage.filter.FilterPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.permanent.Permanent;
import mage.players.Player;
/** /**
* *
* @author LevelX2 * @author LevelX2
*/ */
public class CantAttackUnlessDefenderControllsPermanent extends ReplacementEffectImpl { public class CantAttackUnlessDefenderControllsPermanent extends RestrictionEffect {
private final FilterPermanent filter; private final FilterPermanent filter;
public CantAttackUnlessDefenderControllsPermanent(FilterPermanent filter) { public CantAttackUnlessDefenderControllsPermanent(FilterPermanent filter) {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield);
this.filter = filter; this.filter = filter;
staticText = new StringBuilder("{this} can't attack unless defending player controls ").append(filter.getMessage()).toString(); staticText = new StringBuilder("{this} can't attack unless defending player controls ").append(filter.getMessage()).toString();
} }
@ -56,28 +57,37 @@ public class CantAttackUnlessDefenderControllsPermanent extends ReplacementEffec
this.filter = effect.filter; this.filter = effect.filter;
} }
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
return permanent.getId().equals(source.getSourceId());
}
@Override
public boolean canAttack(Game game) {
return false;
}
@Override
public boolean canAttack(UUID defenderId, Ability source, Game game) {
UUID defendingPlayerId = null;
Player player = game.getPlayer(defenderId);
if (player == null) {
Permanent permanent = game.getPermanent(defenderId);
if (permanent != null) {
defendingPlayerId = permanent.getControllerId();
}
} else {
defendingPlayerId = defenderId;
}
if (defendingPlayerId != null && game.getBattlefield().countAll(filter, defendingPlayerId, game) == 0) {
return true;
}
return true;
}
@Override @Override
public CantAttackUnlessDefenderControllsPermanent copy() { public CantAttackUnlessDefenderControllsPermanent copy() {
return new CantAttackUnlessDefenderControllsPermanent(this); return new CantAttackUnlessDefenderControllsPermanent(this);
} }
@Override
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER && source.getSourceId().equals(event.getSourceId())) {
if (game.getBattlefield().countAll(filter, event.getTargetId(), game) == 0) {
return true;
}
}
return false;
}
} }

View file

@ -27,23 +27,20 @@
*/ */
package mage.abilities.effects.common.combat; package mage.abilities.effects.common.combat;
import mage.constants.Outcome;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.constants.Duration; import mage.constants.Duration;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
* *
* @author LevelX2 * @author LevelX2
*/ */
public class CantBlockAttackActivateAttachedEffect extends RestrictionEffect {
public class CantBlockAttackActivateAttachedEffect extends ReplacementEffectImpl {
public CantBlockAttackActivateAttachedEffect() { public CantBlockAttackActivateAttachedEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield);
staticText = "Enchanted creature can't attack or block, and its activated abilities can't be activated"; staticText = "Enchanted creature can't attack or block, and its activated abilities can't be activated";
} }
@ -52,30 +49,34 @@ public class CantBlockAttackActivateAttachedEffect extends ReplacementEffectImpl
} }
@Override @Override
public CantBlockAttackActivateAttachedEffect copy() { public boolean applies(Permanent permanent, Ability source, Game game) {
return new CantBlockAttackActivateAttachedEffect(this); Permanent enchantment = game.getPermanent(source.getSourceId());
} if (enchantment != null && enchantment.getAttachedTo() != null) {
if (permanent.getId().equals(enchantment.getAttachedTo())) {
@Override return true;
public boolean apply(Game game, Ability source) {
return true;
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == GameEvent.EventType.DECLARE_ATTACKER || event.getType() == GameEvent.EventType.DECLARE_BLOCKER || event.getType() == GameEvent.EventType.ACTIVATE_ABILITY) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null) {
if (event.getSourceId().equals(enchantment.getAttachedTo())) {
return true;
}
} }
} }
return false; return false;
} }
@Override
public boolean canAttack(Game game) {
return false;
}
@Override
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game) {
return false;
}
@Override
public boolean canUseActivatedAbilities(Permanent permanent, Ability source, Game game) {
return false;
}
@Override
public CantBlockAttackActivateAttachedEffect copy() {
return new CantBlockAttackActivateAttachedEffect(this);
}
} }

View file

@ -28,18 +28,15 @@
package mage.abilities.effects.common.continious; package mage.abilities.effects.common.continious;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifiyingEffectImpl;
import mage.abilities.effects.ReplacementEffectImpl;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.TargetController; import mage.constants.TargetController;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.watchers.common.CastSpellLastTurnWatcher; import mage.watchers.common.CastSpellLastTurnWatcher;
/** /**