use of mage.choices.ChoiceColor in project mage by magefree.
the class SungoldSentinelEffect 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(true);
player.choose(outcome, choice, game);
Ability ability = HexproofBaseAbility.getFirstFromColor(choice.getColor());
game.addEffect(new GainAbilitySourceEffect(ability, Duration.EndOfTurn), source);
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
game.addEffect(new CantBeBlockedByAllSourceEffect(filter, Duration.EndOfTurn), source);
return true;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class SuddenDemiseDamageEffect 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)) {
final int damage = source.getManaCostsToPay().getX();
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ColorPredicate(choice.getColor()));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
permanent.damage(damage, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class WashOutEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Set<Card> cardsToReturn = new LinkedHashSet<>();
ChoiceColor choice = new ChoiceColor();
if (controller != null && controller.choose(Outcome.ReturnToHand, choice, game)) {
ObjectColor color = choice.getColor();
FilterPermanent filter = new FilterPermanent();
filter.add(new ColorPredicate(color));
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) {
cardsToReturn.add((Card) permanent);
}
return controller.moveCards(cardsToReturn, Zone.HAND, source, game);
}
return false;
}
use of mage.choices.ChoiceColor in project mage by magefree.
the class AddConditionalManaOfAnyColorEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
if (game != null) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int value = amount.calculate(game, source, this);
if (value > 0) {
if (oneChoice || value == 1) {
ChoiceColor choice = new ChoiceColor(true);
controller.choose(outcome, choice, game);
if (choice.getChoice() == null) {
return null;
}
return new ConditionalMana(manaBuilder.setMana(choice.getMana(value), source, game).build());
}
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, value, MultiAmountType.MANA, game);
Mana mana = new Mana(choices.get(0), choices.get(1), choices.get(2), choices.get(3), choices.get(4), 0, 0, 0);
return new ConditionalMana(manaBuilder.setMana(mana, source, game).build());
}
}
}
return new Mana();
}
use of mage.choices.ChoiceColor 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;
}
Aggregations