From f1ed6338db2ee0eafb91149fd7139382e3c022bb Mon Sep 17 00:00:00 2001 From: LevelX2 <ludwig.hirth@online.de> Date: Tue, 19 Aug 2014 17:06:09 +0200 Subject: [PATCH] Fixed alternate cost handling to be able to only user alternate MANA costs (fixes Dream Halls, Fist of Suns and Omniscience to supress also additional costs instead of only mana costs). --- .../src/mage/sets/magic2013/Omniscience.java | 50 +------------------ .../costs/AlternativeCostSourceAbility.java | 19 +++++-- 2 files changed, 17 insertions(+), 52 deletions(-) diff --git a/Mage.Sets/src/mage/sets/magic2013/Omniscience.java b/Mage.Sets/src/mage/sets/magic2013/Omniscience.java index 13efe46d94..522c5525a0 100644 --- a/Mage.Sets/src/mage/sets/magic2013/Omniscience.java +++ b/Mage.Sets/src/mage/sets/magic2013/Omniscience.java @@ -70,58 +70,10 @@ public class Omniscience extends CardImpl { } } -//class OmniscienceEffect extends CostModificationEffectImpl { -// -// public OmniscienceEffect() { -// super(Duration.WhileOnBattlefield, Outcome.PlayForFree, CostModificationType.SET_COST); -// this.staticText = "You may cast nonland cards from your hand without paying their mana costs"; -// } -// -// private OmniscienceEffect(final OmniscienceEffect effect) { -// super(effect); -// } -// -// @Override -// public boolean apply(Game game, Ability source, Ability abilityToModify) { -// SpellAbility spellAbility = (SpellAbility) abilityToModify; -// spellAbility.getManaCostsToPay().clear(); -// return true; -// } -// -// @Override -// public boolean applies(Ability abilityToModify, Ability source, Game game) { -// if (abilityToModify instanceof SpellAbility || abilityToModify instanceof FlashbackAbility || abilityToModify instanceof RetraceAbility) { -// Card sourceCard = game.getCard(abilityToModify.getSourceId()); -// StackObject stackObject = game.getStack().getStackObject(abilityToModify.getSourceId()); -// if (stackObject != null && stackObject instanceof Spell) { -// Zone zone = ((Spell)stackObject).getFromZone(); -// if (zone != null && zone.equals(Zone.HAND)) { -// if (sourceCard != null && sourceCard.getOwnerId().equals(source.getControllerId()) -// && !sourceCard.getCardType().contains(CardType.LAND)) { -// Player player = game.getPlayer(source.getControllerId()); -// String message = "Cast " + sourceCard.getName() + " without paying its mana costs?"; -// if (player != null && -// (CardUtil.isCheckPlayableMode(abilityToModify) || player.chooseUse(outcome, message, game))) { -// return true; -// } -// } -// } -// } -// } -// return false; -// } -// -// @Override -// public OmniscienceEffect copy() { -// return new OmniscienceEffect(this); -// } -//} - - class OmniscienceCastingEffect extends ContinuousEffectImpl { static AlternativeCostSourceAbility alternativeCastingCostAbility = new AlternativeCostSourceAbility( - null, null, null, new FilterNonlandCard()); + null, null, null, new FilterNonlandCard(), true); public OmniscienceCastingEffect() { super(Duration.WhileOnBattlefield, Outcome.Detriment); diff --git a/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java b/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java index 8430dc66ff..73ff5e389c 100644 --- a/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java +++ b/Mage/src/mage/abilities/costs/AlternativeCostSourceAbility.java @@ -50,6 +50,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter protected Condition condition; protected String rule; protected FilterCard filter; + protected boolean onlyMana; public AlternativeCostSourceAbility(Cost cost) { this(cost, null); @@ -64,16 +65,25 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter } public AlternativeCostSourceAbility(Cost cost, Condition condition, String rule) { - this(cost, condition, rule, null); + this(cost, condition, rule, null, true); } - public AlternativeCostSourceAbility(Cost cost, Condition condition, String rule, FilterCard filter) { + /** + * + * @param cost alternate cost to pay + * @param condition only if the condition is true it's possible to use the alternate costs + * @param rule if set used as rule text + * @param filter filters the cards this alternate cost can be applied to + * @param onlyMana if true only the mana costs are replaced by this costs, other costs stay untouched + */ + public AlternativeCostSourceAbility(Cost cost, Condition condition, String rule, FilterCard filter, boolean onlyMana) { super(Zone.ALL, null); this.convertToAlternativeCostAndAdd(cost); this.setRuleAtTheTop(true); this.condition = condition; this.rule = rule; this.filter = filter; + this.onlyMana = onlyMana; } public AlternativeCostSourceAbility(final AlternativeCostSourceAbility ability) { @@ -82,6 +92,7 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter this.condition = ability.condition; this.rule = ability.rule; this.filter = ability.filter; + this.onlyMana = ability.onlyMana; } @Override @@ -123,7 +134,9 @@ public class AlternativeCostSourceAbility extends StaticAbility implements Alter if (alternateCosts.canPay(ability, ability.getSourceId(), ability.getControllerId(), game) && player.chooseUse(Outcome.Detriment, alternateCosts.isEmpty() ? "Cast without paying its mana cost?":"Pay alternative costs? (" + alternateCosts.getText() +")", game)) { ability.getManaCostsToPay().clear(); - ability.getCosts().clear(); + if(!onlyMana) { + ability.getCosts().clear(); + } for (Cost cost : alternateCosts) { AlternativeCost2 alternateCost = (AlternativeCost2) cost; alternateCost.activate();