use of mage.choices.ChoiceColor in project mage by magefree.
the class BecomesColorOrColorsTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent target = game.getPermanent(source.getFirstTarget());
StringBuilder sb = new StringBuilder();
if (controller != null && target != null) {
for (int i = 0; i < 5; i++) {
if (i > 0) {
if (!controller.chooseUse(Outcome.Neutral, "Choose another color?", source, game)) {
break;
}
}
ChoiceColor choiceColor = new ChoiceColor();
if (!controller.choose(Outcome.Benefit, choiceColor, game)) {
return false;
}
if (!game.isSimulation()) {
game.informPlayers(target.getName() + ": " + controller.getLogName() + " has chosen " + choiceColor.getChoice());
}
if (choiceColor.getColor().isBlack()) {
sb.append('B');
} else if (choiceColor.getColor().isBlue()) {
sb.append('U');
} else if (choiceColor.getColor().isRed()) {
sb.append('R');
} else if (choiceColor.getColor().isGreen()) {
sb.append('G');
} else if (choiceColor.getColor().isWhite()) {
sb.append('W');
}
}
String colors = new String(sb);
ObjectColor chosenColors = new ObjectColor(colors);
ContinuousEffect effect = new BecomesColorTargetEffect(chosenColors, duration);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class CouncilGuardianVote method playerChoose.
@Override
public String playerChoose(String voteInfo, Player player, Player decidingPlayer, Ability source, Game game) {
ChoiceColor choice = new ChoiceColor();
choice.getChoices().remove("White");
choice.setSubMessage(voteInfo);
// TODO: add AI hint logic in the choice method, see Tyrant's Choice as example
decidingPlayer.choose(Outcome.AIDontUseIt, choice, game);
return choice.getChoice();
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class AnyColorLandsProduceManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
int manaAmount = getManaAmount(game, source);
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 (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");
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 == null || !player.choose(outcome, choice, game)) {
return mana;
}
if (choice.getChoice() != null) {
switch(choice.getChoice()) {
case "Black":
mana.setBlack(manaAmount);
break;
case "Blue":
mana.setBlue(manaAmount);
break;
case "Red":
mana.setRed(manaAmount);
break;
case "Green":
mana.setGreen(manaAmount);
break;
case "White":
mana.setWhite(manaAmount);
break;
case "Colorless":
mana.setColorless(manaAmount);
break;
}
}
}
return mana;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class SearingRaysEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(outcome, choice, game) && choice.getColor() != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent(choice.getColor().getDescription() + " creatures");
filter.add(new ColorPredicate(choice.getColor()));
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
int amount = game.getBattlefield().countAll(filter, playerId, game);
if (amount > 0) {
Player player = game.getPlayer(playerId);
if (player != null) {
player.damage(amount, source.getSourceId(), source, game);
}
}
}
return true;
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class ZombieBoaTriggeredAbility 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)) {
ObjectColor color = choice.getColor();
game.informPlayers(player.getLogName() + " chooses " + color);
game.addDelayedTriggeredAbility(new ZombieBoaTriggeredAbility(color), source);
return true;
}
return false;
}
Aggregations