mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
* Training Grounds - Fixed bug that locked the game if activated ability of own creature had no mana costs.
This commit is contained in:
parent
300081d302
commit
ec692902c7
3 changed files with 36 additions and 28 deletions
|
@ -65,6 +65,8 @@ public class AzamiLadyOfScrolls extends CardImpl<AzamiLadyOfScrolls> {
|
||||||
this.color.setBlue(true);
|
this.color.setBlue(true);
|
||||||
this.power = new MageInt(0);
|
this.power = new MageInt(0);
|
||||||
this.toughness = new MageInt(2);
|
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))));
|
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new DrawCardSourceControllerEffect(1), new TapTargetCost(new TargetControlledPermanent(1, 1, filter, false))));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
package mage.sets.riseoftheeldrazi;
|
package mage.sets.riseoftheeldrazi;
|
||||||
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
import mage.abilities.Ability;
|
import mage.abilities.Ability;
|
||||||
|
@ -91,40 +92,44 @@ class TrainingGroundsEffect extends CostModificationEffectImpl<TrainingGroundsEf
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
Player controller = game.getPlayer(abilityToModify.getControllerId());
|
||||||
int reduceMax = mana.getColorless();
|
if (controller != null){
|
||||||
if(mana.count() == mana.getColorless()){
|
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
||||||
reduceMax--;
|
int reduceMax = mana.getColorless();
|
||||||
}
|
if (reduceMax > 0 && mana.count() == mana.getColorless()){
|
||||||
if(reduceMax > 2){
|
reduceMax--;
|
||||||
reduceMax = 2;
|
}
|
||||||
}
|
if (reduceMax > 2){
|
||||||
Player player = game.getPlayer(abilityToModify.getControllerId());
|
reduceMax = 2;
|
||||||
if(player != null){
|
}
|
||||||
ChoiceImpl choice = new ChoiceImpl(true);
|
if (reduceMax > 0) {
|
||||||
LinkedHashSet<String> set = new LinkedHashSet<String>();
|
ChoiceImpl choice = new ChoiceImpl(true);
|
||||||
|
Set<String> set = new LinkedHashSet<>();
|
||||||
|
|
||||||
for(int i = 0; i <= reduceMax; i++){
|
for(int i = 0; i <= reduceMax; i++){
|
||||||
set.add(String.valueOf(i));
|
set.add(String.valueOf(i));
|
||||||
}
|
}
|
||||||
choice.setChoices(set);
|
choice.setChoices(set);
|
||||||
choice.setMessage("Reduce ability cost");
|
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());
|
int reduce = Integer.parseInt(choice.getChoice());
|
||||||
mana.setColorless(mana.getColorless() - reduce);
|
mana.setColorless(mana.getColorless() - reduce);
|
||||||
abilityToModify.getManaCostsToPay().load(mana.toString());
|
abilityToModify.getManaCostsToPay().load(mana.toString());
|
||||||
return true;
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
public boolean applies(Ability abilityToModify, Ability source, Game game) {
|
||||||
//Activated abilities of creatures you control
|
if (abilityToModify instanceof ActivatedAbility) {
|
||||||
Permanent permanent = game.getPermanent(abilityToModify.getSourceId());
|
//Activated abilities of creatures you control
|
||||||
if (abilityToModify instanceof ActivatedAbility && permanent != null && filter.match(permanent, source.getId(), source.getControllerId(), game)) {
|
Permanent permanent = game.getPermanent(abilityToModify.getSourceId());
|
||||||
return true;
|
if (permanent != null && filter.match(permanent, source.getSourceId(), source.getControllerId(), game)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,13 +35,14 @@ import java.util.Set;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author BetaSteward_at_googlemail.com
|
* @author BetaSteward_at_googlemail.com
|
||||||
|
* @param <T>
|
||||||
*/
|
*/
|
||||||
public class ChoiceImpl<T extends ChoiceImpl<T>> implements Choice, Serializable {
|
public class ChoiceImpl<T extends ChoiceImpl<T>> implements Choice, Serializable {
|
||||||
|
|
||||||
protected boolean chosen;
|
protected boolean chosen;
|
||||||
protected boolean required;
|
protected boolean required;
|
||||||
protected String choice;
|
protected String choice;
|
||||||
protected Set<String> choices = new LinkedHashSet<String>();
|
protected Set<String> choices = new LinkedHashSet<>();
|
||||||
protected String message;
|
protected String message;
|
||||||
|
|
||||||
public ChoiceImpl() {
|
public ChoiceImpl() {
|
||||||
|
|
Loading…
Reference in a new issue