use of mage.choices.Choice in project mage by magefree.
the class KatildaDawnhartPrimeManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game != null) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = source.getSourcePermanentIfItStillExists(game);
if (controller != null && permanent != null) {
Choice choice = new ChoiceImpl();
choice.setMessage("Pick a mana color");
ObjectColor color = permanent.getColor(game);
if (color.isWhite()) {
choice.getChoices().add("White");
}
if (color.isBlue()) {
choice.getChoices().add("Blue");
}
if (color.isBlack()) {
choice.getChoices().add("Black");
}
if (color.isRed()) {
choice.getChoices().add("Red");
}
if (color.isGreen()) {
choice.getChoices().add("Green");
}
if (!choice.getChoices().isEmpty()) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
controller.choose(outcome, choice, game);
}
if (choice.getChoice() != null) {
switch(choice.getChoice()) {
case "White":
mana.setWhite(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Black":
mana.setBlack(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
}
}
}
}
}
return mana;
}
use of mage.choices.Choice in project mage by magefree.
the class MistformSliverEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanent(source.getSourceId());
if (player != null && permanent != null) {
Choice typeChoice = new ChoiceCreatureType(permanent);
if (!player.choose(Outcome.Detriment, typeChoice, game)) {
return false;
}
game.informPlayers(permanent.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
ContinuousEffect effect = new AddCardSubTypeTargetEffect(SubType.byDescription(typeChoice.getChoice()), Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class SasayasEssenceManaEffect method produceMana.
/**
* RULINGS 6/1/2005 If Sasaya’s Essence’s controller has four Forests and
* taps one of them for Green, the Essence will add GreenGreenGreen to that
* player’s mana pool for a total of GreenGreenGreenGreen.
*
* 6/1/2005 If Sasaya’s Essence’s controller has four Mossfire Valley and
* taps one of them for RedGreen, the Essence will add three mana (one for
* each other Mossfire Valley) of any combination of Red and/or Green to
* that player’s mana pool.
*
* 6/1/2005 If Sasaya’s Essence’s controller has two Brushlands and taps one
* of them for White, Sasaya’s Essence adds another White to that player’s
* mana pool. It won’t produce Green or Colorless unless the land was tapped
* for Green or Colorless instead.
*/
@Override
public Mana produceMana(Game game, Ability source) {
Mana newMana = new Mana();
if (game == null) {
return newMana;
}
Player controller = game.getPlayer(source.getControllerId());
Mana mana = (Mana) this.getValue("mana");
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
if (controller != null && mana != null && permanent != null) {
FilterPermanent filter = new FilterLandPermanent();
filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
filter.add(new NamePredicate(permanent.getName()));
int count = game.getBattlefield().countAll(filter, controller.getId(), game);
if (count > 0) {
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick the type of mana to produce");
if (mana.getBlack() > 0) {
choice.getChoices().add("Black");
}
if (mana.getRed() > 0) {
choice.getChoices().add("Red");
}
if (mana.getBlue() > 0) {
choice.getChoices().add("Blue");
}
if (mana.getGreen() > 0) {
choice.getChoices().add("Green");
}
if (mana.getWhite() > 0) {
choice.getChoices().add("White");
}
if (mana.getColorless() > 0) {
choice.getChoices().add("Colorless");
}
if (!choice.getChoices().isEmpty()) {
for (int i = 0; i < count; i++) {
choice.clearChoice();
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!controller.choose(outcome, choice, game)) {
return newMana;
}
}
switch(choice.getChoice()) {
case "Black":
newMana.increaseBlack();
break;
case "Blue":
newMana.increaseBlue();
break;
case "Red":
newMana.increaseRed();
break;
case "Green":
newMana.increaseGreen();
break;
case "White":
newMana.increaseWhite();
break;
case "Colorless":
newMana.increaseColorless();
break;
}
}
}
}
}
return newMana;
}
use of mage.choices.Choice in project mage by magefree.
the class StorageMatrixRestrictionEffect method applies.
@Override
public boolean applies(Permanent permanent, Ability source, Game game) {
if (game.getStep().getType() == PhaseStep.UNTAP) {
if (game.getTurnNum() != turn) {
turn = game.getTurnNum();
applies = false;
Permanent storageMatrix = game.getPermanent(source.getSourceId());
if (storageMatrix != null && !storageMatrix.isTapped()) {
Choice choiceImpl = new ChoiceImpl(true);
choiceImpl.setMessage("Untap which kind of permanent?");
choiceImpl.setChoices(choice);
Player player = game.getPlayer(game.getActivePlayerId());
if (player != null && player.choose(outcome, choiceImpl, game)) {
String choosenType = choiceImpl.getChoice();
if (choosenType != null) {
game.informPlayers(storageMatrix.getLogName() + ": " + player.getLogName() + " chose to untap " + choosenType);
if (choosenType.equals(CardType.ARTIFACT.toString())) {
type = CardType.ARTIFACT;
} else if (choosenType.equals(CardType.LAND.toString())) {
type = CardType.LAND;
} else {
type = CardType.CREATURE;
}
applies = true;
}
}
}
}
if (applies) {
return !permanent.getCardType(game).contains(type);
}
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class StingingStudyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Set<Integer> manaValues = new HashSet<>();
for (Card commander : game.getCommanderCardsFromAnyZones(player, CommanderCardType.ANY, Zone.BATTLEFIELD, Zone.COMMAND)) {
manaValues.add(commander.getManaValue());
}
int chosenValue;
if (manaValues.size() > 1) {
Choice choice = new ChoiceImpl(true);
choice.setChoices(manaValues.stream().map(x -> "" + x).collect(Collectors.toSet()));
player.choose(outcome, choice, game);
chosenValue = Integer.parseInt(choice.getChoice());
} else {
chosenValue = manaValues.stream().findFirst().orElse(0);
}
if (chosenValue == 0) {
return false;
}
player.drawCards(chosenValue, source, game);
player.loseLife(chosenValue, game, source, false);
return true;
}
Aggregations