use of mage.choices.ChoiceColor 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.ChoiceColor in project mage by magefree.
the class ProtectionChosenColorTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
Player player = game.getPlayer(targetCreature.getControllerId());
if (player != null) {
ChoiceColor colorChoice = new ChoiceColor();
if (player.choose(Outcome.Neutral, colorChoice, game)) {
game.informPlayers(targetCreature.getName() + ": " + player.getLogName() + " has chosen " + colorChoice.getChoice());
game.getState().setValue(targetCreature.getId() + "_color", colorChoice.getColor());
ObjectColor protectColor = (ObjectColor) game.getState().getValue(targetCreature.getId() + "_color");
if (protectColor != null) {
ContinuousEffect effect = new ProtectionChosenColorTargetEffect();
effect.setTargetPointer(new FixedTarget(targetCreature, game));
game.addEffect(effect, source);
}
return true;
}
}
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class PrismaticBoonEffect 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();
if (!player.choose(outcome, choice, game)) {
return false;
}
game.addEffect(new GainAbilityTargetEffect(ProtectionAbility.from(choice.getColor()), Duration.EndOfTurn), source);
return true;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class PrismaticStrandsPreventionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
ChoiceColor choice = new ChoiceColor();
controller.choose(Outcome.PreventDamage, choice, game);
if (choice.isChosen()) {
if (!game.isSimulation()) {
game.informPlayers(sourceObject.getLogName() + ": " + controller.getLogName() + " has chosen sources of the color " + choice.getChoice());
}
game.addEffect(new PrismaticStrandsPreventionEffect(choice.getColor()), source);
return true;
}
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class StadiumVendorsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
TargetPlayer target = new TargetPlayer(1, 1, true);
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
Player player = game.getPlayer(target.getFirstTarget());
ChoiceColor colorChoice = new ChoiceColor(true);
if (player == null || !player.choose(Outcome.Benefit, colorChoice, game)) {
return false;
}
Effect effect = new AddManaToManaPoolTargetControllerEffect(colorChoice.getMana(2), "that player's");
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
return false;
}
Aggregations