From ee6d3c0fc94a336807bd9ab40afbe8fd44dbdea2 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 09:55:47 -0400 Subject: [PATCH 1/8] fixed Mistbind Clique not triggering on championing of Mutavault --- Mage.Sets/src/mage/cards/m/MistbindClique.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/m/MistbindClique.java b/Mage.Sets/src/mage/cards/m/MistbindClique.java index 076bd47680..2081aa056b 100644 --- a/Mage.Sets/src/mage/cards/m/MistbindClique.java +++ b/Mage.Sets/src/mage/cards/m/MistbindClique.java @@ -108,7 +108,7 @@ class MistbindCliqueAbility extends ZoneChangeTriggeredAbility { && event.getSourceId().equals(getSourceId()) && !event.getSourceId().equals(event.getTargetId())) { Permanent sacrificed = game.getPermanentOrLKIBattlefield(event.getTargetId()); - if (sacrificed != null && sacrificed.hasSubtype(SubType.FAERIE, game)) { + if (sacrificed != null) {// no longer checks for Faerie as LKI isn't always accurate, can't think of how that could matter anyway - TheElk801 return true; } } From a8bce9302371dce7a07c755aacf9be2bfdd698cb Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 10:11:42 -0400 Subject: [PATCH 2/8] fixed Dual Nature giving tokens to the wrong player --- Mage.Sets/src/mage/cards/d/DualNature.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/cards/d/DualNature.java b/Mage.Sets/src/mage/cards/d/DualNature.java index 23da3a3638..3080786093 100644 --- a/Mage.Sets/src/mage/cards/d/DualNature.java +++ b/Mage.Sets/src/mage/cards/d/DualNature.java @@ -112,7 +112,7 @@ class DualNatureCreateTokenEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent permanent = game.getPermanent(source.getSourceId()); + Permanent permanent = game.getPermanentOrLKIBattlefield(this.getTargetPointer().getFirst(game, source)); if (permanent != null) { CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(permanent.getControllerId()); effect.setTargetPointer(targetPointer); From 38f83c84f6e14dbe673c60b949b4beb6337827f3 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 10:32:11 -0400 Subject: [PATCH 3/8] Implemented Rimefeather Owl --- .../src/mage/cards/r/RimefeatherOwl.java | 140 ++++++++++++++++++ Mage.Sets/src/mage/sets/Coldsnap.java | 1 + 2 files changed, 141 insertions(+) create mode 100644 Mage.Sets/src/mage/cards/r/RimefeatherOwl.java diff --git a/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java b/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java new file mode 100644 index 0000000000..9e89292b85 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RimefeatherOwl.java @@ -0,0 +1,140 @@ +/* + * 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.r; + +import java.util.UUID; +import mage.MageInt; +import mage.abilities.Ability; +import mage.abilities.Mode; +import mage.abilities.common.SimpleActivatedAbility; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount; +import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continuous.SetPowerToughnessSourceEffect; +import mage.abilities.effects.common.counter.AddCountersTargetEffect; +import mage.constants.SubType; +import mage.constants.SuperType; +import mage.abilities.keyword.FlyingAbility; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Layer; +import mage.constants.Outcome; +import mage.constants.SubLayer; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.SupertypePredicate; +import mage.filter.predicate.permanent.CounterPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.target.TargetPermanent; + +/** + * + * @author TheElk801 + */ +public class RimefeatherOwl extends CardImpl { + + private static final FilterPermanent filter = new FilterPermanent("Permanents with ice counters on them"); + private static final FilterPermanent filter2 = new FilterPermanent("snow permanents on the battlefield"); + + static { + filter.add(Predicates.not(new CounterPredicate(CounterType.ICE))); + filter2.add(Predicates.not(new SupertypePredicate(SuperType.SNOW))); + } + + public RimefeatherOwl(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{5}{U}{U}"); + + this.addSuperType(SuperType.SNOW); + this.subtype.add(SubType.BIRD); + this.power = new MageInt(0); + this.toughness = new MageInt(0); + + // Flying + this.addAbility(FlyingAbility.getInstance()); + + // Rimefeather Owl's power and toughness are each equal to the number of snow permanents on the battlefield. + this.addAbility(new SimpleStaticAbility(Zone.ALL, new SetPowerToughnessSourceEffect(new PermanentsOnBattlefieldCount(filter2), Duration.EndOfGame))); + + // {1}{snow}: Put an ice counter on target permanent. + Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new AddCountersTargetEffect(CounterType.ICE.createInstance()), new ManaCostsImpl("{1}{S}")); + ability.addTarget(new TargetPermanent()); + this.addAbility(ability); + + // Permanents with ice counters on them are snow. + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new RimefeatherOwlEffect(Duration.WhileOnBattlefield, filter))); + } + + public RimefeatherOwl(final RimefeatherOwl card) { + super(card); + } + + @Override + public RimefeatherOwl copy() { + return new RimefeatherOwl(this); + } +} + +class RimefeatherOwlEffect extends ContinuousEffectImpl { + + private final FilterPermanent filter; + + public RimefeatherOwlEffect(Duration duration, FilterPermanent filter) { + super(duration, Layer.TypeChangingEffects_4, SubLayer.NA, Outcome.Detriment); + this.filter = filter; + } + + public RimefeatherOwlEffect(final RimefeatherOwlEffect effect) { + super(effect); + this.filter = effect.filter; + } + + @Override + public RimefeatherOwlEffect copy() { + return new RimefeatherOwlEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { + permanent.addSuperType(SuperType.SNOW); + + } + return true; + } + + @Override + public String getText(Mode mode) { + return "All nonland permanents are legendary"; + } +} diff --git a/Mage.Sets/src/mage/sets/Coldsnap.java b/Mage.Sets/src/mage/sets/Coldsnap.java index 0636461c80..60a4328d23 100644 --- a/Mage.Sets/src/mage/sets/Coldsnap.java +++ b/Mage.Sets/src/mage/sets/Coldsnap.java @@ -141,6 +141,7 @@ public class Coldsnap extends ExpansionSet { cards.add(new SetCardInfo("Resize", 117, Rarity.UNCOMMON, mage.cards.r.Resize.class)); cards.add(new SetCardInfo("Rimebound Dead", 69, Rarity.COMMON, mage.cards.r.RimeboundDead.class)); cards.add(new SetCardInfo("Rime Transfusion", 68, Rarity.UNCOMMON, mage.cards.r.RimeTransfusion.class)); + cards.add(new SetCardInfo("Rimefeather Owl", 42, Rarity.RARE, mage.cards.r.RimefeatherOwl.class)); cards.add(new SetCardInfo("Rimescale Dragon", 95, Rarity.RARE, mage.cards.r.RimescaleDragon.class)); cards.add(new SetCardInfo("Rimewind Cryomancer", 43, Rarity.UNCOMMON, mage.cards.r.RimewindCryomancer.class)); cards.add(new SetCardInfo("Rimewind Taskmage", 44, Rarity.COMMON, mage.cards.r.RimewindTaskmage.class)); From 9384bf8df4f68d14c009df92eb69609b5025c988 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 11:40:10 -0400 Subject: [PATCH 4/8] Implemented Apocalypse Sanctuaries --- Mage.Sets/src/mage/cards/a/AnaSanctuary.java | 101 ++++++++++++++++++ Mage.Sets/src/mage/cards/c/CetaSanctuary.java | 80 ++------------ Mage.Sets/src/mage/cards/d/DegaSanctuary.java | 65 +++++++++++ .../src/mage/cards/n/NecraSanctuary.java | 67 ++++++++++++ Mage.Sets/src/mage/cards/r/RakaSanctuary.java | 67 ++++++++++++ Mage.Sets/src/mage/sets/Apocalypse.java | 4 + .../common/SanctuaryTriggeredAbility.java | 80 ++++++++++++++ 7 files changed, 393 insertions(+), 71 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/a/AnaSanctuary.java create mode 100644 Mage.Sets/src/mage/cards/d/DegaSanctuary.java create mode 100644 Mage.Sets/src/mage/cards/n/NecraSanctuary.java create mode 100644 Mage.Sets/src/mage/cards/r/RakaSanctuary.java create mode 100644 Mage/src/main/java/mage/abilities/common/SanctuaryTriggeredAbility.java diff --git a/Mage.Sets/src/mage/cards/a/AnaSanctuary.java b/Mage.Sets/src/mage/cards/a/AnaSanctuary.java new file mode 100644 index 0000000000..8b8584ecba --- /dev/null +++ b/Mage.Sets/src/mage/cards/a/AnaSanctuary.java @@ -0,0 +1,101 @@ +/* + * 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.a; + +import java.util.UUID; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SanctuaryTriggeredAbility; +import mage.abilities.effects.ContinuousEffect; +import mage.abilities.effects.OneShotEffect; +import mage.abilities.effects.common.continuous.BoostTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.game.Game; +import mage.target.common.TargetCreaturePermanent; +import mage.target.targetpointer.FixedTarget; + +/** + * + * @author TheElk801 + */ +public class AnaSanctuary extends CardImpl { + + public AnaSanctuary(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}"); + + // At the beginning of your upkeep, if you control a blue or black permanent, target creature gets +1/+1 until end of turn. If you control a blue permanent and a black permanent, that creature gets +5/+5 until end of turn instead. + Ability ability = new SanctuaryTriggeredAbility( + new BoostEffect(1), new BoostEffect(5), ObjectColor.BLACK, ObjectColor.BLUE, + "At the beginning of your upkeep, if you control a blue or black permanent, " + + "target creature gets +1/+1 until end of turn. If you control a blue permanent and a black permanent, that creature gets +5/+5 until end of turn instead." + ); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public AnaSanctuary(final AnaSanctuary card) { + super(card); + } + + @Override + public AnaSanctuary copy() { + return new AnaSanctuary(this); + } +} + +class BoostEffect extends OneShotEffect { + + private final int amount; + + BoostEffect(int amount) { + super(Outcome.Benefit); + this.amount = amount; + } + + BoostEffect(final BoostEffect effect) { + super(effect); + this.amount = effect.amount; + } + + @Override + public BoostEffect copy() { + return new BoostEffect(this); + } + + @Override + public boolean apply(Game game, Ability source) { + ContinuousEffect effect = new BoostTargetEffect(amount, amount, Duration.EndOfTurn); + effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); + game.addEffect(effect, source); + return true; + } +} diff --git a/Mage.Sets/src/mage/cards/c/CetaSanctuary.java b/Mage.Sets/src/mage/cards/c/CetaSanctuary.java index ef3a88fc4d..7a126b0743 100644 --- a/Mage.Sets/src/mage/cards/c/CetaSanctuary.java +++ b/Mage.Sets/src/mage/cards/c/CetaSanctuary.java @@ -30,44 +30,28 @@ package mage.cards.c; import java.util.UUID; import mage.ObjectColor; import mage.abilities.Ability; -import mage.abilities.TriggeredAbility; -import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; -import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; -import mage.abilities.decorator.ConditionalTriggeredAbility; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.common.SanctuaryTriggeredAbility; +import mage.abilities.effects.common.DrawDiscardControllerEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; -import mage.constants.TargetController; -import mage.constants.Zone; -import mage.filter.common.FilterControlledPermanent; -import mage.filter.predicate.Predicates; -import mage.filter.predicate.mageobject.ColorPredicate; -import mage.game.Game; -import mage.game.permanent.Permanent; -import mage.players.Player; /** * - * @author Pete Rossi + * @author TheElk801 */ public class CetaSanctuary extends CardImpl { - private static final FilterControlledPermanent filter = new FilterControlledPermanent("a red or green permanent"); - - static { - filter.add(Predicates.or(new ColorPredicate(ObjectColor.RED), new ColorPredicate(ObjectColor.GREEN))); - } - public CetaSanctuary(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}"); // At the beginning of your upkeep, if you control a red or green permanent, draw a card, then discard a card. If you control a red permanent and a green permanent, instead draw two cards, then discard a card. - TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new CetaSanctuaryEffect(), TargetController.YOU, true); - this.addAbility(new ConditionalTriggeredAbility(ability, new PermanentsOnTheBattlefieldCondition(filter), - "At the beginning of your upkeep, if you control a red or green permanent, draw a card, then discard a card. If you control a red permanent and a green permanent, instead draw two cards, then discard a card.")); - + Ability ability = new SanctuaryTriggeredAbility( + new DrawDiscardControllerEffect(1, 1), new DrawDiscardControllerEffect(2, 1), ObjectColor.GREEN, ObjectColor.RED, + "At the beginning of your upkeep, if you control a red or green permanent, draw a card, then discard a card. " + + "If you control a red permanent and a green permanent, instead draw two cards, then discard a card." + ); + this.addAbility(ability); } public CetaSanctuary(final CetaSanctuary card) { @@ -79,49 +63,3 @@ public class CetaSanctuary extends CardImpl { return new CetaSanctuary(this); } } - -class CetaSanctuaryEffect extends OneShotEffect { - - public CetaSanctuaryEffect() { - super(Outcome.DrawCard); - } - - public CetaSanctuaryEffect(final CetaSanctuaryEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { - int red = 0; - int green = 0; - for (Permanent permanent : game.getBattlefield().getAllActivePermanents(controller.getId())) { - ObjectColor color = permanent.getColor(game); - if (color.isRed()) { - red = 1; - } - if (color.isGreen()) { - green = 1; - } - - if (red == 1 && green == 1) { - break; - } - } - - if (red != 0 || green != 0) { - controller.drawCards((red + green), game); - controller.discard(1, false, source, game); - return true; - } - } - return false; - - } - - @Override - public CetaSanctuaryEffect copy() { - return new CetaSanctuaryEffect(this); - } -} diff --git a/Mage.Sets/src/mage/cards/d/DegaSanctuary.java b/Mage.Sets/src/mage/cards/d/DegaSanctuary.java new file mode 100644 index 0000000000..67141fe4cb --- /dev/null +++ b/Mage.Sets/src/mage/cards/d/DegaSanctuary.java @@ -0,0 +1,65 @@ +/* + * 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.d; + +import java.util.UUID; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SanctuaryTriggeredAbility; +import mage.abilities.effects.common.GainLifeEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; + +/** + * + * @author TheElk801 + */ +public class DegaSanctuary extends CardImpl { + + public DegaSanctuary(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{W}"); + + // At the beginning of your upkeep, if you control a black or red permanent, you gain 2 life. If you control a black permanent and a red permanent, you gain 4 life instead. + Ability ability = new SanctuaryTriggeredAbility( + new GainLifeEffect(2), new GainLifeEffect(4), ObjectColor.BLACK, ObjectColor.RED, + "At the beginning of your upkeep, if you control a black or red permanent, you gain 2 life. " + + "If you control a black permanent and a red permanent, you gain 4 life instead." + ); + this.addAbility(ability); + } + + public DegaSanctuary(final DegaSanctuary card) { + super(card); + } + + @Override + public DegaSanctuary copy() { + return new DegaSanctuary(this); + } +} diff --git a/Mage.Sets/src/mage/cards/n/NecraSanctuary.java b/Mage.Sets/src/mage/cards/n/NecraSanctuary.java new file mode 100644 index 0000000000..0658d639c7 --- /dev/null +++ b/Mage.Sets/src/mage/cards/n/NecraSanctuary.java @@ -0,0 +1,67 @@ +/* + * 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.n; + +import java.util.UUID; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SanctuaryTriggeredAbility; +import mage.abilities.effects.common.LoseLifeTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.target.TargetPlayer; + +/** + * + * @author TheElk801 + */ +public class NecraSanctuary extends CardImpl { + + public NecraSanctuary(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}"); + + // At the beginning of your upkeep, if you control a green or white permanent, target player loses 1 life. If you control a green permanent and a white permanent, that player loses 3 life instead. + Ability ability = new SanctuaryTriggeredAbility( + new LoseLifeTargetEffect(1), new LoseLifeTargetEffect(3), ObjectColor.GREEN, ObjectColor.WHITE, + "At the beginning of your upkeep, if you control a green or white permanent, " + + "target player loses 1 life. If you control a green permanent and a white permanent, that player loses 3 life instead." + ); + ability.addTarget(new TargetPlayer()); + this.addAbility(ability); + } + + public NecraSanctuary(final NecraSanctuary card) { + super(card); + } + + @Override + public NecraSanctuary copy() { + return new NecraSanctuary(this); + } +} diff --git a/Mage.Sets/src/mage/cards/r/RakaSanctuary.java b/Mage.Sets/src/mage/cards/r/RakaSanctuary.java new file mode 100644 index 0000000000..2ee93f4a45 --- /dev/null +++ b/Mage.Sets/src/mage/cards/r/RakaSanctuary.java @@ -0,0 +1,67 @@ +/* + * 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.r; + +import java.util.UUID; +import mage.ObjectColor; +import mage.abilities.Ability; +import mage.abilities.common.SanctuaryTriggeredAbility; +import mage.abilities.effects.common.DamageTargetEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.target.common.TargetCreaturePermanent; + +/** + * + * @author TheElk801 + */ +public class RakaSanctuary extends CardImpl { + + public RakaSanctuary(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}"); + + // At the beginning of your upkeep, if you control a white or blue permanent, Raka Sanctuary deals 1 damage to target creature. If you control a white permanent and a blue permanent, Raka Sanctuary deals 3 damage to that creature instead. + Ability ability = new SanctuaryTriggeredAbility( + new DamageTargetEffect(1), new DamageTargetEffect(3), ObjectColor.WHITE, ObjectColor.BLUE, + "At the beginning of your upkeep, if you control a white or blue permanent, Raka Sanctuary deals 1 damage to target creature. " + + "If you control a white permanent and a blue permanent, Raka Sanctuary deals 3 damage to that creature instead." + ); + ability.addTarget(new TargetCreaturePermanent()); + this.addAbility(ability); + } + + public RakaSanctuary(final RakaSanctuary card) { + super(card); + } + + @Override + public RakaSanctuary copy() { + return new RakaSanctuary(this); + } +} diff --git a/Mage.Sets/src/mage/sets/Apocalypse.java b/Mage.Sets/src/mage/sets/Apocalypse.java index 122dc92c5c..4bd813e5bd 100644 --- a/Mage.Sets/src/mage/sets/Apocalypse.java +++ b/Mage.Sets/src/mage/sets/Apocalypse.java @@ -24,6 +24,7 @@ public class Apocalypse extends ExpansionSet { this.ratioBoosterMythic = 0; cards.add(new SetCardInfo("Aether Mutation", 91, Rarity.UNCOMMON, mage.cards.a.AetherMutation.class)); cards.add(new SetCardInfo("Ana Disciple", 73, Rarity.COMMON, mage.cards.a.AnaDisciple.class)); + cards.add(new SetCardInfo("Ana Sanctuary", 74, Rarity.UNCOMMON, mage.cards.a.AnaSanctuary.class)); cards.add(new SetCardInfo("Anavolver", 75, Rarity.RARE, mage.cards.a.Anavolver.class)); cards.add(new SetCardInfo("Angelfire Crusader", 1, Rarity.COMMON, mage.cards.a.AngelfireCrusader.class)); cards.add(new SetCardInfo("Battlefield Forge", 139, Rarity.RARE, mage.cards.b.BattlefieldForge.class)); @@ -45,6 +46,7 @@ public class Apocalypse extends ExpansionSet { cards.add(new SetCardInfo("Death Grasp", 95, Rarity.RARE, mage.cards.d.DeathGrasp.class)); cards.add(new SetCardInfo("Death Mutation", 96, Rarity.UNCOMMON, mage.cards.d.DeathMutation.class)); cards.add(new SetCardInfo("Dega Disciple", 4, Rarity.COMMON, mage.cards.d.DegaDisciple.class)); + cards.add(new SetCardInfo("Dega Sanctuary", 5, Rarity.UNCOMMON, mage.cards.d.DegaSanctuary.class)); cards.add(new SetCardInfo("Degavolver", 6, Rarity.RARE, mage.cards.d.Degavolver.class)); cards.add(new SetCardInfo("Desolation Angel", 38, Rarity.RARE, mage.cards.d.DesolationAngel.class)); cards.add(new SetCardInfo("Desolation Giant", 59, Rarity.RARE, mage.cards.d.DesolationGiant.class)); @@ -99,6 +101,7 @@ public class Apocalypse extends ExpansionSet { cards.add(new SetCardInfo("Mournful Zombie", 43, Rarity.COMMON, mage.cards.m.MournfulZombie.class)); cards.add(new SetCardInfo("Mystic Snake", 112, Rarity.RARE, mage.cards.m.MysticSnake.class)); cards.add(new SetCardInfo("Necra Disciple", 44, Rarity.COMMON, mage.cards.n.NecraDisciple.class)); + cards.add(new SetCardInfo("Necra Sanctuary", 45, Rarity.UNCOMMON, mage.cards.n.NecraSanctuary.class)); cards.add(new SetCardInfo("Necravolver", 46, Rarity.RARE, mage.cards.n.Necravolver.class)); cards.add(new SetCardInfo("Night // Day", 131, Rarity.UNCOMMON, mage.cards.n.NightDay.class)); cards.add(new SetCardInfo("Order // Chaos", 132, Rarity.UNCOMMON, mage.cards.o.OrderChaos.class)); @@ -118,6 +121,7 @@ public class Apocalypse extends ExpansionSet { cards.add(new SetCardInfo("Quagmire Druid", 51, Rarity.COMMON, mage.cards.q.QuagmireDruid.class)); cards.add(new SetCardInfo("Quicksilver Dagger", 118, Rarity.COMMON, mage.cards.q.QuicksilverDagger.class)); cards.add(new SetCardInfo("Raka Disciple", 66, Rarity.COMMON, mage.cards.r.RakaDisciple.class)); + cards.add(new SetCardInfo("Raka Sanctuary", 67, Rarity.UNCOMMON, mage.cards.r.RakaSanctuary.class)); cards.add(new SetCardInfo("Rakavolver", 68, Rarity.RARE, mage.cards.r.Rakavolver.class)); cards.add(new SetCardInfo("Razorfin Hunter", 119, Rarity.COMMON, mage.cards.r.RazorfinHunter.class)); cards.add(new SetCardInfo("Reef Shaman", 29, Rarity.COMMON, mage.cards.r.ReefShaman.class)); diff --git a/Mage/src/main/java/mage/abilities/common/SanctuaryTriggeredAbility.java b/Mage/src/main/java/mage/abilities/common/SanctuaryTriggeredAbility.java new file mode 100644 index 0000000000..9023e003cb --- /dev/null +++ b/Mage/src/main/java/mage/abilities/common/SanctuaryTriggeredAbility.java @@ -0,0 +1,80 @@ +/* + * 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.common; + +import mage.ObjectColor; +import mage.abilities.TriggeredAbility; +import mage.abilities.condition.CompoundCondition; +import mage.abilities.condition.Condition; +import mage.abilities.condition.InvertCondition; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.decorator.ConditionalTriggeredAbility; +import mage.abilities.effects.OneShotEffect; +import mage.constants.TargetController; +import mage.filter.FilterPermanent; +import mage.filter.predicate.Predicates; +import mage.filter.predicate.mageobject.ColorPredicate; + +/** + * + * @author TheElk801 + */ +public class SanctuaryTriggeredAbility extends ConditionalTriggeredAbility { + + private static Condition makeOrCondition(ObjectColor color1, ObjectColor color2) { + FilterPermanent filter = new FilterPermanent(); + filter.add(Predicates.or( + new ColorPredicate(color1), + new ColorPredicate(color2) + )); + return new PermanentsOnTheBattlefieldCondition(filter); + } + + private static Condition makeAndCondition(ObjectColor color1, ObjectColor color2) { + FilterPermanent filter1 = new FilterPermanent(); + filter1.add(new ColorPredicate(color1)); + Condition condition1 = new PermanentsOnTheBattlefieldCondition(filter1); + FilterPermanent filter2 = new FilterPermanent(); + filter2.add(new ColorPredicate(color2)); + Condition condition2 = new PermanentsOnTheBattlefieldCondition(filter2); + return new CompoundCondition(condition1, condition2); + } + + private static TriggeredAbility makeTrigger(OneShotEffect effect1, OneShotEffect effect2, ObjectColor color1, ObjectColor color2) { + TriggeredAbility ability = new BeginningOfUpkeepTriggeredAbility( + new ConditionalOneShotEffect(effect1, new InvertCondition(makeAndCondition(color1, color2))), TargetController.YOU, false + ); + ability.addEffect(new ConditionalOneShotEffect(effect2, makeAndCondition(color1, color2))); + return ability; + } + + public SanctuaryTriggeredAbility(OneShotEffect effect1, OneShotEffect effect2, ObjectColor color1, ObjectColor color2, String text) { + super(makeTrigger(effect1, effect2, color1, color2), makeOrCondition(color1, color2), text); + } +} From fe23e227a6e36f3a6ebe0b4518c93f7f3f3f8d71 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 14:11:11 -0400 Subject: [PATCH 5/8] fixed Ixalan booster count --- Mage.Sets/src/mage/sets/Ixalan.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Mage.Sets/src/mage/sets/Ixalan.java b/Mage.Sets/src/mage/sets/Ixalan.java index d75998cc27..03a3a24910 100644 --- a/Mage.Sets/src/mage/sets/Ixalan.java +++ b/Mage.Sets/src/mage/sets/Ixalan.java @@ -27,7 +27,7 @@ public class Ixalan extends ExpansionSet { this.hasBoosters = true; this.hasBasicLands = true; this.numBoosterLands = 1; - this.numBoosterCommon = 11; + this.numBoosterCommon = 10; this.numBoosterUncommon = 3; this.numBoosterRare = 1; this.ratioBoosterMythic = 8; From c264817f4e986586ed4a2ec6ffe8e2e01c11cd7b Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 14:49:57 -0400 Subject: [PATCH 6/8] fixed Admiral Beckett Brass not triggering correctly when cloned --- .../src/mage/cards/a/AdmiralBeckettBrass.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java b/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java index 84b6dcd8c1..6e97c7ab13 100644 --- a/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java +++ b/Mage.Sets/src/mage/cards/a/AdmiralBeckettBrass.java @@ -65,12 +65,13 @@ import mage.watchers.Watcher; */ public class AdmiralBeckettBrass extends CardImpl { - private final UUID originalId; private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("other Pirates you control"); + private static final FilterNonlandPermanent filter2 = new FilterNonlandPermanent("nonland permanent controlled by a player who was dealt combat damage by three or more Pirates this turn"); static { filter.add(new SubtypePredicate(SubType.PIRATE)); filter.add(new ControllerPredicate(TargetController.YOU)); + filter2.add(new ControllerDealtDamageByPiratesPredicate()); } public AdmiralBeckettBrass(UUID ownerId, CardSetInfo setInfo) { @@ -87,25 +88,12 @@ public class AdmiralBeckettBrass extends CardImpl { // At the beginning of your end step, gain control of target nonland permanent controlled by a player who was dealt combat damage by three or more Pirates this turn. Ability ability = new BeginningOfEndStepTriggeredAbility(new GainControlTargetEffect(Duration.Custom), TargetController.YOU, false); - ability.addTarget(new TargetNonlandPermanent(new FilterNonlandPermanent("nonland permanent controlled by a player who was dealt combat damage by three or more Pirates this turn"))); - originalId = ability.getOriginalId(); + ability.addTarget(new TargetNonlandPermanent(filter2)); this.addAbility(ability, new DamagedByPiratesWatcher()); } public AdmiralBeckettBrass(final AdmiralBeckettBrass card) { super(card); - this.originalId = card.originalId; - } - - @Override - public void adjustTargets(Ability ability, Game game) { - if (ability.getOriginalId().equals(originalId)) { - ability.getTargets().clear(); - FilterNonlandPermanent playerFilter = new FilterNonlandPermanent("nonland permanent controlled by a player who was dealt combat damage by three or more Pirates this turn"); - playerFilter.add(new ControllerDealtDamageByPiratesPredicate()); - TargetNonlandPermanent target = new TargetNonlandPermanent(1, 1, playerFilter, true); - ability.addTarget(target); - } } @Override From ad1c3ae79a66b16cbe0de3b5ca0042d4fbc06a26 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 14:59:47 -0400 Subject: [PATCH 7/8] small nonfunctional change to Mathas, Fiend Seeker --- Mage.Sets/src/mage/cards/m/MathasFiendSeeker.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Mage.Sets/src/mage/cards/m/MathasFiendSeeker.java b/Mage.Sets/src/mage/cards/m/MathasFiendSeeker.java index 5e9422278a..60a0c81692 100644 --- a/Mage.Sets/src/mage/cards/m/MathasFiendSeeker.java +++ b/Mage.Sets/src/mage/cards/m/MathasFiendSeeker.java @@ -83,9 +83,7 @@ public class MathasFiendSeeker extends CardImpl { ability.addTarget(new TargetCreaturePermanent(filter)); Ability ability2 = new DiesTriggeredAbility(new DrawCardAllEffect(1, TargetController.OPPONENT)); ability2.addEffect(new OpponentsGainLifeEffect()); - Effect effect = new MathasFiendSeekerGainAbilityEffect( - ability2, - Duration.Custom, rule); + Effect effect = new MathasFiendSeekerGainAbilityEffect(ability2, Duration.Custom, rule); ability.addEffect(effect); this.addAbility(ability); } @@ -112,8 +110,8 @@ class MathasFiendSeekerGainAbilityEffect extends GainAbilityTargetEffect { @Override public boolean isInactive(Ability source, Game game) { - Permanent land = game.getPermanent(this.targetPointer.getFirst(game, source)); - if (land != null && land.getCounters(game).getCount(CounterType.BOUNTY) < 1) { + Permanent creature = game.getPermanent(this.targetPointer.getFirst(game, source)); + if (creature != null && creature.getCounters(game).getCount(CounterType.BOUNTY) < 1) { return true; } return false; @@ -129,7 +127,7 @@ class OpponentsGainLifeEffect extends OneShotEffect { public OpponentsGainLifeEffect() { super(Outcome.GainLife); - staticText = "Each opponent gains 2 life."; + staticText = "and gains 2 life."; } public OpponentsGainLifeEffect(final OpponentsGainLifeEffect effect) { From cfb7ba82fb5e86e62db38aea00870233cb93f7c9 Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Thu, 21 Sep 2017 21:17:14 -0400 Subject: [PATCH 8/8] changed how Hope of Ghirapur's ability works, making it copiable --- .../src/mage/cards/h/HopeOfGhirapur.java | 73 ++++++++----------- 1 file changed, 31 insertions(+), 42 deletions(-) diff --git a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java index 07c212e770..7111d06e4d 100644 --- a/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java +++ b/Mage.Sets/src/mage/cards/h/HopeOfGhirapur.java @@ -33,7 +33,6 @@ import java.util.Set; import java.util.UUID; import mage.MageInt; import mage.MageObject; -import mage.MageObjectReference; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.costs.common.SacrificeSourceCost; @@ -44,7 +43,8 @@ import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.FilterPlayer; -import mage.filter.predicate.Predicate; +import mage.filter.predicate.ObjectSourcePlayer; +import mage.filter.predicate.ObjectSourcePlayerPredicate; import mage.game.Game; import mage.game.events.DamagedPlayerEvent; import mage.game.events.GameEvent; @@ -59,6 +59,12 @@ import mage.watchers.Watcher; */ public class HopeOfGhirapur extends CardImpl { + private static final FilterPlayer filter = new FilterPlayer("player who was dealt combat damage by {this} this turn"); + + static { + filter.add(new HopeOfGhirapurPlayerLostLifePredicate()); + } + public HopeOfGhirapur(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{1}"); @@ -70,28 +76,10 @@ public class HopeOfGhirapur extends CardImpl { // Flying this.addAbility(FlyingAbility.getInstance()); - //TODO: Make ability properly copiable // Sacrifice Hope of Ghirapur: Until your next turn, target player who was dealt combat damage by Hope of Ghirapur this turn can't cast noncreature spells. Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HopeOfGhirapurCantCastEffect(), new SacrificeSourceCost()); - ability.addTarget(new TargetPlayer()); + ability.addTarget(new TargetPlayer(1, 1, false, filter)); this.addAbility(ability, new HopeOfGhirapurCombatDamageWatcher()); - - } - - @Override - public void adjustTargets(Ability ability, Game game) { - if (ability instanceof SimpleActivatedAbility) { - if (!ability.getEffects().isEmpty() && (ability.getEffects().get(0) instanceof HopeOfGhirapurCantCastEffect)) { - MageObject sourceObject = ability.getSourceObject(game); - if (sourceObject != null) { - ability.getTargets().clear(); - FilterPlayer playerFilter = new FilterPlayer("player who was dealt combat damage by " + sourceObject.getIdName() + " this turn"); - MageObjectReference sourceReference = new MageObjectReference(ability.getSourceId(), ability.getSourceObjectZoneChangeCounter(), game); - playerFilter.add(new HopeOfGhirapurPlayerLostLifePredicate(sourceReference)); - ability.addTarget(new TargetPlayer(1, 1, false, playerFilter)); - } - } - } } public HopeOfGhirapur(final HopeOfGhirapur card) { @@ -152,19 +140,20 @@ class HopeOfGhirapurCantCastEffect extends ContinuousRuleModifyingEffectImpl { } } -class HopeOfGhirapurPlayerLostLifePredicate implements Predicate { +class HopeOfGhirapurPlayerLostLifePredicate implements ObjectSourcePlayerPredicate> { - private final MageObjectReference sourceReference; - - public HopeOfGhirapurPlayerLostLifePredicate(MageObjectReference sourceReference) { - this.sourceReference = sourceReference; + public HopeOfGhirapurPlayerLostLifePredicate() { } @Override - public boolean apply(Player input, Game game) { + public boolean apply(ObjectSourcePlayer input, Game game) { + Player targetPlayer = input.getObject(); + if (targetPlayer == null) { + return false; + } HopeOfGhirapurCombatDamageWatcher watcher = (HopeOfGhirapurCombatDamageWatcher) game.getState().getWatchers().get(HopeOfGhirapurCombatDamageWatcher.class.getSimpleName()); if (watcher != null) { - return watcher.playerGotCombatDamage(sourceReference, input.getId()); + return watcher.playerGotCombatDamage(input.getSourceId(), input.getObject().getId()); } return false; } @@ -172,7 +161,7 @@ class HopeOfGhirapurPlayerLostLifePredicate implements Predicate { class HopeOfGhirapurCombatDamageWatcher extends Watcher { - private final HashMap> combatDamagedPlayers = new HashMap<>(); + private final HashMap> combatDamagedPlayers = new HashMap<>(); public HopeOfGhirapurCombatDamageWatcher() { super(HopeOfGhirapurCombatDamageWatcher.class.getSimpleName(), WatcherScope.GAME); @@ -180,10 +169,10 @@ class HopeOfGhirapurCombatDamageWatcher extends Watcher { public HopeOfGhirapurCombatDamageWatcher(final HopeOfGhirapurCombatDamageWatcher watcher) { super(watcher); - for (MageObjectReference sourceReference : watcher.combatDamagedPlayers.keySet()) { + for (UUID damagerId : watcher.combatDamagedPlayers.keySet()) { Set players = new HashSet<>(); - players.addAll(watcher.combatDamagedPlayers.get(sourceReference)); - this.combatDamagedPlayers.put(sourceReference, players); + players.addAll(watcher.combatDamagedPlayers.get(damagerId)); + this.combatDamagedPlayers.put(damagerId, players); } } @@ -195,29 +184,29 @@ class HopeOfGhirapurCombatDamageWatcher extends Watcher { @Override public void watch(GameEvent event, Game game) { if (event.getType() == EventType.DAMAGED_PLAYER && ((DamagedPlayerEvent) event).isCombatDamage()) { - MageObjectReference sourceReference = new MageObjectReference(event.getSourceId(), game); + UUID damagerId = event.getSourceId(); Set players; - if (combatDamagedPlayers.containsKey(sourceReference)) { - players = combatDamagedPlayers.get(sourceReference); + if (combatDamagedPlayers.containsKey(damagerId)) { + players = combatDamagedPlayers.get(damagerId); } else { players = new HashSet<>(); - combatDamagedPlayers.put(sourceReference, players); + combatDamagedPlayers.put(damagerId, players); } players.add(event.getTargetId()); } } /** - * Checks if the current object has damaged the player during - * the current turn. + * Checks if the current object has damaged the player during the current + * turn. * - * @param objectReference + * @param objectId * @param playerId * @return */ - public boolean playerGotCombatDamage(MageObjectReference objectReference, UUID playerId) { - if (combatDamagedPlayers.containsKey(objectReference)) { - return combatDamagedPlayers.get(objectReference).contains(playerId); + public boolean playerGotCombatDamage(UUID objectId, UUID playerId) { + if (combatDamagedPlayers.containsKey(objectId)) { + return combatDamagedPlayers.get(objectId).contains(playerId); } return false; }