Merge origin/master

This commit is contained in:
Styxo 2016-09-03 22:40:18 +02:00
commit adf95f1db5
22 changed files with 587 additions and 59 deletions

View file

@ -31,9 +31,9 @@ package mage.sets.championsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostAllEffect; import mage.abilities.effects.common.continuous.BoostAllEffect;
import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.EquipAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
@ -47,6 +47,7 @@ import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.SupertypePredicate; import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
import mage.util.CardUtil; import mage.util.CardUtil;
@ -56,7 +57,7 @@ import mage.util.CardUtil;
*/ */
public class KondasBanner extends CardImpl { public class KondasBanner extends CardImpl {
private static final FilterControlledCreaturePermanent legendaryFilter = new FilterControlledCreaturePermanent("Legendary creatures"); private static final FilterControlledCreaturePermanent legendaryFilter = new FilterControlledCreaturePermanent("legendary creatures");
static { static {
legendaryFilter.add(new SupertypePredicate("Legendary")); legendaryFilter.add(new SupertypePredicate("Legendary"));
@ -68,8 +69,9 @@ public class KondasBanner extends CardImpl {
this.supertype.add("Legendary"); this.supertype.add("Legendary");
this.subtype.add("Equipment"); this.subtype.add("Equipment");
Target target = new TargetControlledCreaturePermanent(1, 1, legendaryFilter, false);
// Konda's Banner can be attached only to a legendary creature. // 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. // Creatures that share a color with equipped creature get +1/+1.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KondasBannerColorBoostEffect())); 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())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new KondasBannerTypeBoostEffect()));
// Equip {2} // Equip {2}
this.addAbility(new EquipAbility( this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2), target));
Outcome.AddAbility,
new GenericManaCost(2),
new TargetControlledCreaturePermanent(1, 1, legendaryFilter, false)));
} }

View file

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

View file

@ -29,10 +29,10 @@ package mage.sets.dragonsoftarkir;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.EquipAbility;
@ -46,6 +46,7 @@ import mage.constants.Zone;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.ToughnessPredicate; import mage.filter.predicate.mageobject.ToughnessPredicate;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
/** /**
@ -65,8 +66,9 @@ public class GateSmasher extends CardImpl {
this.expansionSetCode = "DTK"; this.expansionSetCode = "DTK";
this.subtype.add("Equipment"); 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. // 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. // Equipped creature gets +3/+0 and has trample.
Effect effect = new BoostEquippedEffect(3, 0); Effect effect = new BoostEquippedEffect(3, 0);
@ -78,10 +80,7 @@ public class GateSmasher extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Equip {3} // Equip {3}
this.addAbility(new EquipAbility( this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3), target));
Outcome.AddAbility,
new GenericManaCost(3),
new TargetControlledCreaturePermanent(1,1, filter, false)));
} }

View file

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

View file

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

View file

@ -0,0 +1,70 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.legends;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author maxlebedev
*/
public class DwarvenSong extends CardImpl {
public DwarvenSong(UUID ownerId) {
super(ownerId, 141, "Dwarven Song", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{R}");
this.expansionSetCode = "LEG";
// Any number of target creatures become red until end of turn.
Effect effect = new BecomesColorTargetEffect(ObjectColor.RED, Duration.EndOfTurn);
effect.setText("Any number of target creatures become red until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE, new FilterCreaturePermanent(), false));
}
public DwarvenSong(final DwarvenSong card) {
super(card);
}
@Override
public DwarvenSong copy() {
return new DwarvenSong(this);
}
}

View file

@ -0,0 +1,71 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.legends;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author maxlebedev
*/
public class HeavensGate extends CardImpl {
public HeavensGate(UUID ownerId) {
super(ownerId, 188, "Heaven's Gate", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{W}");
this.expansionSetCode = "LEG";
// Any number of target creatures become white until end of turn.
Effect effect = new BecomesColorTargetEffect(ObjectColor.WHITE, Duration.EndOfTurn);
effect.setText("Any number of target creatures become white until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE, new FilterCreaturePermanent(), false));
}
public HeavensGate(final HeavensGate card) {
super(card);
}
@Override
public HeavensGate copy() {
return new HeavensGate(this);
}
}

View file

@ -0,0 +1,71 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.legends;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author maxlebedev
*/
public class SeaKingsBlessing extends CardImpl {
public SeaKingsBlessing(UUID ownerId) {
super(ownerId, 75, "Sea King's Blessing", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{U}");
this.expansionSetCode = "LEG";
// Any number of target creatures become blue until end of turn.
Effect effect = new BecomesColorTargetEffect(ObjectColor.BLUE, Duration.EndOfTurn);
effect.setText("Any number of target creatures become blue until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE, new FilterCreaturePermanent(), false));
}
public SeaKingsBlessing(final SeaKingsBlessing card) {
super(card);
}
@Override
public SeaKingsBlessing copy() {
return new SeaKingsBlessing(this);
}
}

View file

@ -0,0 +1,70 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.legends;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author maxlebedev
*/
public class SylvanParadise extends CardImpl {
public SylvanParadise(UUID ownerId) {
super(ownerId, 122, "Sylvan Paradise", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{G}");
this.expansionSetCode = "LEG";
// Any number of target creatures become green until end of turn.
Effect effect = new BecomesColorTargetEffect(ObjectColor.GREEN, Duration.EndOfTurn);
effect.setText("Any number of target creatures become green until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE, new FilterCreaturePermanent(), false));
}
public SylvanParadise(final SylvanParadise card) {
super(card);
}
@Override
public SylvanParadise copy() {
return new SylvanParadise(this);
}
}

View file

@ -0,0 +1,71 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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.legends;
import java.util.UUID;
import mage.ObjectColor;
import mage.abilities.effects.Effect;
import mage.abilities.effects.common.continuous.BecomesColorTargetEffect;
import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.filter.common.FilterCreaturePermanent;
import mage.target.common.TargetCreaturePermanent;
/**
*
* @author maxlebedev
*/
public class TouchOfDarkness extends CardImpl {
public TouchOfDarkness(UUID ownerId) {
super(ownerId, 36, "Touch of Darkness", Rarity.UNCOMMON, new CardType[]{CardType.INSTANT}, "{B}");
this.expansionSetCode = "LEG";
// Any number of target creatures become black until end of turn.
Effect effect = new BecomesColorTargetEffect(ObjectColor.BLACK, Duration.EndOfTurn);
effect.setText("Any number of target creatures become black until end of turn");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCreaturePermanent(0, Integer.MAX_VALUE, new FilterCreaturePermanent(), false));
}
public TouchOfDarkness(final TouchOfDarkness card) {
super(card);
}
@Override
public TouchOfDarkness copy() {
return new TouchOfDarkness(this);
}
}

View file

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

View file

@ -29,10 +29,10 @@ package mage.sets.saviorsofkamigawa;
import java.util.UUID; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.mana.GenericManaCost; import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.InfoEffect;
import mage.abilities.effects.common.continuous.BoostEquippedEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect;
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
import mage.abilities.keyword.EquipAbility; import mage.abilities.keyword.EquipAbility;
@ -46,6 +46,7 @@ import mage.constants.Zone;
import mage.filter.Filter; import mage.filter.Filter;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.predicate.mageobject.PowerPredicate; import mage.filter.predicate.mageobject.PowerPredicate;
import mage.target.Target;
import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetControlledCreaturePermanent;
/** /**
@ -65,8 +66,9 @@ public class ONaginata extends CardImpl {
this.expansionSetCode = "SOK"; this.expansionSetCode = "SOK";
this.subtype.add("Equipment"); 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. // 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. // Equipped creature gets +3/+0 and has trample.
Effect effect = new BoostEquippedEffect(3, 0); Effect effect = new BoostEquippedEffect(3, 0);
@ -78,10 +80,7 @@ public class ONaginata extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Equip {2} // Equip {2}
this.addAbility(new EquipAbility( this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(2), target));
Outcome.AddAbility,
new GenericManaCost(2),
new TargetControlledCreaturePermanent(1,1, filter, false)));
} }
public ONaginata(final ONaginata card) { public ONaginata(final ONaginata card) {

View file

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

View file

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

View file

@ -0,0 +1,122 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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 org.mage.test.cards.abilities.equipped;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.game.permanent.Permanent;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class EquipRestrictedTest extends CardTestPlayerBase {
@Test
public void testEquipLeoninScimitarToNonLegendary() {
addCard(Zone.BATTLEFIELD, playerB, "Auriok Windwalker");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerB, "Leonin Scimitar");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: Attach target Equipment you control to target creature you control.", "Leonin Scimitar");
addTarget(playerB, "Silvercout Lion");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
Permanent equipment = getPermanent("Leonin Scimitar", playerB);
Assert.assertTrue("Leonin Scimitar has to be attached", equipment.getAttachedTo() != null);
}
/**
* Konda's Banner, Gate Smasher, and O-Naginata can all be attached to
* creatures that they should not be able to be attached to. The filter is
* only applied to the EquipAbility and does not check other methods (such
* as Auriok Windwaker)
*/
@Test
public void testEquipKondasBannerToNonLegendary() {
addCard(Zone.BATTLEFIELD, playerB, "Auriok Windwalker");
addCard(Zone.BATTLEFIELD, playerB, "Silvercoat Lion");
addCard(Zone.BATTLEFIELD, playerB, "Konda's Banner");
activateAbility(2, PhaseStep.PRECOMBAT_MAIN, playerB, "{T}: Attach target Equipment you control to target creature you control.", "Konda's Banner");
addTarget(playerB, "Silvercout Lion");
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
Permanent equipment = getPermanent("Konda's Banner", playerB);
Assert.assertTrue("Konda's Banner may not be attached", equipment.getAttachedTo() == null);
}
@Test
public void testEquipGateSmasher() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
// {1}{W}: Kranioceros gets +0/+3 until end of turn.
addCard(Zone.BATTLEFIELD, playerA, "Kranioceros");// 5/2
// Gate Smasher can be attached only to a creature with toughness 4 or greater.
// Equipped creature gets +3/+0 and has trample.
// Equip {3}
addCard(Zone.BATTLEFIELD, playerA, "Gate Smasher");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}:");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Equip", "Kranioceros");
setStopAt(1, PhaseStep.END_TURN);
execute();
assertPowerToughness(playerA, "Kranioceros", 8, 5);
Permanent equipment = getPermanent("Gate Smasher", playerA);
Assert.assertTrue("Gate Smasher may no longer be attached", equipment.getAttachedTo() != null);
}
@Test
public void testEquipGateSmasherAndUnattached() {
addCard(Zone.BATTLEFIELD, playerA, "Plains", 5);
// {1}{W}: Kranioceros gets +0/+3 until end of turn.
addCard(Zone.BATTLEFIELD, playerA, "Kranioceros");// 5/2
// Gate Smasher can be attached only to a creature with toughness 4 or greater.
// Equipped creature gets +3/+0 and has trample.
// Equip {3}
addCard(Zone.BATTLEFIELD, playerA, "Gate Smasher");
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{1}{W}:");
activateAbility(1, PhaseStep.POSTCOMBAT_MAIN, playerA, "Equip", "Kranioceros");
setStopAt(2, PhaseStep.PRECOMBAT_MAIN);
execute();
assertPowerToughness(playerA, "Kranioceros", 5, 2);
Permanent equipment = getPermanent("Gate Smasher", playerA);
Assert.assertTrue("Gate Smasher may no longer be attached", equipment.getAttachedTo() == null);
}
}

View file

@ -11,6 +11,9 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Test; import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase; import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** /**
* @author noxx * @author noxx

View file

@ -0,0 +1,47 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package mage.abilities.common;
import mage.abilities.Ability;
import mage.abilities.effects.common.InfoEffect;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.target.Target;
/**
*
* @author LevelX2
*/
public class AttachableToRestrictedAbility extends SimpleStaticAbility {
public AttachableToRestrictedAbility(Target target) {
super(Zone.BATTLEFIELD, new InfoEffect("{this} can be attached only to a " + target.getTargetName()));
addTarget(target);
}
private AttachableToRestrictedAbility(AttachableToRestrictedAbility ability) {
super(ability);
}
public boolean canEquip(Permanent toEquip, Ability source, Game game) {
for (Target target : getTargets()) {
if (source == null) {
if (!target.canTarget(toEquip.getId(), game)) {
return false;
}
} else if (!target.canTarget(toEquip.getId(), source, game)) {
return false;
}
}
return true;
}
@Override
public AttachableToRestrictedAbility copy() {
return new AttachableToRestrictedAbility(this);
}
}

View file

@ -25,7 +25,6 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.abilities.keyword; package mage.abilities.keyword;
import java.util.UUID; import java.util.UUID;
@ -57,17 +56,15 @@ public class EquipAbility extends ActivatedAbilityImpl {
@Override @Override
public boolean canActivate(UUID playerId, Game game) { public boolean canActivate(UUID playerId, Game game) {
if(super.canActivate(playerId, game)){ if (super.canActivate(playerId, game)) {
Permanent permanent = game.getPermanent(sourceId); Permanent permanent = game.getPermanent(sourceId);
if(permanent != null && permanent.hasSubtype("Equipment", game)){ if (permanent != null && permanent.hasSubtype("Equipment", game)) {
return true; return true;
} }
} }
return false; return false;
} }
public EquipAbility(final EquipAbility ability) { public EquipAbility(final EquipAbility ability) {
super(ability); super(ability);
} }
@ -79,9 +76,7 @@ public class EquipAbility extends ActivatedAbilityImpl {
@Override @Override
public String getRule() { public String getRule() {
StringBuilder sb = new StringBuilder("Equip ").append(costs.getText()).append(manaCosts.getText()); return "Equip " + costs.getText() + manaCosts.getText() + " (" + manaCosts.getText() + ": <i>Attach to target creature you control. Equip only as a sorcery.)</i>";
sb.append(" (").append(manaCosts.getText()).append(": <i>Attach to target creature you control. Equip only as a sorcery.)</i>");
return sb.toString();
} }
} }

View file

@ -45,7 +45,7 @@ public class CanBeEnchantedByPredicate implements Predicate<Permanent> {
@Override @Override
public boolean apply(Permanent input, Game game) { public boolean apply(Permanent input, Game game) {
return !input.cantBeEnchantedBy(auraEnchantment, game); return !input.cantBeAttachedBy(auraEnchantment, game);
} }
@Override @Override

View file

@ -51,6 +51,7 @@ import mage.abilities.ActivatedAbility;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.SpellAbility; import mage.abilities.SpellAbility;
import mage.abilities.TriggeredAbility; import mage.abilities.TriggeredAbility;
import mage.abilities.common.AttachableToRestrictedAbility;
import mage.abilities.common.ChancellorAbility; import mage.abilities.common.ChancellorAbility;
import mage.abilities.common.GemstoneCavernsAbility; import mage.abilities.common.GemstoneCavernsAbility;
import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.ContinuousEffect;
@ -1775,12 +1776,12 @@ public abstract class GameImpl implements Game, Serializable {
Filter auraFilter = spellAbility.getTargets().get(0).getFilter(); Filter auraFilter = spellAbility.getTargets().get(0).getFilter();
if (auraFilter instanceof FilterControlledCreaturePermanent) { if (auraFilter instanceof FilterControlledCreaturePermanent) {
if (!((FilterControlledCreaturePermanent) auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this) if (!((FilterControlledCreaturePermanent) auraFilter).match(attachedTo, perm.getId(), perm.getControllerId(), this)
|| attachedTo.cantBeEnchantedBy(perm, this)) { || attachedTo.cantBeAttachedBy(perm, this)) {
if (movePermanentToGraveyardWithInfo(perm)) { if (movePermanentToGraveyardWithInfo(perm)) {
somethingHappened = true; somethingHappened = true;
} }
} }
} else if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeEnchantedBy(perm, this)) { } else if (!auraFilter.match(attachedTo, this) || attachedTo.cantBeAttachedBy(perm, this)) {
// handle bestow unattachment // handle bestow unattachment
Card card = this.getCard(perm.getId()); Card card = this.getCard(perm.getId());
if (card != null && card.getCardType().contains(CardType.CREATURE)) { if (card != null && card.getCardType().contains(CardType.CREATURE)) {
@ -1816,13 +1817,23 @@ public abstract class GameImpl implements Game, Serializable {
if (FILTER_EQUIPMENT.match(perm, this)) { if (FILTER_EQUIPMENT.match(perm, this)) {
//20091005 - 704.5p, 702.14d //20091005 - 704.5p, 702.14d
if (perm.getAttachedTo() != null) { if (perm.getAttachedTo() != null) {
Permanent creature = getPermanent(perm.getAttachedTo()); Permanent attachedTo = getPermanent(perm.getAttachedTo());
if (creature == null || !creature.getAttachments().contains(perm.getId())) { if (attachedTo != null) {
for (Ability ability : perm.getAbilities(this)) {
if (ability instanceof AttachableToRestrictedAbility) {
if (!((AttachableToRestrictedAbility) ability).canEquip(attachedTo, null, this)) {
attachedTo = null;
break;
}
}
}
}
if (attachedTo == null || !attachedTo.getAttachments().contains(perm.getId())) {
UUID wasAttachedTo = perm.getAttachedTo(); UUID wasAttachedTo = perm.getAttachedTo();
perm.attachTo(null, this); perm.attachTo(null, this);
fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId())); fireEvent(new GameEvent(GameEvent.EventType.UNATTACHED, wasAttachedTo, perm.getId(), perm.getControllerId()));
} else if (!creature.getCardType().contains(CardType.CREATURE) || creature.hasProtectionFrom(perm, this)) { } else if (!attachedTo.getCardType().contains(CardType.CREATURE) || attachedTo.hasProtectionFrom(perm, this)) {
if (creature.removeAttachment(perm.getId(), this)) { if (attachedTo.removeAttachment(perm.getId(), this)) {
somethingHappened = true; somethingHappened = true;
} }
} }

View file

@ -121,7 +121,7 @@ public interface Permanent extends Card, Controllable {
boolean hasProtectionFrom(MageObject source, Game game); boolean hasProtectionFrom(MageObject source, Game game);
boolean cantBeEnchantedBy(MageObject source, Game game); boolean cantBeAttachedBy(MageObject source, Game game);
boolean wasControlledFromStartOfControllerTurn(); boolean wasControlledFromStartOfControllerTurn();

View file

@ -981,7 +981,7 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
@Override @Override
public boolean hasProtectionFrom(MageObject source, Game game) { public boolean hasProtectionFrom(MageObject source, Game game) {
for (ProtectionAbility ability : abilities.getProtectionAbilities()) { for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
if (!ability.canTarget(source, game)) { if (!ability.canTarget(source, game)) {
return true; return true;
} }
@ -990,8 +990,8 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
} }
@Override @Override
public boolean cantBeEnchantedBy(MageObject source, Game game) { public boolean cantBeAttachedBy(MageObject source, Game game) {
for (ProtectionAbility ability : abilities.getProtectionAbilities()) { for (ProtectionAbility ability : this.getAbilities(game).getProtectionAbilities()) {
if (!(source.getSubtype(game).contains("Aura") if (!(source.getSubtype(game).contains("Aura")
&& !ability.removesAuras()) && !ability.removesAuras())
&& !source.getId().equals(ability.getAuraIdNotToBeRemoved()) && !source.getId().equals(ability.getAuraIdNotToBeRemoved())