mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Consecrete Land - Some changes.
This commit is contained in:
parent
fde05d8efb
commit
561f120ce0
5 changed files with 126 additions and 107 deletions
|
@ -30,26 +30,22 @@ package mage.cards.c;
|
|||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleStaticAbility;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.abilities.effects.common.AttachEffect;
|
||||
import mage.abilities.effects.common.CantBeEnchantedSourceEffect;
|
||||
import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect;
|
||||
import mage.abilities.keyword.EnchantAbility;
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.AttachmentType;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterEnchantmentPermanent;
|
||||
import mage.filter.predicate.mageobject.SubtypePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
import mage.target.TargetPermanent;
|
||||
import mage.target.common.TargetLandPermanent;
|
||||
|
||||
|
@ -61,7 +57,7 @@ public class ConsecrateLand extends CardImpl {
|
|||
|
||||
public ConsecrateLand(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}");
|
||||
|
||||
|
||||
this.subtype.add("Aura");
|
||||
|
||||
// Enchant land
|
||||
|
@ -72,9 +68,8 @@ public class ConsecrateLand extends CardImpl {
|
|||
this.addAbility(ability);
|
||||
|
||||
// Enchanted land is indestructible and can't be enchanted by other Auras.
|
||||
Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(IndestructibleAbility.getInstance(), AttachmentType.AURA, Duration.WhileOnBattlefield, "{this} is indestructible and can't be enchanted by other Auras."));
|
||||
ability2.addEffect(new CantBeEnchantedSourceEffect());
|
||||
ability2.addEffect(new ConsecrateLandEffect());
|
||||
Ability ability2 = new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(IndestructibleAbility.getInstance(), AttachmentType.AURA));
|
||||
ability2.addEffect(new ConsecrateLandRuleEffect());
|
||||
this.addAbility(ability2);
|
||||
}
|
||||
|
||||
|
@ -89,39 +84,34 @@ public class ConsecrateLand extends CardImpl {
|
|||
}
|
||||
|
||||
// 9/25/2006 ruling: If Consecrate Land enters the battlefield attached to a land that’s enchanted by other Auras, those Auras are put into their owners’ graveyards.
|
||||
class ConsecrateLandRuleEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
class ConsecrateLandEffect extends ContinuousEffectImpl {
|
||||
|
||||
private static final FilterEnchantmentPermanent filter = new FilterEnchantmentPermanent();
|
||||
|
||||
static {
|
||||
filter.add(new SubtypePredicate("Aura"));
|
||||
public ConsecrateLandRuleEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Detriment);
|
||||
staticText = "and can't be enchanted by other Auras";
|
||||
}
|
||||
|
||||
public ConsecrateLandEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Benefit);
|
||||
}
|
||||
|
||||
public ConsecrateLandEffect(final ConsecrateLandEffect effect) {
|
||||
public ConsecrateLandRuleEffect(final ConsecrateLandRuleEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConsecrateLandEffect copy() {
|
||||
return new ConsecrateLandEffect(this);
|
||||
public ConsecrateLandRuleEffect copy() {
|
||||
return new ConsecrateLandRuleEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo());
|
||||
if (enchanted != null) {
|
||||
Cards removeAuras = new CardsImpl(enchanted.getAttachments());
|
||||
controller.moveCards(removeAuras, Zone.GRAVEYARD, source, game);
|
||||
}
|
||||
return true;
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType().equals(EventType.ATTACH) || event.getType().equals(EventType.STAY_ATTACHED);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
Permanent sourceObject = game.getPermanent(source.getSourceId());
|
||||
if (sourceObject != null && sourceObject.getAttachedTo() != null) {
|
||||
if (event.getTargetId().equals(sourceObject.getAttachedTo())) {
|
||||
return !event.getSourceId().equals(source.getSourceId());
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
/*
|
||||
* 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.rules;
|
||||
|
||||
import mage.abilities.keyword.IndestructibleAbility;
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author LevelX2
|
||||
*/
|
||||
public class CantBeEnchantedTest extends CardTestPlayerBase {
|
||||
|
||||
@Test
|
||||
public void testConsecrateLand() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains");
|
||||
|
||||
// Enchant land
|
||||
// Enchanted land is indestructible and can't be enchanted by other Auras.
|
||||
addCard(Zone.HAND, playerA, "Consecrate Land", 1); // Enchantment {W}
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
// Enchant land
|
||||
// Whenever enchanted land becomes tapped, Psychic Venom deals 2 damage to that land's controller.
|
||||
addCard(Zone.HAND, playerB, "Psychic Venom", 1); // Enchantment {1}{U}
|
||||
|
||||
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Consecrate Land", "Plains");
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Psychic Venom", "Plains");
|
||||
|
||||
setStopAt(2, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Consecrate Land", 0);
|
||||
assertPermanentCount(playerA, "Consecrate Land", 1);
|
||||
assertAbility(playerA, "Plains", IndestructibleAbility.getInstance(), true);
|
||||
assertPermanentCount(playerB, "Psychic Venom", 0);
|
||||
assertGraveyardCount(playerB, "Psychic Venom", 1);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testConsecrateLandEnchantedBefore() {
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Plains");
|
||||
|
||||
// Enchant land
|
||||
// Enchanted land is indestructible and can't be enchanted by other Auras.
|
||||
addCard(Zone.HAND, playerA, "Consecrate Land", 1); // Enchantment {W}
|
||||
|
||||
addCard(Zone.BATTLEFIELD, playerB, "Island", 2);
|
||||
// Enchant land
|
||||
// Whenever enchanted land becomes tapped, Psychic Venom deals 2 damage to that land's controller.
|
||||
addCard(Zone.HAND, playerB, "Psychic Venom", 1); // Enchantment {1}{U}
|
||||
|
||||
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Psychic Venom", "Plains");
|
||||
castSpell(3, PhaseStep.PRECOMBAT_MAIN, playerA, "Consecrate Land", "Plains");
|
||||
|
||||
setStopAt(3, PhaseStep.BEGIN_COMBAT);
|
||||
execute();
|
||||
|
||||
assertGraveyardCount(playerA, "Consecrate Land", 0);
|
||||
assertPermanentCount(playerA, "Consecrate Land", 1);
|
||||
assertAbility(playerA, "Plains", IndestructibleAbility.getInstance(), true);
|
||||
|
||||
assertLife(playerA, 18);
|
||||
assertPermanentCount(playerB, "Psychic Venom", 0);
|
||||
assertGraveyardCount(playerB, "Psychic Venom", 1);
|
||||
assertHandCount(playerB, "Psychic Venom", 0);
|
||||
|
||||
}
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* 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.abilities.effects.common;
|
||||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Outcome;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author MTGfan
|
||||
*/
|
||||
public class CantBeEnchantedSourceEffect extends ContinuousRuleModifyingEffectImpl {
|
||||
|
||||
public CantBeEnchantedSourceEffect(CantBeEnchantedSourceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
public CantBeEnchantedSourceEffect() {
|
||||
super(Duration.WhileOnBattlefield, Outcome.Neutral);
|
||||
staticText = "{this} can't be enchanted by other Auras.";
|
||||
}
|
||||
|
||||
@Override
|
||||
public CantBeEnchantedSourceEffect copy() {
|
||||
return new CantBeEnchantedSourceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checksEventType(GameEvent event, Game game) {
|
||||
return event.getType() == GameEvent.EventType.ATTACH;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getTargetId().equals(source.getSourceId())) {
|
||||
Permanent permanent = game.getPermanent(event.getSourceId());
|
||||
if (permanent != null && permanent.getSubtype(game).contains("Aura")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -271,6 +271,7 @@ public class GameEvent implements Serializable {
|
|||
EXPLOITED_CREATURE,
|
||||
EVOLVED_CREATURE,
|
||||
ATTACH, ATTACHED,
|
||||
STAY_ATTACHED,
|
||||
UNATTACH, UNATTACHED,
|
||||
ADD_COUNTER, COUNTER_ADDED,
|
||||
ADD_COUNTERS, COUNTERS_ADDED,
|
||||
|
|
|
@ -927,6 +927,9 @@ public abstract class PermanentImpl extends CardImpl implements Permanent {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (game.getContinuousEffects().preventedByRuleModification(GameEvent.getEvent(EventType.STAY_ATTACHED, objectId, source.getId(), null), null, game, false)) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue