use of mage.choices.Choice in project mage by magefree.
the class AnyColorPermanentTypesManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Mana types = getManaTypes(game, source);
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a mana color");
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (!onlyColors && types.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
if (types.getAny() > 0) {
choice.getChoices().add("Black");
choice.getChoices().add("Red");
choice.getChoices().add("Blue");
choice.getChoices().add("Green");
choice.getChoices().add("White");
if (!onlyColors) {
choice.getChoices().add("Colorless");
}
}
if (!choice.getChoices().isEmpty()) {
Player player = game.getPlayer(source.getControllerId());
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!player.choose(outcome, choice, game)) {
return mana;
}
}
if (choice.getChoice() != null) {
switch(choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
case "Colorless":
mana.setColorless(1);
break;
}
}
}
return mana;
}
use of mage.choices.Choice in project mage by magefree.
the class CommanderIdentityManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Choice choice = new ChoiceImpl();
choice.setMessage("Pick a mana color");
for (UUID commanderId : game.getCommandersIds(controller, CommanderCardType.COMMANDER_OR_OATHBREAKER, false)) {
Card commander = game.getCard(commanderId);
if (commander != null) {
FilterMana commanderMana = commander.getColorIdentity();
if (commanderMana.isWhite()) {
choice.getChoices().add("White");
}
if (commanderMana.isBlue()) {
choice.getChoices().add("Blue");
}
if (commanderMana.isBlack()) {
choice.getChoices().add("Black");
}
if (commanderMana.isRed()) {
choice.getChoices().add("Red");
}
if (commanderMana.isGreen()) {
choice.getChoices().add("Green");
}
}
}
if (!choice.getChoices().isEmpty()) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!controller.choose(outcome, choice, game)) {
return mana;
}
}
switch(choice.getChoice()) {
case "Black":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
}
}
}
return mana;
}
use of mage.choices.Choice in project mage by magefree.
the class ElementalResonanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent thisPerm = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (thisPerm == null) {
return false;
}
Permanent permanent = game.getPermanentOrLKIBattlefield(thisPerm.getAttachedTo());
if (permanent == null) {
return false;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<String> manaOptions = new ArrayList<>();
// TODO: Phyrexian mana gives multiple choices when there should only be one (e.g. Slash Panther is {4} or {4}{R}).
for (Mana mana : permanent.getManaCost().getOptions()) {
String manaString = mana.toString();
if (!manaOptions.contains(manaString)) {
manaOptions.add(manaString);
}
}
String manaToAdd = "";
if (manaOptions.size() > 1) {
// TODO: Make the choices look nicer, right now the brace notation is hard to visually parse, especially with Reaper King
Choice choice = new ChoiceImpl();
choice.setMessage("Choose a mana combination");
choice.getChoices().addAll(manaOptions);
if (!controller.choose(Outcome.PutManaInPool, choice, game)) {
return false;
}
manaToAdd = choice.getChoice();
} else if (manaOptions.size() == 1) {
manaToAdd = manaOptions.get(0);
}
if (!manaToAdd.equals("")) {
controller.getManaPool().addMana(getManaFromString(manaToAdd), game, source);
}
return true;
}
use of mage.choices.Choice in project mage by magefree.
the class GoblinClearCutterManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
Choice manaChoice = new ChoiceImpl();
Set<String> choices = new LinkedHashSet<>();
choices.add("Red");
choices.add("Green");
manaChoice.setChoices(choices);
manaChoice.setMessage("Select color of mana to add");
for (int i = 0; i < 3; i++) {
if (!player.choose(Outcome.Benefit, manaChoice, game)) {
return mana;
}
switch(manaChoice.getChoice()) {
case "Green":
mana.increaseGreen();
break;
case "Red":
mana.increaseRed();
break;
}
}
}
return mana;
}
use of mage.choices.Choice in project mage by magefree.
the class GrimdancerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (player == null || permanent == null) {
return false;
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose two abilities");
choice.setChoices(choices);
if (!player.choose(outcome, choice, game)) {
return false;
}
Counter counter1 = null;
Counter counter2 = null;
switch(choice.getChoice()) {
case "Menace and deathtouch":
counter1 = CounterType.MENACE.createInstance();
counter2 = CounterType.DEATHTOUCH.createInstance();
break;
case "Menace and lifelink":
counter1 = CounterType.MENACE.createInstance();
counter2 = CounterType.LIFELINK.createInstance();
break;
case "Deathtouch and lifelink":
counter1 = CounterType.DEATHTOUCH.createInstance();
counter2 = CounterType.LIFELINK.createInstance();
break;
}
permanent.addCounters(counter1, source.getControllerId(), source, game);
permanent.addCounters(counter2, source.getControllerId(), source, game);
return true;
}
Aggregations