mirror of
https://github.com/magefree/mage.git
synced 2025-12-27 05:52:06 -08:00
Fix #9709
This commit is contained in:
parent
c9117a4f39
commit
414613623a
12 changed files with 77 additions and 110 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
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));
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
|
@ -599,6 +599,15 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
|| 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() {
|
||||
return transformed ? this.getMainCard() : this.getMainCard().getSecondCardFace();
|
||||
}
|
||||
|
|
@ -608,6 +617,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
if (!this.isTransformable()
|
||||
|| (!ignoreDayNight && this.checkDayNightBound())
|
||||
|| this.getOtherFace().isInstantOrSorcery()
|
||||
|| !this.checkTransformRestrictionEffects(game)
|
||||
|| (source != null && !source.checkTransformCount(this, game))
|
||||
|| this.replaceEvent(EventType.TRANSFORM, game)) {
|
||||
return false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue