mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
Fix #9709
This commit is contained in:
parent
c9117a4f39
commit
414613623a
12 changed files with 77 additions and 110 deletions
|
@ -1,19 +1,19 @@
|
||||||
|
|
||||||
package mage.cards.b;
|
package mage.cards.b;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
import mage.abilities.common.LimitedTimesPerTurnActivatedAbility;
|
||||||
import mage.abilities.common.SimpleStaticAbility;
|
import mage.abilities.common.SimpleStaticAbility;
|
||||||
import mage.abilities.costs.common.SacrificeTargetCost;
|
import mage.abilities.costs.common.SacrificeTargetCost;
|
||||||
import mage.abilities.effects.Effect;
|
import mage.abilities.effects.RestrictionEffect;
|
||||||
import mage.abilities.effects.common.AttachEffect;
|
import mage.abilities.effects.common.AttachEffect;
|
||||||
import mage.abilities.effects.common.CantAttackBlockTransformAttachedEffect;
|
|
||||||
import mage.abilities.keyword.EnchantAbility;
|
import mage.abilities.keyword.EnchantAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.*;
|
||||||
import mage.filter.common.FilterControlledPermanent;
|
import mage.filter.common.FilterControlledPermanent;
|
||||||
import mage.filter.predicate.mageobject.AnotherPredicate;
|
import mage.filter.predicate.mageobject.AnotherPredicate;
|
||||||
|
import mage.game.Game;
|
||||||
|
import mage.game.permanent.Permanent;
|
||||||
import mage.target.TargetPermanent;
|
import mage.target.TargetPermanent;
|
||||||
import mage.target.common.TargetControlledPermanent;
|
import mage.target.common.TargetControlledPermanent;
|
||||||
import mage.target.common.TargetCreaturePermanent;
|
import mage.target.common.TargetCreaturePermanent;
|
||||||
|
@ -43,10 +43,8 @@ public final class BoundByMoonsilver extends CardImpl {
|
||||||
Ability ability = new EnchantAbility(auraTarget);
|
Ability ability = new EnchantAbility(auraTarget);
|
||||||
this.addAbility(ability);
|
this.addAbility(ability);
|
||||||
|
|
||||||
// Enchanted permanent can't attack, block, or transform.
|
// Enchanted creature can't attack, block, or transform.
|
||||||
Effect effect = new CantAttackBlockTransformAttachedEffect();
|
this.addAbility(new SimpleStaticAbility(new BoundByMoonsilverEffect()));
|
||||||
effect.setText("Enchanted creature can't attack, block, or transform.");
|
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, effect));
|
|
||||||
|
|
||||||
// Sacrifice another permanent: Attach Bound by Moonsilver to target creature. Activate this ability only any time you could cast a sorcery and only once each turn.
|
// Sacrifice another permanent: Attach Bound by Moonsilver to target creature. Activate this ability only any time you could cast a sorcery and only once each turn.
|
||||||
LimitedTimesPerTurnActivatedAbility limitedAbility = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "Attach {this} to target creature"),
|
LimitedTimesPerTurnActivatedAbility limitedAbility = new LimitedTimesPerTurnActivatedAbility(Zone.BATTLEFIELD, new AttachEffect(Outcome.Detriment, "Attach {this} to target creature"),
|
||||||
|
@ -65,3 +63,40 @@ public final class BoundByMoonsilver extends CardImpl {
|
||||||
return new BoundByMoonsilver(this);
|
return new BoundByMoonsilver(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class BoundByMoonsilverEffect extends RestrictionEffect {
|
||||||
|
|
||||||
|
public BoundByMoonsilverEffect() {
|
||||||
|
super(Duration.WhileOnBattlefield);
|
||||||
|
staticText = "enchanted creature can't attack, block, or transform";
|
||||||
|
}
|
||||||
|
|
||||||
|
private BoundByMoonsilverEffect(final BoundByMoonsilverEffect effect) {
|
||||||
|
super(effect);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BoundByMoonsilverEffect copy() {
|
||||||
|
return new BoundByMoonsilverEffect(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canTransform(Game game, boolean canUseChooseDialogs) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,21 +1,21 @@
|
||||||
|
|
||||||
package mage.cards.i;
|
package mage.cards.i;
|
||||||
|
|
||||||
import java.util.UUID;
|
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.ContinuousRuleModifyingEffectImpl;
|
import mage.abilities.effects.RestrictionEffect;
|
||||||
import mage.abilities.effects.common.continuous.BoostControlledEffect;
|
import mage.abilities.effects.common.continuous.BoostControlledEffect;
|
||||||
import mage.abilities.keyword.IntimidateAbility;
|
import mage.abilities.keyword.IntimidateAbility;
|
||||||
import mage.cards.CardImpl;
|
import mage.cards.CardImpl;
|
||||||
import mage.cards.CardSetInfo;
|
import mage.cards.CardSetInfo;
|
||||||
import mage.constants.*;
|
import mage.constants.CardType;
|
||||||
|
import mage.constants.Duration;
|
||||||
|
import mage.constants.SubType;
|
||||||
|
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||||
import mage.filter.common.FilterCreaturePermanent;
|
import mage.filter.common.FilterCreaturePermanent;
|
||||||
import mage.filter.predicate.Predicates;
|
import mage.filter.predicate.Predicates;
|
||||||
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;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,10 +40,10 @@ public final class Immerwolf extends CardImpl {
|
||||||
this.addAbility(IntimidateAbility.getInstance());
|
this.addAbility(IntimidateAbility.getInstance());
|
||||||
|
|
||||||
// Other Wolf and Werewolf creatures you control get +1/+1.
|
// Other Wolf and Werewolf creatures you control get +1/+1.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
|
this.addAbility(new SimpleStaticAbility(new BoostControlledEffect(1, 1, Duration.WhileOnBattlefield, filter, true)));
|
||||||
|
|
||||||
// Non-Human Werewolves you control can't transform.
|
// Non-Human Werewolves you control can't transform.
|
||||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ImmerwolfEffect()));
|
this.addAbility(new SimpleStaticAbility(new ImmerwolfEffect()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,21 +57,20 @@ public final class Immerwolf extends CardImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImmerwolfEffect extends ContinuousRuleModifyingEffectImpl {
|
class ImmerwolfEffect extends RestrictionEffect {
|
||||||
|
|
||||||
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent(SubType.WEREWOLF);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
filter.add(SubType.WEREWOLF.getPredicate());
|
|
||||||
filter.add(Predicates.not(SubType.HUMAN.getPredicate()));
|
filter.add(Predicates.not(SubType.HUMAN.getPredicate()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmerwolfEffect() {
|
public ImmerwolfEffect() {
|
||||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
super(Duration.WhileOnBattlefield);
|
||||||
staticText = "Non-Human Werewolves you control can't transform";
|
staticText = "Non-Human Werewolves you control can't transform";
|
||||||
}
|
}
|
||||||
|
|
||||||
public ImmerwolfEffect(final ImmerwolfEffect effect) {
|
private ImmerwolfEffect(final ImmerwolfEffect effect) {
|
||||||
super(effect);
|
super(effect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,15 +80,12 @@ class ImmerwolfEffect extends ContinuousRuleModifyingEffectImpl {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checksEventType(GameEvent event, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
return event.getType() == GameEvent.EventType.TRANSFORM;
|
return filter.match(permanent, source.getControllerId(), source, game);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
public boolean canTransform(Game game, boolean canUseChooseDialogs) {
|
||||||
Permanent permanent = game.getPermanent(event.getTargetId());
|
return false;
|
||||||
return permanent != null &&
|
|
||||||
permanent.isControlledBy(source.getControllerId()) &&
|
|
||||||
filter.match(permanent, game) ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,8 +98,7 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canTransform(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
|
public boolean canTransform(Game game, boolean canUseChooseDialogs) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,52 +0,0 @@
|
||||||
package mage.abilities.effects.common;
|
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
|
||||||
import mage.abilities.effects.RestrictionEffect;
|
|
||||||
import mage.constants.Duration;
|
|
||||||
import mage.game.Game;
|
|
||||||
import mage.game.permanent.Permanent;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author halljared
|
|
||||||
*/
|
|
||||||
public class CantAttackBlockTransformAttachedEffect extends RestrictionEffect {
|
|
||||||
|
|
||||||
public CantAttackBlockTransformAttachedEffect() {
|
|
||||||
super(Duration.WhileOnBattlefield);
|
|
||||||
staticText = "Enchanted creature can't attack, block, or transform.";
|
|
||||||
}
|
|
||||||
|
|
||||||
public CantAttackBlockTransformAttachedEffect(final CantAttackBlockTransformAttachedEffect effect) {
|
|
||||||
super(effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
|
||||||
return permanent.getId().equals(enchantment.getAttachedTo());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canAttack(Game game, boolean canUseChooseDialogs) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canBlock(Permanent attacker, Permanent blocker, Ability source, Game game, boolean canUseChooseDialogs) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canTransform(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CantAttackBlockTransformAttachedEffect copy() {
|
|
||||||
return new CantAttackBlockTransformAttachedEffect(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
package mage.abilities.effects.common.combat;
|
package mage.abilities.effects.common.combat;
|
||||||
|
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -32,9 +30,7 @@ public class AttacksIfAbleAttachedEffect extends RequirementEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
return attachment != null && attachment.getAttachedTo() != null
|
|
||||||
&& permanent.getId().equals(attachment.getAttachedTo());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -29,9 +29,7 @@ public class BlocksIfAbleAttachedEffect extends RequirementEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
return attachment != null && attachment.getAttachedTo() != null
|
|
||||||
&& permanent.getId().equals(attachment.getAttachedTo());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,8 +33,6 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
return attachment != null && attachment.getAttachedTo() != null
|
|
||||||
&& permanent.getId().equals(attachment.getAttachedTo());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,9 +24,7 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
return attachment != null && attachment.getAttachedTo() != null
|
|
||||||
&& permanent.getId().equals(attachment.getAttachedTo());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -33,8 +33,6 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent attachment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
return attachment != null
|
|
||||||
&& attachment.isAttachedTo(permanent.getId());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,11 +22,7 @@ public class CantBlockActivateAttachedEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
|
||||||
return permanent.getId().equals(enchantment.getAttachedTo());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -43,5 +39,4 @@ public class CantBlockActivateAttachedEffect extends RestrictionEffect {
|
||||||
public CantBlockActivateAttachedEffect copy() {
|
public CantBlockActivateAttachedEffect copy() {
|
||||||
return new CantBlockActivateAttachedEffect(this);
|
return new CantBlockActivateAttachedEffect(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,11 +26,7 @@ public class CantBlockAttackActivateAttachedEffect extends RestrictionEffect {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Permanent permanent, Ability source, Game game) {
|
public boolean applies(Permanent permanent, Ability source, Game game) {
|
||||||
Permanent enchantment = game.getPermanent(source.getSourceId());
|
return permanent.getAttachments().contains(source.getSourceId());
|
||||||
if (enchantment != null && enchantment.getAttachedTo() != null) {
|
|
||||||
return permanent.getId().equals(enchantment.getAttachedTo());
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -303,7 +303,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
if (!entry.getKey().canUseActivatedAbilities(this, ability, game, false)) {
|
if (!entry.getKey().canUseActivatedAbilities(this, ability, game, false)) {
|
||||||
restrictHints.add(HintUtils.prepareText("Can't use activated abilities" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
restrictHints.add(HintUtils.prepareText("Can't use activated abilities" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||||
}
|
}
|
||||||
if (!entry.getKey().canTransform(this, ability, game, false)) {
|
if (!entry.getKey().canTransform(game, false)) {
|
||||||
restrictHints.add(HintUtils.prepareText("Can't transform" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
restrictHints.add(HintUtils.prepareText("Can't transform" + addSourceObjectName(game, ability), null, HintUtils.HINT_ICON_RESTRICT));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -599,6 +599,15 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
|| this.getAbilities().containsClass(NightboundAbility.class);
|
|| this.getAbilities().containsClass(NightboundAbility.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkTransformRestrictionEffects(Game game) {
|
||||||
|
for (Map.Entry<RestrictionEffect, Set<Ability>> entry : game.getContinuousEffects().getApplicableRestrictionEffects(this, game).entrySet()) {
|
||||||
|
if (!entry.getKey().canTransform(game, true)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
private Card getOtherFace() {
|
private Card getOtherFace() {
|
||||||
return transformed ? this.getMainCard() : this.getMainCard().getSecondCardFace();
|
return transformed ? this.getMainCard() : this.getMainCard().getSecondCardFace();
|
||||||
}
|
}
|
||||||
|
@ -608,6 +617,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
||||||
if (!this.isTransformable()
|
if (!this.isTransformable()
|
||||||
|| (!ignoreDayNight && this.checkDayNightBound())
|
|| (!ignoreDayNight && this.checkDayNightBound())
|
||||||
|| this.getOtherFace().isInstantOrSorcery()
|
|| this.getOtherFace().isInstantOrSorcery()
|
||||||
|
|| !this.checkTransformRestrictionEffects(game)
|
||||||
|| (source != null && !source.checkTransformCount(this, game))
|
|| (source != null && !source.checkTransformCount(this, game))
|
||||||
|| this.replaceEvent(EventType.TRANSFORM, game)) {
|
|| this.replaceEvent(EventType.TRANSFORM, game)) {
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue