mirror of
https://github.com/correl/mage.git
synced 2024-12-24 11:50:45 +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.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))));
|
||||
}
|
||||
|
||||
|
|
|
@ -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<TrainingGroundsEf
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source, Ability abilityToModify) {
|
||||
Mana mana = abilityToModify.getManaCostsToPay().getMana();
|
||||
int reduceMax = mana.getColorless();
|
||||
if(mana.count() == mana.getColorless()){
|
||||
reduceMax--;
|
||||
}
|
||||
if(reduceMax > 2){
|
||||
reduceMax = 2;
|
||||
}
|
||||
Player player = game.getPlayer(abilityToModify.getControllerId());
|
||||
if(player != null){
|
||||
ChoiceImpl choice = new ChoiceImpl(true);
|
||||
LinkedHashSet<String> set = new LinkedHashSet<String>();
|
||||
|
||||
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<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(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<TrainingGroundsEf
|
|||
public TrainingGroundsEffect copy() {
|
||||
return new TrainingGroundsEffect(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue