* Training Grounds - Fixed bug that locked the game if activated ability of own creature had no mana costs.

This commit is contained in:
LevelX2 2014-04-25 12:10:57 +02:00
parent 300081d302
commit ec692902c7
3 changed files with 36 additions and 28 deletions

View file

@ -65,6 +65,8 @@ public class AzamiLadyOfScrolls extends CardImpl<AzamiLadyOfScrolls> {
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))));
}

View file

@ -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,41 +92,45 @@ class TrainingGroundsEffect extends CostModificationEffectImpl<TrainingGroundsEf
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
Player controller = game.getPlayer(abilityToModify.getControllerId());
if (controller != null){
Mana mana = abilityToModify.getManaCostsToPay().getMana();
int reduceMax = mana.getColorless();
if(mana.count() == mana.getColorless()){
if (reduceMax > 0 && mana.count() == mana.getColorless()){
reduceMax--;
}
if(reduceMax > 2){
if (reduceMax > 2){
reduceMax = 2;
}
Player player = game.getPlayer(abilityToModify.getControllerId());
if(player != null){
if (reduceMax > 0) {
ChoiceImpl choice = new ChoiceImpl(true);
LinkedHashSet<String> set = new LinkedHashSet<String>();
Set<String> set = new LinkedHashSet<>();
for(int i = 0; i <= reduceMax; i++){
set.add(String.valueOf(i));
}
choice.setChoices(set);
choice.setMessage("Reduce ability cost");
if(player.choose(Outcome.Benefit, choice, game)){
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 true;
}
return false;
}
@Override
public boolean applies(Ability abilityToModify, Ability source, Game game) {
if (abilityToModify instanceof ActivatedAbility) {
//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)) {
if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
return true;
}
}
return false;
}

View file

@ -35,13 +35,14 @@ import java.util.Set;
/**
*
* @author BetaSteward_at_googlemail.com
* @param <T>
*/
public class ChoiceImpl<T extends ChoiceImpl<T>> implements Choice, Serializable {
protected boolean chosen;
protected boolean required;
protected String choice;
protected Set<String> choices = new LinkedHashSet<String>();
protected Set<String> choices = new LinkedHashSet<>();
protected String message;
public ChoiceImpl() {