From ec692902c7dfc0bc1fe7225ab6599f661ed2f268 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 25 Apr 2014 12:10:57 +0200 Subject: [PATCH] * Training Grounds - Fixed bug that locked the game if activated ability of own creature had no mana costs. --- .../AzamiLadyOfScrolls.java | 2 + .../riseoftheeldrazi/TrainingGrounds.java | 59 ++++++++++--------- Mage/src/mage/choices/ChoiceImpl.java | 3 +- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/Mage.Sets/src/mage/sets/championsofkamigawa/AzamiLadyOfScrolls.java b/Mage.Sets/src/mage/sets/championsofkamigawa/AzamiLadyOfScrolls.java index f2b9016081..da84124583 100644 --- a/Mage.Sets/src/mage/sets/championsofkamigawa/AzamiLadyOfScrolls.java +++ b/Mage.Sets/src/mage/sets/championsofkamigawa/AzamiLadyOfScrolls.java @@ -65,6 +65,8 @@ public class AzamiLadyOfScrolls extends CardImpl { this.color.setBlue(true); this.power = new MageInt(0); this.toughness = new MageInt(2); + + // Tap an untapped Wizard you control: Draw a card. this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapTargetCost(new TargetControlledPermanent(1, 1, filter, false)))); } diff --git a/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java b/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java index 1563f6ce83..b7681dfc9c 100644 --- a/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java +++ b/Mage.Sets/src/mage/sets/riseoftheeldrazi/TrainingGrounds.java @@ -29,6 +29,7 @@ package mage.sets.riseoftheeldrazi; import java.util.LinkedHashSet; +import java.util.Set; import java.util.UUID; import mage.Mana; import mage.abilities.Ability; @@ -91,40 +92,44 @@ class TrainingGroundsEffect extends CostModificationEffectImpl 2){ - reduceMax = 2; - } - Player player = game.getPlayer(abilityToModify.getControllerId()); - if(player != null){ - ChoiceImpl choice = new ChoiceImpl(true); - LinkedHashSet set = new LinkedHashSet(); - - for(int i = 0; i <= reduceMax; i++){ - set.add(String.valueOf(i)); + Player controller = game.getPlayer(abilityToModify.getControllerId()); + if (controller != null){ + Mana mana = abilityToModify.getManaCostsToPay().getMana(); + int reduceMax = mana.getColorless(); + if (reduceMax > 0 && mana.count() == mana.getColorless()){ + reduceMax--; } - choice.setChoices(set); - choice.setMessage("Reduce ability cost"); - if(player.choose(Outcome.Benefit, choice, game)){ - int reduce = Integer.parseInt(choice.getChoice()); - mana.setColorless(mana.getColorless() - reduce); - abilityToModify.getManaCostsToPay().load(mana.toString()); - return true; + if (reduceMax > 2){ + reduceMax = 2; } + if (reduceMax > 0) { + ChoiceImpl choice = new ChoiceImpl(true); + Set set = new LinkedHashSet<>(); + + for(int i = 0; i <= reduceMax; i++){ + set.add(String.valueOf(i)); + } + choice.setChoices(set); + choice.setMessage("Reduce ability cost"); + if(controller.choose(Outcome.Benefit, choice, game)){ + int reduce = Integer.parseInt(choice.getChoice()); + mana.setColorless(mana.getColorless() - reduce); + abilityToModify.getManaCostsToPay().load(mana.toString()); + } + } + return true; } return false; } @Override public boolean applies(Ability abilityToModify, Ability source, Game game) { - //Activated abilities of creatures you control - Permanent permanent = game.getPermanent(abilityToModify.getSourceId()); - if (abilityToModify instanceof ActivatedAbility && permanent != null && filter.match(permanent, source.getId(), source.getControllerId(), game)) { - return true; + if (abilityToModify instanceof ActivatedAbility) { + //Activated abilities of creatures you control + Permanent permanent = game.getPermanent(abilityToModify.getSourceId()); + if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) { + return true; + } } return false; } @@ -133,4 +138,4 @@ class TrainingGroundsEffect extends CostModificationEffectImpl */ public class ChoiceImpl> implements Choice, Serializable { protected boolean chosen; protected boolean required; protected String choice; - protected Set choices = new LinkedHashSet(); + protected Set choices = new LinkedHashSet<>(); protected String message; public ChoiceImpl() {