use of mage.choices.ChoiceImpl in project mage by magefree.
the class FlowstoneSculptureEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add");
choice.setChoices(choices);
if (!controller.choose(outcome, choice, game)) {
return false;
}
String chosen = choice.getChoice();
if (chosen.equals("+1/+1 counter")) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance()).apply(game, source);
} else {
Ability gainedAbility;
switch(chosen) {
case "Flying":
gainedAbility = FlyingAbility.getInstance();
break;
case "First strike":
gainedAbility = FirstStrikeAbility.getInstance();
break;
default:
gainedAbility = TrampleAbility.getInstance();
break;
}
game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.WhileOnBattlefield), source);
return true;
}
}
return false;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class FluctuatorEffect method apply.
@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.getGeneric();
if (reduceMax > 2) {
reduceMax = 2;
}
if (reduceMax > 0) {
int reduce;
if (game.inCheckPlayableState() || controller.isComputer()) {
reduce = reduceMax;
} else {
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 cycling cost");
if (controller.choose(Outcome.Benefit, choice, game)) {
reduce = Integer.parseInt(choice.getChoice());
} else {
return false;
}
}
CardUtil.reduceCost(abilityToModify, reduce);
}
return true;
}
return false;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class InvokeTheAncientsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
token.putOntoBattlefield(2, game, source, source.getControllerId());
for (UUID tokenId : token.getLastAddedTokenIds()) {
Permanent permanent = game.getPermanent(tokenId);
if (permanent == null) {
continue;
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose vigilance, reach, or trample counter");
choice.setChoices(choices);
player.choose(outcome, choice, game);
String chosen = choice.getChoice();
if (chosen != null) {
permanent.addCounters(CounterType.findByName(chosen.toLowerCase(Locale.ENGLISH)).createInstance(), source.getControllerId(), source, game);
}
}
return true;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class LunarAvengerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose ability to add");
choice.setChoices(choices);
if (!controller.choose(outcome, choice, game)) {
return false;
}
Ability gainedAbility;
String chosen = choice.getChoice();
switch(chosen) {
case "Flying":
gainedAbility = FlyingAbility.getInstance();
break;
case "First strike":
gainedAbility = FirstStrikeAbility.getInstance();
break;
default:
gainedAbility = HasteAbility.getInstance();
break;
}
game.addEffect(new GainAbilitySourceEffect(gainedAbility, Duration.EndOfTurn), source);
return true;
}
return false;
}
use of mage.choices.ChoiceImpl in project mage by magefree.
the class PemminsAuraBoostEnchantedEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent enchantment = game.getPermanent(source.getSourceId());
if (controller == null || enchantment == null) {
return false;
}
Permanent creature = game.getPermanent(enchantment.getAttachedTo());
if (creature == null) {
return false;
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Select how to boost");
choice.getChoices().add(CHOICE_1);
choice.getChoices().add(CHOICE_2);
if (controller.choose(outcome, choice, game)) {
if (choice.getChoice().equals(CHOICE_1)) {
game.addEffect(new BoostEnchantedEffect(+1, -1, Duration.EndOfTurn), source);
} else {
game.addEffect(new BoostEnchantedEffect(-1, +1, Duration.EndOfTurn), source);
}
return true;
}
return false;
}
Aggregations