forked from External/mage
[M21] Fix castability and selectability of EnthrallingHold (#6773)
This commit is contained in:
parent
b6b7a9c0f9
commit
91571df264
3 changed files with 74 additions and 77 deletions
|
|
@ -3,6 +3,7 @@ package mage.cards.d;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.continuous.ControlEnchantedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
|
|
@ -11,11 +12,8 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetTappedPermanentAsYouCast;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -30,15 +28,18 @@ public final class DreamLeash extends CardImpl {
|
|||
this.subtype.add(SubType.AURA);
|
||||
|
||||
// Enchant permanent
|
||||
// You can't choose an untapped permanent as Dream Leash's target as you cast Dream Leash.
|
||||
TargetPermanent auraTarget = new DreamLeashTarget();
|
||||
TargetPermanent auraTarget = new TargetTappedPermanentAsYouCast();
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.GainControl));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
// You can't choose an untapped permanent as Dream Leash's target as you cast Dream Leash.
|
||||
Effect effect = new ControlEnchantedEffect("permanent");
|
||||
effect.setText("You can't choose an untapped permanent as {this}'s target as you cast {this}.<br>" + effect.getText(null));
|
||||
|
||||
// You control enchanted permanent.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new ControlEnchantedEffect("permanent")));
|
||||
this.addAbility(new SimpleStaticAbility(effect));
|
||||
}
|
||||
|
||||
private DreamLeash(final DreamLeash card) {
|
||||
|
|
@ -49,35 +50,4 @@ public final class DreamLeash extends CardImpl {
|
|||
public DreamLeash copy() {
|
||||
return new DreamLeash(this);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class DreamLeashTarget extends TargetPermanent {
|
||||
|
||||
DreamLeashTarget() {}
|
||||
|
||||
private DreamLeashTarget(DreamLeashTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DreamLeashTarget copy() {
|
||||
return new DreamLeashTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent.isTapped();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// See ruling: https://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/253345-dream-leash
|
||||
@Override
|
||||
public boolean stillLegalTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent != null && StaticFilters.FILTER_PERMANENT.match(permanent, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,12 +11,9 @@ import mage.cards.CardSetInfo;
|
|||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.common.TargetTappedPermanentAsYouCast;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
|
@ -32,18 +29,18 @@ public final class EnthrallingHold extends CardImpl {
|
|||
this.subtype.add(SubType.AURA);
|
||||
|
||||
// Enchant creature
|
||||
TargetPermanent auraTarget = new EnthrallingHoldTarget();
|
||||
TargetPermanent auraTarget = new TargetTappedPermanentAsYouCast(StaticFilters.FILTER_PERMANENT_CREATURE);
|
||||
this.getSpellAbility().addTarget(auraTarget);
|
||||
this.getSpellAbility().addEffect(new AttachEffect(Outcome.GainControl));
|
||||
Ability ability = new EnchantAbility(auraTarget.getTargetName());
|
||||
this.addAbility(ability);
|
||||
|
||||
// You can't choose an untapped creature as this spell's target as you cast it.
|
||||
Effect controlEnchantedEffect = new ControlEnchantedEffect();
|
||||
controlEnchantedEffect.setText("You can't choose an untapped creature as this spell's target as you cast it.<br>" + controlEnchantedEffect.getText(null));
|
||||
Effect effect = new ControlEnchantedEffect();
|
||||
effect.setText("You can't choose an untapped creature as this spell's target as you cast it.<br>" + effect.getText(null));
|
||||
|
||||
// You control enchanted creature.
|
||||
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, controlEnchantedEffect));
|
||||
this.addAbility(new SimpleStaticAbility(effect));
|
||||
}
|
||||
|
||||
private EnthrallingHold(final EnthrallingHold card) {
|
||||
|
|
@ -54,34 +51,4 @@ public final class EnthrallingHold extends CardImpl {
|
|||
public EnthrallingHold copy() {
|
||||
return new EnthrallingHold(this);
|
||||
}
|
||||
}
|
||||
|
||||
class EnthrallingHoldTarget extends TargetCreaturePermanent {
|
||||
|
||||
EnthrallingHoldTarget() {}
|
||||
|
||||
private EnthrallingHoldTarget(EnthrallingHoldTarget target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnthrallingHoldTarget copy() {
|
||||
return new EnthrallingHoldTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent.isTapped();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// See ruling: https://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/253345-dream-leash
|
||||
@Override
|
||||
public boolean stillLegalTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent != null && StaticFilters.FILTER_PERMANENT_CREATURE.match(permanent, game);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
package mage.target.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.TargetPermanent;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class TargetTappedPermanentAsYouCast extends TargetPermanent {
|
||||
|
||||
public TargetTappedPermanentAsYouCast() {}
|
||||
|
||||
public TargetTappedPermanentAsYouCast(FilterPermanent filter) {
|
||||
this.filter = filter;
|
||||
this.targetName = filter.getMessage();
|
||||
}
|
||||
|
||||
private TargetTappedPermanentAsYouCast(TargetTappedPermanentAsYouCast target) {
|
||||
super(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TargetTappedPermanentAsYouCast copy() {
|
||||
return new TargetTappedPermanentAsYouCast(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> possibleTargets(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
return game.getBattlefield().getAllActivePermanents(getFilter(), game).stream()
|
||||
.filter(Permanent::isTapped)
|
||||
.map(Permanent::getId)
|
||||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canChoose(UUID sourceId, UUID sourceControllerId, Game game) {
|
||||
return game.getBattlefield().getAllActivePermanents(getFilter(), game).stream()
|
||||
.anyMatch(Permanent::isTapped);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
|
||||
if (super.canTarget(controllerId, id, source, game)) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent != null && permanent.isTapped();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// See ruling: https://www.mtgsalvation.com/forums/magic-fundamentals/magic-rulings/magic-rulings-archives/253345-dream-leash
|
||||
@Override
|
||||
public boolean stillLegalTarget(UUID id, Ability source, Game game) {
|
||||
Permanent permanent = game.getPermanent(id);
|
||||
return permanent != null && getFilter().match(permanent, game);
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue