[M21] Fix Enthralling Hold (#6745)

This commit is contained in:
htrajan 2020-06-28 23:06:29 -07:00 committed by GitHub
parent c6e5f3a1c8
commit 4652ebd790
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 15 deletions

View file

@ -1,7 +1,6 @@
package mage.cards.d;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.common.AttachEffect;
@ -10,13 +9,15 @@ import mage.abilities.keyword.EnchantAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.SubType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import java.util.UUID;
/**
*
* @author maxlebedev
@ -52,10 +53,20 @@ public final class DreamLeash extends CardImpl {
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)){
if (super.canTarget(controllerId, id, source, game)) {
Permanent permanent = game.getPermanent(id);
return permanent.isTapped();
}

View file

@ -12,9 +12,8 @@ import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SubType;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.TappedPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent;
@ -26,26 +25,19 @@ import java.util.UUID;
*/
public final class EnthrallingHold extends CardImpl {
private static final FilterPermanent filter = new FilterCreaturePermanent();
static {
filter.add(TappedPredicate.instance);
}
public EnthrallingHold(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{U}{U}");
this.subtype.add(SubType.AURA);
// Enchant creature
TargetPermanent auraTarget = new TargetCreaturePermanent();
TargetPermanent auraTarget = new EnthrallingHoldTarget();
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.
auraTarget.replaceFilter(filter);
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));
@ -62,3 +54,27 @@ public final class EnthrallingHold extends CardImpl {
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;
}
}