From 940fe603c6f16f111e5e7fed58c9868e87ebf290 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 30 Apr 2018 23:15:48 +0200 Subject: [PATCH] * Herald's Horn - Fixed that cast cost reduction was also applied to other players. --- Mage.Sets/src/mage/cards/h/HeraldsHorn.java | 19 +++++++++---------- .../cost/SpellsCostReductionAllEffect.java | 13 +++++++++++-- ...CostReductionAllOfChosenSubtypeEffect.java | 6 +++++- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/Mage.Sets/src/mage/cards/h/HeraldsHorn.java b/Mage.Sets/src/mage/cards/h/HeraldsHorn.java index 1ad4c814a3..cadce2f3ce 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldsHorn.java +++ b/Mage.Sets/src/mage/cards/h/HeraldsHorn.java @@ -27,6 +27,7 @@ */ package mage.cards.h; +import java.util.UUID; import mage.MageObject; import mage.abilities.Ability; import mage.abilities.common.AsEntersBattlefieldAbility; @@ -45,8 +46,6 @@ import mage.filter.predicate.mageobject.ChosenSubtypePredicate; import mage.game.Game; import mage.players.Player; -import java.util.UUID; - /** * * @author Saga @@ -54,15 +53,15 @@ import java.util.UUID; public class HeraldsHorn extends CardImpl { public HeraldsHorn(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{3}"); + super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{3}"); // As Herald's Horn enters the battlefield, choose a creature type. this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.BoostCreature))); - + // Creature spells you cast of the chosen type cost {1} less to cast. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, - new SpellsCostReductionAllOfChosenSubtypeEffect(new FilterCreatureCard("Creature spells you cast of the chosen type"), 1))); - + new SpellsCostReductionAllOfChosenSubtypeEffect(new FilterCreatureCard("Creature spells you cast of the chosen type"), 1, true))); + // At the beginning of your upkeep, look at the top card of your library. If it's a creature card of the chosen type, you may reveal it and put it into your hand. this.addAbility(new BeginningOfUpkeepTriggeredAbility(Zone.BATTLEFIELD, new HeraldsHornEffect(), TargetController.YOU, false)); } @@ -97,21 +96,21 @@ class HeraldsHornEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); - + // Look at the top card of your library. if (controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); Cards cards = new CardsImpl(card); controller.lookAtCards(sourceObject.getIdName(), cards, game); - + // If it's a creature card of the chosen type, you may reveal it and put it into your hand. FilterCreatureCard filter = new FilterCreatureCard("creature card of the chosen type"); filter.add(new ChosenSubtypePredicate(source.getSourceId())); String message = "Reveal the top card of your library and put that card into your hand?"; if (card != null) { if (filter.match(card, game) && controller.chooseUse(Outcome.Benefit, message, source, game)) { - controller.moveCards(card, Zone.HAND, source, game); - controller.revealCards(sourceObject.getIdName() + " put into hand", cards, game); + controller.moveCards(card, Zone.HAND, source, game); + controller.revealCards(sourceObject.getIdName() + " put into hand", cards, game); } } } diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java index 0b7af33808..c66870598c 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllEffect.java @@ -53,6 +53,7 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl { private FilterCard filter; private int amount; private final boolean upTo; + private boolean onlyControlled; public SpellsCostReductionAllEffect(int amount) { this(new FilterCard("Spells"), amount); @@ -63,19 +64,24 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl { } public SpellsCostReductionAllEffect(FilterCard filter, int amount, boolean upTo) { + this(filter, amount, upTo, false); + } + + public SpellsCostReductionAllEffect(FilterCard filter, int amount, boolean upTo, boolean onlyControlled) { super(Duration.WhileOnBattlefield, Outcome.Benefit, CostModificationType.REDUCE_COST); this.filter = filter; this.amount = amount; this.upTo = upTo; - + this.onlyControlled = onlyControlled; this.staticText = filter.getMessage() + " cost " + (upTo ? "up to " : "") + '{' + amount + "} less to cast"; } - protected SpellsCostReductionAllEffect(SpellsCostReductionAllEffect effect) { + protected SpellsCostReductionAllEffect(final SpellsCostReductionAllEffect effect) { super(effect); this.filter = effect.filter; this.amount = effect.amount; this.upTo = effect.upTo; + this.onlyControlled = effect.onlyControlled; } @Override @@ -136,6 +142,9 @@ public class SpellsCostReductionAllEffect extends CostModificationEffectImpl { @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { + if (onlyControlled && abilityToModify.getControllerId().equals(source.getControllerId())) { + return false; + } if (abilityToModify instanceof SpellAbility) { Spell spell = (Spell) game.getStack().getStackObject(abilityToModify.getId()); if (spell != null) { diff --git a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java index 71185730ca..4a8fdf40d0 100644 --- a/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java +++ b/Mage/src/main/java/mage/abilities/effects/common/cost/SpellsCostReductionAllOfChosenSubtypeEffect.java @@ -19,7 +19,11 @@ import mage.game.Game; public class SpellsCostReductionAllOfChosenSubtypeEffect extends SpellsCostReductionAllEffect { public SpellsCostReductionAllOfChosenSubtypeEffect(FilterCard filter, int amount) { - super(filter, amount); + this(filter, amount, false); + } + + public SpellsCostReductionAllOfChosenSubtypeEffect(FilterCard filter, int amount, boolean onlyControlled) { + super(filter, amount, false, onlyControlled); } public SpellsCostReductionAllOfChosenSubtypeEffect(final SpellsCostReductionAllOfChosenSubtypeEffect effect) {