This commit is contained in:
Alex W. Jackson 2022-10-30 03:17:14 -04:00
parent c9117a4f39
commit 414613623a
12 changed files with 77 additions and 110 deletions

View file

@ -98,8 +98,7 @@ public abstract class RestrictionEffect extends ContinuousEffectImpl {
return true;
}
public boolean canTransform(Permanent permanent, Ability source, Game game, boolean canUseChooseDialogs) {
public boolean canTransform(Game game, boolean canUseChooseDialogs) {
return true;
}
}

View file

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

View file

@ -1,5 +1,3 @@
package mage.abilities.effects.common.combat;
import mage.abilities.Ability;
@ -32,9 +30,7 @@ public class AttacksIfAbleAttachedEffect extends RequirementEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent attachment = game.getPermanent(source.getSourceId());
return attachment != null && attachment.getAttachedTo() != null
&& permanent.getId().equals(attachment.getAttachedTo());
return permanent.getAttachments().contains(source.getSourceId());
}
@Override

View file

@ -29,9 +29,7 @@ public class BlocksIfAbleAttachedEffect extends RequirementEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent attachment = game.getPermanent(source.getSourceId());
return attachment != null && attachment.getAttachedTo() != null
&& permanent.getId().equals(attachment.getAttachedTo());
return permanent.getAttachments().contains(source.getSourceId());
}
@Override

View file

@ -33,8 +33,6 @@ public class CantAttackAloneAttachedEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent attachment = game.getPermanent(source.getSourceId());
return attachment != null && attachment.getAttachedTo() != null
&& permanent.getId().equals(attachment.getAttachedTo());
return permanent.getAttachments().contains(source.getSourceId());
}
}

View file

@ -24,9 +24,7 @@ public class CantAttackBlockAttachedEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent attachment = game.getPermanent(source.getSourceId());
return attachment != null && attachment.getAttachedTo() != null
&& permanent.getId().equals(attachment.getAttachedTo());
return permanent.getAttachments().contains(source.getSourceId());
}
@Override

View file

@ -33,8 +33,6 @@ public class CantBeBlockedAttachedEffect extends RestrictionEffect {
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
Permanent attachment = game.getPermanent(source.getSourceId());
return attachment != null
&& attachment.isAttachedTo(permanent.getId());
return permanent.getAttachments().contains(source.getSourceId());
}
}

View file

@ -22,11 +22,7 @@ public class CantBlockActivateAttachedEffect extends RestrictionEffect {
@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;
return permanent.getAttachments().contains(source.getSourceId());
}
@Override
@ -43,5 +39,4 @@ public class CantBlockActivateAttachedEffect extends RestrictionEffect {
public CantBlockActivateAttachedEffect copy() {
return new CantBlockActivateAttachedEffect(this);
}
}

View file

@ -26,11 +26,7 @@ public class CantBlockAttackActivateAttachedEffect extends RestrictionEffect {
@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;
return permanent.getAttachments().contains(source.getSourceId());
}
@Override