mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +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;
|
|
||||||
}
|
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
choice.setChoices(set);
|
if (reduceMax > 2){
|
||||||
choice.setMessage("Reduce ability cost");
|
reduceMax = 2;
|
||||||
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 > 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;
|
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;
|
||||||
}
|
}
|
||||||
|
@ -133,4 +138,4 @@ class TrainingGroundsEffect extends CostModificationEffectImpl<TrainingGroundsEf
|
||||||
public TrainingGroundsEffect copy() {
|
public TrainingGroundsEffect copy() {
|
||||||
return new TrainingGroundsEffect(this);
|
return new TrainingGroundsEffect(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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