From 3c81275ab1647401ddb9c3241c4ff4ca36d92f66 Mon Sep 17 00:00:00 2001 From: Clint Herron Date: Thu, 23 Mar 2017 19:23:28 -0400 Subject: [PATCH 1/4] Implementing Guilty Conscience and Backfire, as well as expanding capabilities of trigers that occur when an enchanted creature deals damage to a player, and adding an effect to deal damage to an enchanted creature. --- Mage.Sets/src/mage/cards/b/Backfire.java | 75 +++++++++++++++ .../src/mage/cards/g/GuiltyConscience.java | 76 +++++++++++++++ Mage.Sets/src/mage/sets/FourthEdition.java | 1 + Mage.Sets/src/mage/sets/Legends.java | 1 + Mage.Sets/src/mage/sets/Scourge.java | 1 + ...mageToAPlayerAttachedTriggeredAbility.java | 9 ++ .../effects/common/DamageAttachedEffect.java | 93 +++++++++++++++++++ 7 files changed, 256 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/b/Backfire.java create mode 100644 Mage.Sets/src/mage/cards/g/GuiltyConscience.java create mode 100644 Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java diff --git a/Mage.Sets/src/mage/cards/b/Backfire.java b/Mage.Sets/src/mage/cards/b/Backfire.java new file mode 100644 index 00000000000..6986a9c96a1 --- /dev/null +++ b/Mage.Sets/src/mage/cards/b/Backfire.java @@ -0,0 +1,75 @@ +/* + * 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.cards.b; + +import java.util.UUID; +import mage.target.common.TargetCreaturePermanent; +import mage.abilities.Ability; +import mage.abilities.common.DealsDamageToAPlayerAttachedTriggeredAbility; +import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DamageAttachedControllerEffect; +import mage.constants.Outcome; +import mage.target.TargetPermanent; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.TargetController; + +/** + * + * @author anonymous + */ +public class Backfire extends CardImpl { + + public Backfire(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{U}"); + + this.subtype.add("Aura"); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Whenever enchanted creature deals damage to you, Backfire deals that much damage to that creature's controller. + this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DamageAttachedControllerEffect(new NumericSetToEffectValues("that much", "damage")), "description", false, true, false, TargetController.YOU)); + } + + public Backfire(final Backfire card) { + super(card); + } + + @Override + public Backfire copy() { + return new Backfire(this); + } +} diff --git a/Mage.Sets/src/mage/cards/g/GuiltyConscience.java b/Mage.Sets/src/mage/cards/g/GuiltyConscience.java new file mode 100644 index 00000000000..fbc71e3d7c6 --- /dev/null +++ b/Mage.Sets/src/mage/cards/g/GuiltyConscience.java @@ -0,0 +1,76 @@ +/* + * 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.cards.g; + +import java.util.UUID; +import mage.target.common.TargetCreaturePermanent; +import mage.abilities.Ability; +import mage.abilities.common.DealsDamageAttachedTriggeredAbility; +import mage.abilities.dynamicvalue.common.NumericSetToEffectValues; +import mage.abilities.effects.common.AttachEffect; +import mage.abilities.effects.common.DamageAttachedEffect; +import mage.abilities.effects.common.GainLifeEffect; +import mage.constants.Outcome; +import mage.target.TargetPermanent; +import mage.abilities.keyword.EnchantAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Zone; + +/** + * + * @author anonymous + */ +public class GuiltyConscience extends CardImpl { + + public GuiltyConscience(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{W}"); + + this.subtype.add("Aura"); + + // Enchant creature + TargetPermanent auraTarget = new TargetCreaturePermanent(); + this.getSpellAbility().addTarget(auraTarget); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + Ability ability = new EnchantAbility(auraTarget.getTargetName()); + this.addAbility(ability); + + // Whenever enchanted creature deals damage, Guilty Conscience deals that much damage to that creature. + this.addAbility(new DealsDamageAttachedTriggeredAbility(Zone.BATTLEFIELD, new DamageAttachedEffect(new NumericSetToEffectValues("that much", "damage")), false)); + } + + public GuiltyConscience(final GuiltyConscience card) { + super(card); + } + + @Override + public GuiltyConscience copy() { + return new GuiltyConscience(this); + } +} diff --git a/Mage.Sets/src/mage/sets/FourthEdition.java b/Mage.Sets/src/mage/sets/FourthEdition.java index a0b6388c94c..ecfa16be06c 100644 --- a/Mage.Sets/src/mage/sets/FourthEdition.java +++ b/Mage.Sets/src/mage/sets/FourthEdition.java @@ -72,6 +72,7 @@ public class FourthEdition extends ExpansionSet { cards.add(new SetCardInfo("Ashes to Ashes", 3, Rarity.UNCOMMON, mage.cards.a.AshesToAshes.class)); cards.add(new SetCardInfo("Ashnod's Battle Gear", 314, Rarity.UNCOMMON, mage.cards.a.AshnodsBattleGear.class)); cards.add(new SetCardInfo("Aspect of Wolf", 117, Rarity.RARE, mage.cards.a.AspectOfWolf.class)); + cards.add(new SetCardInfo("Backfire", 62, Rarity.UNCOMMON, mage.cards.b.Backfire.class)); cards.add(new SetCardInfo("Bad Moon", 4, Rarity.RARE, mage.cards.b.BadMoon.class)); cards.add(new SetCardInfo("Balance", 256, Rarity.RARE, mage.cards.b.Balance.class)); cards.add(new SetCardInfo("Ball Lightning", 194, Rarity.RARE, mage.cards.b.BallLightning.class)); diff --git a/Mage.Sets/src/mage/sets/Legends.java b/Mage.Sets/src/mage/sets/Legends.java index cdb99292084..e31b476ba5e 100644 --- a/Mage.Sets/src/mage/sets/Legends.java +++ b/Mage.Sets/src/mage/sets/Legends.java @@ -67,6 +67,7 @@ public class Legends extends ExpansionSet { cards.add(new SetCardInfo("Arena of the Ancients", 215, Rarity.RARE, mage.cards.a.ArenaOfTheAncients.class)); cards.add(new SetCardInfo("Avoid Fate", 89, Rarity.COMMON, mage.cards.a.AvoidFate.class)); cards.add(new SetCardInfo("Azure Drake", 46, Rarity.UNCOMMON, mage.cards.a.AzureDrake.class)); + cards.add(new SetCardInfo("Backfire", 47, Rarity.UNCOMMON, mage.cards.b.Backfire.class)); cards.add(new SetCardInfo("Barbary Apes", 90, Rarity.COMMON, mage.cards.b.BarbaryApes.class)); cards.add(new SetCardInfo("Barktooth Warbeard", 261, Rarity.UNCOMMON, mage.cards.b.BarktoothWarbeard.class)); cards.add(new SetCardInfo("Bartel Runeaxe", 262, Rarity.RARE, mage.cards.b.BartelRuneaxe.class)); diff --git a/Mage.Sets/src/mage/sets/Scourge.java b/Mage.Sets/src/mage/sets/Scourge.java index fe48db6930b..b5c9e9492e6 100644 --- a/Mage.Sets/src/mage/sets/Scourge.java +++ b/Mage.Sets/src/mage/sets/Scourge.java @@ -114,6 +114,7 @@ public class Scourge extends ExpansionSet { cards.add(new SetCardInfo("Goblin Warchief", 97, Rarity.UNCOMMON, mage.cards.g.GoblinWarchief.class)); cards.add(new SetCardInfo("Goblin War Strike", 96, Rarity.COMMON, mage.cards.g.GoblinWarStrike.class)); cards.add(new SetCardInfo("Grip of Chaos", 98, Rarity.RARE, mage.cards.g.GripOfChaos.class)); + cards.add(new SetCardInfo("Guilty Conscience", 17, Rarity.COMMON, mage.cards.g.GuiltyConscience.class)); cards.add(new SetCardInfo("Hindering Touch", 37, Rarity.COMMON, mage.cards.h.HinderingTouch.class)); cards.add(new SetCardInfo("Hunting Pack", 121, Rarity.UNCOMMON, mage.cards.h.HuntingPack.class)); cards.add(new SetCardInfo("Karona, False God", 138, Rarity.RARE, mage.cards.k.KaronaFalseGod.class)); diff --git a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java index b8c245b7235..d3ff537c9bb 100644 --- a/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java +++ b/Mage/src/main/java/mage/abilities/common/DealsDamageToAPlayerAttachedTriggeredAbility.java @@ -66,12 +66,18 @@ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbili return false; } } + if (targetController == TargetController.YOU) { + if (!this.getControllerId().equals(event.getPlayerId())) { + return false; + } + } DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event; Permanent p = game.getPermanent(event.getSourceId()); if ((!onlyCombat || damageEvent.isCombatDamage()) && p != null && p.getAttachments().contains(this.getSourceId())) { if (setFixedTargetPointer) { for (Effect effect : this.getEffects()) { + effect.setValue("damage", event.getAmount()); effect.setTargetPointer(new FixedTarget(event.getPlayerId())); } } @@ -92,6 +98,9 @@ public class DealsDamageToAPlayerAttachedTriggeredAbility extends TriggeredAbili case OPPONENT: sb.append("an opponent, "); break; + case YOU: + sb.append("you, "); + break; case ANY: sb.append("a player, "); break; diff --git a/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java new file mode 100644 index 00000000000..e90803919c5 --- /dev/null +++ b/Mage/src/main/java/mage/abilities/effects/common/DamageAttachedEffect.java @@ -0,0 +1,93 @@ +/* + * 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.Mode; +import mage.abilities.dynamicvalue.DynamicValue; +import mage.abilities.dynamicvalue.common.StaticValue; +import mage.abilities.effects.OneShotEffect; +import mage.constants.Outcome; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.players.Player; + +/** + * + * @author LoneFox + */ +public class DamageAttachedEffect extends OneShotEffect { + + protected DynamicValue amount; + + public DamageAttachedEffect(int amount) { + super(Outcome.Damage); + this.amount = new StaticValue(amount); + } + + public DamageAttachedEffect(DynamicValue amount) { + super(Outcome.Damage); + this.amount = amount; + } + + public DamageAttachedEffect(final DamageAttachedEffect effect) { + super(effect); + this.amount = effect.amount; + } + + @Override + public DamageAttachedEffect copy() { + return new DamageAttachedEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + Permanent enchantment = game.getPermanentOrLKIBattlefield(source.getSourceId()); + if(enchantment == null) { + return false; + } + Permanent enchanted = game.getPermanentOrLKIBattlefield(enchantment.getAttachedTo()); + if(enchanted == null) { + return false; + } + enchanted.damage(amount.calculate(game, source, this), source.getSourceId(), game, false, true); + return true; + } + + @Override + public String getText(Mode mode) { + if (staticText != null && !staticText.isEmpty()) { + return staticText; + } + if ("equal to".equals(amount.toString())) { + return "{this} deals damage " + amount + " that creatures toughness to that creature"; + } + return "{this} deals " + amount + " damage to that creature"; + } +} From f461899eece7289fdca697ce153acd5f47e6d450 Mon Sep 17 00:00:00 2001 From: Clint Herron Date: Wed, 19 Apr 2017 22:18:49 -0400 Subject: [PATCH 2/4] Changing description to match 'enchanted creature' properly now so that Backfire now has the correct reminder text. --- Mage.Sets/src/mage/cards/b/Backfire.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/b/Backfire.java b/Mage.Sets/src/mage/cards/b/Backfire.java index 6986a9c96a1..2f42de640df 100644 --- a/Mage.Sets/src/mage/cards/b/Backfire.java +++ b/Mage.Sets/src/mage/cards/b/Backfire.java @@ -61,7 +61,7 @@ public class Backfire extends CardImpl { this.addAbility(ability); // Whenever enchanted creature deals damage to you, Backfire deals that much damage to that creature's controller. - this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DamageAttachedControllerEffect(new NumericSetToEffectValues("that much", "damage")), "description", false, true, false, TargetController.YOU)); + this.addAbility(new DealsDamageToAPlayerAttachedTriggeredAbility(new DamageAttachedControllerEffect(new NumericSetToEffectValues("that much", "damage")), "enchanted creature", false, true, false, TargetController.YOU)); } public Backfire(final Backfire card) { From 30e0ef863d9c750f24a2232fbff32cff4ccb6f83 Mon Sep 17 00:00:00 2001 From: Clint Herron Date: Wed, 19 Apr 2017 22:31:02 -0400 Subject: [PATCH 3/4] Removing error when running server where Creeping Mold would have a predicate error because 'inference variable T#1 has incompatible bounds' -- I don't fully understand the error, but at least this fix seems to work. --- Mage/src/main/java/mage/filter/predicate/Predicates.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage/src/main/java/mage/filter/predicate/Predicates.java b/Mage/src/main/java/mage/filter/predicate/Predicates.java index 30ad5956a49..f17932b7145 100644 --- a/Mage/src/main/java/mage/filter/predicate/Predicates.java +++ b/Mage/src/main/java/mage/filter/predicate/Predicates.java @@ -117,7 +117,7 @@ public final class Predicates { * @return */ public static Predicate or(Predicate... components) { - return new OrPredicate<>(defensiveCopy(components)); + return new OrPredicate(defensiveCopy(components)); } /** From 523743aaf671f606b8b609f7b430abbe434612fa Mon Sep 17 00:00:00 2001 From: Clint Herron Date: Thu, 20 Apr 2017 19:03:05 -0400 Subject: [PATCH 4/4] Fixing nits from LevelX2 -- adding authorship tag and marking both enchantments as unboost effects, because both are things that you would tend to want to play on your opponents' creatures -- not your own. This should help the AI make more sensible plays when using these. --- Mage.Sets/src/mage/cards/b/Backfire.java | 4 ++-- Mage.Sets/src/mage/cards/g/GuiltyConscience.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/cards/b/Backfire.java b/Mage.Sets/src/mage/cards/b/Backfire.java index 2f42de640df..277e0d03d18 100644 --- a/Mage.Sets/src/mage/cards/b/Backfire.java +++ b/Mage.Sets/src/mage/cards/b/Backfire.java @@ -44,7 +44,7 @@ import mage.constants.TargetController; /** * - * @author anonymous + * @author HanClinto */ public class Backfire extends CardImpl { @@ -56,7 +56,7 @@ public class Backfire extends CardImpl { // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability); diff --git a/Mage.Sets/src/mage/cards/g/GuiltyConscience.java b/Mage.Sets/src/mage/cards/g/GuiltyConscience.java index fbc71e3d7c6..dcaf555b124 100644 --- a/Mage.Sets/src/mage/cards/g/GuiltyConscience.java +++ b/Mage.Sets/src/mage/cards/g/GuiltyConscience.java @@ -45,7 +45,7 @@ import mage.constants.Zone; /** * - * @author anonymous + * @author HanClinto */ public class GuiltyConscience extends CardImpl { @@ -57,7 +57,7 @@ public class GuiltyConscience extends CardImpl { // Enchant creature TargetPermanent auraTarget = new TargetCreaturePermanent(); this.getSpellAbility().addTarget(auraTarget); - this.getSpellAbility().addEffect(new AttachEffect(Outcome.BoostCreature)); + this.getSpellAbility().addEffect(new AttachEffect(Outcome.UnboostCreature)); Ability ability = new EnchantAbility(auraTarget.getTargetName()); this.addAbility(ability);