From 33731ce90caad7e5d5367a3a6c856741870b2ffa Mon Sep 17 00:00:00 2001 From: LoneFox Date: Thu, 26 Nov 2015 12:11:34 +0200 Subject: [PATCH] Fix Sadistic Glee, Soul Tithe, and Tormentor's Trident. These cards were incorrectly granting an ability to the creature they are attached to. --- .../avacynrestored/TormentorsTrident.java | 22 +++++--- .../mage/sets/returntoravnica/SoulTithe.java | 52 ++++++++++--------- .../src/mage/sets/tempest/SadisticGlee.java | 11 ++-- 3 files changed, 45 insertions(+), 40 deletions(-) diff --git a/Mage.Sets/src/mage/sets/avacynrestored/TormentorsTrident.java b/Mage.Sets/src/mage/sets/avacynrestored/TormentorsTrident.java index 6978d7118c5..ce92e18fccf 100644 --- a/Mage.Sets/src/mage/sets/avacynrestored/TormentorsTrident.java +++ b/Mage.Sets/src/mage/sets/avacynrestored/TormentorsTrident.java @@ -27,16 +27,21 @@ */ package mage.sets.avacynrestored; -import mage.constants.*; -import mage.abilities.common.AttacksEachTurnStaticAbility; +import java.util.UUID; +import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.costs.mana.GenericManaCost; +import mage.abilities.effects.Effect; +import mage.abilities.effects.common.combat.AttacksIfAbleAttachedEffect; import mage.abilities.effects.common.continuous.BoostEquippedEffect; -import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EquipAbility; import mage.cards.CardImpl; - -import java.util.UUID; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.Zone; /** * @@ -51,8 +56,11 @@ public class TormentorsTrident extends CardImpl { this.subtype.add("Equipment"); // Equipped creature gets +3/+0 and attacks each turn if able. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(3, 0))); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(new AttacksEachTurnStaticAbility(), AttachmentType.EQUIPMENT))); + Ability ability = new SimpleStaticAbility(Zone.BATTLEFIELD, new BoostEquippedEffect(3, 0)); + Effect effect = new AttacksIfAbleAttachedEffect(Duration.WhileOnBattlefield, AttachmentType.EQUIPMENT); + effect.setText("and attacks each turn if able"); + ability.addEffect(effect); + this.addAbility(ability); // Equip {3} this.addAbility(new EquipAbility(Outcome.AddAbility, new GenericManaCost(3))); diff --git a/Mage.Sets/src/mage/sets/returntoravnica/SoulTithe.java b/Mage.Sets/src/mage/sets/returntoravnica/SoulTithe.java index 753401fbf69..3c20ab8aee8 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/SoulTithe.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/SoulTithe.java @@ -30,13 +30,6 @@ package mage.sets.returntoravnica; import java.util.UUID; import mage.MageObject; -import mage.constants.AttachmentType; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; -import mage.constants.Rarity; -import mage.constants.TargetController; -import mage.constants.Zone; import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.SimpleStaticAbility; @@ -47,6 +40,13 @@ import mage.abilities.effects.common.AttachEffect; import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; +import mage.constants.AttachmentType; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.Rarity; +import mage.constants.TargetController; +import mage.constants.Zone; import mage.game.Game; import mage.game.permanent.Permanent; import mage.players.Player; @@ -76,9 +76,7 @@ public class SoulTithe extends CardImpl { // At the beginning of the upkeep of enchanted permanent's controller, // that player sacrifices it unless he or she pays {X}, // where X is its converted mana cost. - Ability gainedAbility = new BeginningOfUpkeepTriggeredAbility(new SoulTitheSacrificeSourceUnlessPaysEffect(), TargetController.YOU, false); - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new GainAbilityAttachedEffect(gainedAbility, AttachmentType.AURA, Duration.WhileOnBattlefield, rule))); - + this.addAbility(new BeginningOfUpkeepTriggeredAbility(new SoulTitheEffect(), TargetController.CONTROLLER_ATTACHED_TO, false)); } public SoulTithe (final SoulTithe card) { @@ -91,38 +89,42 @@ public class SoulTithe extends CardImpl { } } -class SoulTitheSacrificeSourceUnlessPaysEffect extends OneShotEffect { +class SoulTitheEffect extends OneShotEffect { - public SoulTitheSacrificeSourceUnlessPaysEffect() { + public SoulTitheEffect() { super(Outcome.Sacrifice); staticText = "that player sacrifices it unless he or she pays {X}, where X is its converted mana cost"; } - public SoulTitheSacrificeSourceUnlessPaysEffect(final SoulTitheSacrificeSourceUnlessPaysEffect effect) { + public SoulTitheEffect(final SoulTitheEffect effect) { super(effect); } @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - Permanent permanent = game.getPermanent(source.getSourceId()); - MageObject sourceObject = source.getSourceObject(game); - if (player != null && permanent != null && sourceObject != null) { - int cmc = permanent.getManaCost().convertedManaCost(); - if (player.chooseUse(Outcome.Benefit, "Pay {" + cmc + "} for " + permanent.getName() + "? (otherwise you sacrifice it)", source, game)) { - Cost cost = new GenericManaCost(cmc); - if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false)) { + Permanent aura = game.getPermanent(source.getSourceId()); + if(aura != null) { + Permanent permanent = game.getPermanent(aura.getAttachedTo()); + if(permanent != null) { + Player player = game.getPlayer(permanent.getControllerId()); + if(player != null) { + int cmc = permanent.getManaCost().convertedManaCost(); + if (player.chooseUse(Outcome.Benefit, "Pay {" + cmc + "} for " + permanent.getName() + "? (otherwise you sacrifice it)", source, game)) { + Cost cost = new GenericManaCost(cmc); + if (cost.pay(source, game, source.getSourceId(), player.getId(), false)) { + return true; + } + } + permanent.sacrifice(source.getSourceId(), game); return true; } } - permanent.sacrifice(source.getSourceId(), game); - return true; } return false; } @Override - public SoulTitheSacrificeSourceUnlessPaysEffect copy() { - return new SoulTitheSacrificeSourceUnlessPaysEffect(this); + public SoulTitheEffect copy() { + return new SoulTitheEffect(this); } } diff --git a/Mage.Sets/src/mage/sets/tempest/SadisticGlee.java b/Mage.Sets/src/mage/sets/tempest/SadisticGlee.java index 48386fc4bf3..85d1496ca5c 100644 --- a/Mage.Sets/src/mage/sets/tempest/SadisticGlee.java +++ b/Mage.Sets/src/mage/sets/tempest/SadisticGlee.java @@ -30,13 +30,10 @@ package mage.sets.tempest; import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.DiesCreatureTriggeredAbility; -import mage.abilities.effects.Effect; import mage.abilities.effects.common.AttachEffect; -import mage.abilities.effects.common.continuous.GainAbilityAttachedEffect; -import mage.abilities.effects.common.counter.AddCountersSourceEffect; +import mage.abilities.effects.common.counter.AddCountersAttachedEffect; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; -import mage.constants.AttachmentType; import mage.constants.CardType; import mage.constants.Outcome; import mage.constants.Rarity; @@ -61,11 +58,9 @@ public class SadisticGlee extends CardImpl { this.getSpellAbility().addEffect(new AttachEffect(Outcome.AddAbility)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); - // Whenever a creature dies, put a +1/+1 counter on enchanted creature. - Effect effect = new GainAbilityAttachedEffect(new DiesCreatureTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance()), false), AttachmentType.AURA); - ability.addEffect(effect); - effect.setText("Whenever a creature dies, put a +1/+1 counter on enchanted creature."); + this.addAbility(new DiesCreatureTriggeredAbility(new AddCountersAttachedEffect( + CounterType.P1P1.createInstance(), "enchanted creature"), false)); } public SadisticGlee(final SadisticGlee card) {