use of mage.choices.ChoiceColor in project mage by magefree.
the class DynamicManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana computedMana = new Mana();
if (game == null) {
return computedMana;
}
int count = amount.calculate(game, source, this);
if (baseMana.getBlack() > 0) {
computedMana.setBlack(count);
} else if (baseMana.getBlue() > 0) {
computedMana.setBlue(count);
} else if (baseMana.getGreen() > 0) {
computedMana.setGreen(count);
} else if (baseMana.getRed() > 0) {
computedMana.setRed(count);
} else if (baseMana.getWhite() > 0) {
computedMana.setWhite(count);
} else if (baseMana.getColorless() > 0) {
computedMana.setColorless(count);
} else if (baseMana.getAny() > 0) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && count > 0) {
if (oneChoice || count == 1) {
ChoiceColor choice = new ChoiceColor(true);
controller.choose(outcome, choice, game);
if (choice.getChoice() == null) {
return computedMana;
}
computedMana.add(choice.getMana(count));
} else {
List<String> manaStrings = new ArrayList<>(5);
manaStrings.add("W");
manaStrings.add("U");
manaStrings.add("B");
manaStrings.add("R");
manaStrings.add("G");
List<Integer> choices = controller.getMultiAmount(this.outcome, manaStrings, 0, count, MultiAmountType.MANA, game);
computedMana.add(new Mana(choices.get(0), choices.get(1), choices.get(2), choices.get(3), choices.get(4), 0, 0, 0));
}
}
} else {
computedMana.setGeneric(count);
}
return computedMana;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class CrosisThePurgerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
ChoiceColor choice = new ChoiceColor();
player.choose(outcome, choice, game);
if (!choice.isChosen()) {
return false;
}
game.informPlayers(player.getLogName() + " chooses " + choice.getColor());
Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source));
if (damagedPlayer == null) {
return false;
}
damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game);
Cards cards = new CardsImpl(damagedPlayer.getHand().getCards(game).stream().filter(card -> card.getColor(game).shares(choice.getColor())).collect(Collectors.toSet()));
damagedPlayer.discard(cards, false, source, game);
return true;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class ChromeMoxManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Permanent permanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (permanent != null && player != null) {
List<UUID> imprinted = permanent.getImprinted();
if (imprinted != null && !imprinted.isEmpty()) {
Card imprintedCard = game.getCard(imprinted.get(0));
if (imprintedCard != null) {
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a mana color");
ObjectColor color = imprintedCard.getColor(game);
if (color.isBlack()) {
choice.getChoices().add("Black");
}
if (color.isRed()) {
choice.getChoices().add("Red");
}
if (color.isBlue()) {
choice.getChoices().add("Blue");
}
if (color.isGreen()) {
choice.getChoices().add("Green");
}
if (color.isWhite()) {
choice.getChoices().add("White");
}
if (!choice.getChoices().isEmpty()) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!player.choose(outcome, choice, game)) {
return mana;
}
}
switch(choice.getChoice()) {
case "Black":
// player.getManaPool().addMana(Mana.BlackMana(1), game, source);
mana.add(Mana.BlackMana(1));
break;
case "Blue":
// player.getManaPool().addMana(Mana.BlueMana(1), game, source);
mana.add(Mana.BlueMana(1));
break;
case "Red":
// player.getManaPool().addMana(Mana.RedMana(1), game, source);
mana.add(Mana.RedMana(1));
break;
case "Green":
// player.getManaPool().addMana(Mana.GreenMana(1), game, source);
mana.add(Mana.GreenMana(1));
break;
case "White":
// player.getManaPool().addMana(Mana.WhiteMana(1), game, source);
mana.add(Mana.WhiteMana(1));
break;
default:
break;
}
}
}
}
}
return mana;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class DromarTheBanisherEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
ChoiceColor choice = new ChoiceColor();
if (player.choose(outcome, choice, game)) {
game.informPlayers(player.getLogName() + " chooses " + choice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
new ReturnToHandFromBattlefieldAllEffect(filter).apply(game, source);
return true;
}
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class EmpoweredAutogeneratorManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
game.getState().processAction(game);
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent == null) {
return mana;
}
sourcePermanent.addCounters(CounterType.CHARGE.createInstance(), source.getControllerId(), source, game);
int counters = sourcePermanent.getCounters(game).getCount(CounterType.CHARGE);
if (counters == 0) {
return mana;
}
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return mana;
}
ChoiceColor choice = new ChoiceColor();
choice.setMessage("Choose a color to add mana of that color");
if (!controller.choose(outcome, choice, game)) {
return mana;
}
if (choice.getChoice() == null) {
return mana;
}
String color = choice.getChoice();
switch(color) {
case "Red":
mana.setRed(counters);
break;
case "Blue":
mana.setBlue(counters);
break;
case "White":
mana.setWhite(counters);
break;
case "Black":
mana.setBlack(counters);
break;
case "Green":
mana.setGreen(counters);
break;
}
return mana;
}
Aggregations