mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
Fixed #6047
This commit is contained in:
parent
b8cc48c2ca
commit
3f9f860f85
3 changed files with 29 additions and 28 deletions
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
package mage.cards.p;
|
||||
|
||||
import java.util.UUID;
|
||||
|
|
@ -7,6 +6,7 @@ import mage.abilities.common.SimpleActivatedAbility;
|
|||
import mage.abilities.costs.common.SacrificeSourceCost;
|
||||
import mage.abilities.costs.mana.VariableManaCost;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.DestroyAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
|
|
@ -18,18 +18,15 @@ import mage.filter.predicate.Predicates;
|
|||
import mage.filter.predicate.mageobject.CardTypePredicate;
|
||||
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
/**
|
||||
* @author Plopman
|
||||
*/
|
||||
public final class PerniciousDeed extends CardImpl {
|
||||
|
||||
|
||||
public PerniciousDeed(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{G}");
|
||||
|
||||
|
||||
// {X}, Sacrifice Pernicious Deed: Destroy each artifact, creature, and enchantment with converted mana cost X or less.
|
||||
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PerniciousDeedEffect(), new VariableManaCost());
|
||||
ability.addCost(new SacrificeSourceCost());
|
||||
|
|
@ -46,16 +43,13 @@ public final class PerniciousDeed extends CardImpl {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
class PerniciousDeedEffect extends OneShotEffect {
|
||||
|
||||
|
||||
public PerniciousDeedEffect() {
|
||||
super(Outcome.DestroyPermanent);
|
||||
staticText = "Destroy each artifact, creature, and enchantment with converted mana cost X or less";
|
||||
}
|
||||
|
||||
|
||||
public PerniciousDeedEffect(final PerniciousDeedEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
|
@ -68,21 +62,15 @@ class PerniciousDeedEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
|
||||
|
||||
FilterPermanent filter = new FilterPermanent("artifacts, creatures, and enchantments");
|
||||
|
||||
|
||||
filter.add(Predicates.or(
|
||||
new CardTypePredicate(CardType.ARTIFACT),
|
||||
new CardTypePredicate(CardType.CREATURE),
|
||||
new CardTypePredicate(CardType.ENCHANTMENT)));
|
||||
filter.add(new ConvertedManaCostPredicate(ComparisonType.FEWER_THAN, source.getManaCostsToPay().getX() + 1));
|
||||
|
||||
|
||||
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
|
||||
permanent.destroy(source.getSourceId(), game, false);
|
||||
}
|
||||
return true;
|
||||
return new DestroyAllEffect(filter).apply(game, source);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,8 @@
|
|||
|
||||
package org.mage.test.cards.enchantments;
|
||||
|
||||
import mage.constants.PhaseStep;
|
||||
import mage.constants.Zone;
|
||||
import org.junit.Test;
|
||||
import org.junit.Ignore;
|
||||
import org.mage.test.serverside.base.CardTestPlayerBase;
|
||||
|
||||
/**
|
||||
|
|
@ -26,11 +25,14 @@ public class SkullclampTest extends CardTestPlayerBase {
|
|||
* 704.5n.)
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
|
||||
// This test does not work, but the example works in the game fine.
|
||||
@Ignore
|
||||
public void testPerniciousDeed() {
|
||||
// Equipped creature gets +1/-1.
|
||||
// Whenever equipped creature dies, draw two cards.
|
||||
// Equip {1}
|
||||
addCard(Zone.LIBRARY, playerA, "Memnite", 2);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Skullclamp", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 1);
|
||||
addCard(Zone.BATTLEFIELD, playerA, "Pillarfield Ox", 1);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package mage.abilities.common;
|
|||
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.cards.Card;
|
||||
import mage.constants.SetTargetPointer;
|
||||
import mage.constants.Zone;
|
||||
import mage.game.Game;
|
||||
|
|
@ -33,7 +34,8 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
this(effect, attachedDescription, optional, diesRuleText, SetTargetPointer.NONE);
|
||||
}
|
||||
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional, boolean diesRuleText, SetTargetPointer setTargetPointer) {
|
||||
public DiesAttachedTriggeredAbility(Effect effect, String attachedDescription, boolean optional,
|
||||
boolean diesRuleText, SetTargetPointer setTargetPointer) {
|
||||
super(Zone.ALL, effect, optional); // because the trigger only triggers if the object was attached, it doesn't matter where the Attachment was moved to (e.g. by replacement effect) after the trigger triggered, so Zone.all
|
||||
this.attachedDescription = attachedDescription;
|
||||
this.diesRuleText = diesRuleText;
|
||||
|
|
@ -62,18 +64,26 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
if (((ZoneChangeEvent) event).isDiesEvent()) {
|
||||
ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
|
||||
boolean triggered = false;
|
||||
if (zEvent.getTarget() != null && zEvent.getTarget().getAttachments() != null && zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
if (zEvent.getTarget() != null
|
||||
&& zEvent.getTarget().getAttachments() != null
|
||||
&& zEvent.getTarget().getAttachments().contains(this.getSourceId())) {
|
||||
triggered = true;
|
||||
} else {
|
||||
// If both (attachment and attached went to graveyard at the same time, the attachemnets can be already removed from the attached object.)
|
||||
// So check here with the LKI of the enchantment
|
||||
// If the attachment and attachedTo went to graveyard at the same time, the trigger applies.
|
||||
// If the attachment is removed beforehand, the trigger fails.
|
||||
// IE: A player cast Planar Clensing. The attachment is Disenchanted in reponse
|
||||
// and successfully removed from the attachedTo. The trigger fails.
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
Card attachmentCard = game.getCard(getSourceId());
|
||||
if (attachment != null
|
||||
&& zEvent.getTargetId() != null && attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId() != null
|
||||
&& attachment.getAttachedTo() != null
|
||||
&& zEvent.getTargetId().equals(attachment.getAttachedTo())) {
|
||||
Permanent attachedTo = game.getPermanentOrLKIBattlefield(attachment.getAttachedTo());
|
||||
if (attachedTo != null
|
||||
&& attachment.getAttachedToZoneChangeCounter() == attachedTo.getZoneChangeCounter(game)) { // zoneChangeCounter is stored in Permanent
|
||||
&& attachmentCard != null
|
||||
&& attachment.getAttachedToZoneChangeCounter() == attachedTo.getZoneChangeCounter(game)
|
||||
&& attachment.getZoneChangeCounter(game) == attachmentCard.getZoneChangeCounter(game)) {
|
||||
triggered = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -84,8 +94,10 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
effect.setValue("attachedTo", zEvent.getTarget());
|
||||
if (setTargetPointer == SetTargetPointer.ATTACHED_TO_CONTROLLER) {
|
||||
Permanent attachment = game.getPermanentOrLKIBattlefield(getSourceId());
|
||||
if (attachment != null && attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(), Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachment != null
|
||||
&& attachment.getAttachedTo() != null) {
|
||||
Permanent attachedTo = (Permanent) game.getLastKnownInformation(attachment.getAttachedTo(),
|
||||
Zone.BATTLEFIELD, attachment.getAttachedToZoneChangeCounter());
|
||||
if (attachedTo != null) {
|
||||
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
|
||||
}
|
||||
|
|
@ -95,7 +107,6 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -111,4 +122,4 @@ public class DiesAttachedTriggeredAbility extends TriggeredAbilityImpl {
|
|||
sb.append(super.getRule());
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue