use of mage.choices.ChoiceColor in project mage by magefree.
the class HallOfGemstoneEffect method init.
@Override
public void init(Ability source, Game game) {
super.init(source, game);
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
Permanent mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
if (player == null || mageObject == null) {
return;
}
ChoiceColor choice = new ChoiceColor();
if (!player.choose(outcome, choice, game)) {
discard();
return;
}
game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice());
game.getState().setValue(mageObject.getId() + "_color", choice.getColor());
mageObject.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game);
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class OonaQueenOfTheFaeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player opponent = game.getPlayer(getTargetPointer().getFirst(game, source));
ChoiceColor choice = new ChoiceColor();
if (controller == null || opponent == null || !controller.choose(outcome, choice, game)) {
return false;
}
int cardsWithColor = 0;
Cards cardsToExile = new CardsImpl();
cardsToExile.addAll(opponent.getLibrary().getTopCards(game, source.getManaCostsToPay().getX()));
for (Card card : cardsToExile.getCards(game)) {
if (card != null && card.getColor(game).contains(choice.getColor())) {
cardsWithColor++;
}
}
controller.moveCards(cardsToExile, Zone.EXILED, source, game);
if (cardsWithColor > 0) {
new CreateTokenEffect(new OonaQueenFaerieRogueToken(), cardsWithColor).apply(game, source);
}
game.informPlayers("Oona: " + cardsWithColor + " Token" + (cardsWithColor != 1 ? "s" : "") + " created");
return true;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class AddManaAnyColorAttachedControllerEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
if (game != null) {
Permanent enchantment = game.getPermanent(source.getSourceId());
if (enchantment != null) {
Permanent land = game.getPermanent(enchantment.getAttachedTo());
if (land != null) {
Player player = game.getPlayer(land.getControllerId());
ChoiceColor choice = new ChoiceColor();
if (player != null && player.choose(outcome, choice, game)) {
return choice.getMana(1);
}
}
}
}
return new Mana();
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class AddManaOfAnyTypeProducedEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana newMana = new Mana();
if (game == null) {
return newMana;
}
Permanent permanent = (Permanent) this.getValue("tappedPermanent");
Mana types = (Mana) this.getValue("mana");
if (permanent == null || types == null) {
return newMana;
}
Player targetController = game.getPlayer(permanent.getControllerId());
if (targetController == null) {
return newMana;
}
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick the type of mana to produce");
if (types.getWhite() > 0) {
choice.getChoices().add("White");
}
if (types.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (types.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (types.getRed() > 0) {
choice.getChoices().add("Red");
}
if (types.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (types.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
if (choice.getChoices().isEmpty()) {
return newMana;
}
if (choice.getChoices().size() != 1 && !targetController.choose(outcome, choice, game)) {
return newMana;
}
choice.setChoice(choice.getChoices().iterator().next());
switch(choice.getChoice()) {
case "White":
newMana.setWhite(1);
break;
case "Blue":
newMana.setBlue(1);
break;
case "Black":
newMana.setBlack(1);
break;
case "Red":
newMana.setRed(1);
break;
case "Green":
newMana.setGreen(1);
break;
case "Colorless":
newMana.setColorless(1);
break;
}
return newMana;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class AddManaOfAnyColorEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
if (game != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
String mes = String.format("Select a color of mana to add %d of it", this.amount);
if (mes != null) {
ChoiceColor choice = new ChoiceColor(true, mes, game.getObject(source.getSourceId()));
if (controller.choose(outcome, choice, game)) {
if (choice.getColor() != null) {
Mana mana = choice.getMana(amount);
mana.setFlag(setFlag);
return mana;
}
}
}
}
}
return new Mana();
}
Aggregations