* Fixed that equipments with restrictions (e.g. Gate Smasher) were not unequipped if the equipped permanent did no longer fulfill the restrictions(fixes #2212).

This commit is contained in:
LevelX2 2016-09-03 15:26:17 +02:00
parent 720a4457fd
commit ab2399cbe7
17 changed files with 234 additions and 59 deletions

View file

@ -1,5 +1,5 @@
/*
*
*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
@ -25,15 +25,15 @@
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*
*
*/
package mage.sets.championsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl;
@ -47,6 +47,7 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil;
@ -56,7 +57,7 @@ import mage.util.CardUtil;
*/
public class KondasBanner extends CardImpl {
private static final FilterControlledCreaturePermanent legendaryFilter = new FilterControlledCreaturePermanent("Legendary creatures");
private static final FilterControlledCreaturePermanent legendaryFilter = new FilterControlledCreaturePermanent("legendary creatures");
static {
legendaryFilter.add(new SupertypePredicate("Legendary"));
@ -68,8 +69,9 @@ public class KondasBanner extends CardImpl {
this.supertype.add("Legendary");
this.subtype.add("Equipment");
Target target = new TargetControlledCreaturePermanent(1, 1, legendaryFilter, false);
// Konda's Banner can be attached only to a legendary creature.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("{this} can be attached only to a legendary creature")));
this.addAbility(new AttachableToRestrictedAbility(target));
// Creatures that share a color with equipped creature get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KondasBannerColorBoostEffect()));
@ -78,10 +80,7 @@ public class KondasBanner extends CardImpl {
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KondasBannerTypeBoostEffect()));
// Equip {2}
this.addAbility(new EquipAbility(
Outcome.AddAbility,
new GenericManaCost(2),
new TargetControlledCreaturePermanent(1, 1, legendaryFilter, false)));
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2), target));
}

View file

@ -229,7 +229,7 @@ class MoveAuraEffect extends OneShotEffect {
}
// Check for protection
MageObject auraObject = game.getObject(auraId);
if (permanentToAttachAuras.cantBeEnchantedBy(auraObject, game)) {
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
passed = false;
}
}

View file

@ -29,10 +29,10 @@ package mage.sets.dragonsoftarkir;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
@ -46,6 +46,7 @@ import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.ToughnessPredicate;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
/**
@ -65,9 +66,10 @@ public class GateSmasher extends CardImpl {
this.expansionSetCode = "DTK";
this.subtype.add("Equipment");
Target target = new TargetControlledCreaturePermanent(1, 1, filter, false);
// Gate Smasher can be attached only to a creature with toughness 4 or greater.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("{this} can be attached only to a creature with toughness 4 or greater")));
this.addAbility(new AttachableToRestrictedAbility(target));
// Equipped creature gets +3/+0 and has trample.
Effect effect = new BoostEquippedEffect(3, 0);
effect.setText("Equipped creature gets +3/+0");
@ -76,13 +78,10 @@ public class GateSmasher extends CardImpl {
effect.setText("and has trample");
ability.addEffect(effect);
this.addAbility(ability);
// Equip {3}
this.addAbility(new EquipAbility(
Outcome.AddAbility,
new GenericManaCost(3),
new TargetControlledCreaturePermanent(1,1, filter, false)));
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3), target));
}
public GateSmasher(final GateSmasher card) {

View file

@ -53,6 +53,7 @@ import mage.target.common.TargetControlledPermanent;
public class AuriokWindwalker extends CardImpl {
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Equipment you control");
static {
filter.add(new SubtypePredicate("Equipment"));
}
@ -67,7 +68,7 @@ public class AuriokWindwalker extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// {tap}: Attach target Equipment you control to target creature you control.
// {T}: Attach target Equipment you control to target creature you control.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AttachTargetEquipmentEffect(), new TapSourceCost());
ability.addTarget(new TargetControlledPermanent(filter));
ability.addTarget(new TargetControlledCreaturePermanent());
@ -84,7 +85,6 @@ public class AuriokWindwalker extends CardImpl {
}
}
class AttachTargetEquipmentEffect extends OneShotEffect {
public AttachTargetEquipmentEffect() {

View file

@ -121,7 +121,7 @@ class NomadMythmakerEffect extends OneShotEffect {
&& controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null
&& !permanent.cantBeEnchantedBy(aura, game)) {
&& !permanent.cantBeAttachedBy(aura, game)) {
game.getState().setValue("attachTo:" + aura.getId(), permanent);
controller.moveCards(aura, Zone.BATTLEFIELD, source, game);
return permanent.addAttachment(aura.getId(), game);

View file

@ -127,7 +127,7 @@ class ReinsOfTheVinesteedEffect extends OneShotEffect {
if (controller != null
&& controller.choose(Outcome.PutCardInPlay, target, source.getSourceId(), game)) {
Permanent targetPermanent = game.getPermanent(target.getFirstTarget());
if (!targetPermanent.cantBeEnchantedBy(aura, game)) {
if (!targetPermanent.cantBeAttachedBy(aura, game)) {
game.getState().setValue("attachTo:" + aura.getId(), targetPermanent);
aura.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), controller.getId());
return targetPermanent.addAttachment(aura.getId(), game);

View file

@ -29,10 +29,10 @@ package mage.sets.saviorsofkamigawa;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility;
@ -46,6 +46,7 @@ import mage.constants.Zone;
import mage.filter.Filter;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent;
/**
@ -65,9 +66,10 @@ public class ONaginata extends CardImpl {
this.expansionSetCode = "SOK";
this.subtype.add("Equipment");
Target target = new TargetControlledCreaturePermanent(1, 1, filter, false);
// O-Naginata can be attached only to a creature with 3 or more power.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new InfoEffect("{this} can be attached only to a creature with 3 or more power")));
this.addAbility(new AttachableToRestrictedAbility(target));
// Equipped creature gets +3/+0 and has trample.
Effect effect = new BoostEquippedEffect(3, 0);
effect.setText("Equipped creature gets +3/+0");
@ -76,12 +78,9 @@ public class ONaginata extends CardImpl {
effect.setText("and has trample");
ability.addEffect(effect);
this.addAbility(ability);
// Equip {2}
this.addAbility(new EquipAbility(
Outcome.AddAbility,
new GenericManaCost(2),
new TargetControlledCreaturePermanent(1,1, filter, false)));
this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2), target));
}
public ONaginata(final ONaginata card) {

View file

@ -143,7 +143,7 @@ class GlamerSpinnersEffect extends OneShotEffect {
}
// Check for protection
MageObject auraObject = game.getObject(auraId);
if (permanentToAttachAuras.cantBeEnchantedBy(auraObject, game)) {
if (permanentToAttachAuras.cantBeAttachedBy(auraObject, game)) {
passed = false;
}
}

View file

@ -110,7 +110,7 @@ class GryffsBoonEffect extends OneShotEffect {
if (aura != null
&& game.getState().getZone(aura.getId()).equals(Zone.GRAVEYARD)) {
Permanent targetPermanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (!targetPermanent.cantBeEnchantedBy(aura, game)) {
if (!targetPermanent.cantBeAttachedBy(aura, game)) {
game.getState().setValue("attachTo:" + aura.getId(), targetPermanent);
aura.putOntoBattlefield(game, Zone.GRAVEYARD, source.getSourceId(), source.getControllerId());
return targetPermanent.addAttachment(aura.getId(), game);