use of mage.choices.Choice in project mage by magefree.
the class WalkingDesecrationEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null) {
if (sourceObject != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
RequirementEffect effect = new AttacksIfAbleAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
return true;
}
}
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class ConvokeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = game.getStack().getSpell(source.getSourceId());
if (controller != null && spell != null) {
for (UUID creatureId : this.getTargetPointer().getTargets(game, source)) {
Permanent perm = game.getPermanent(creatureId);
if (perm == null) {
continue;
}
String manaName;
if (!perm.isTapped() && perm.tap(source, game)) {
ManaPool manaPool = controller.getManaPool();
Choice chooseManaType = buildChoice(perm.getColor(game), unpaid.getMana());
if (!chooseManaType.getChoices().isEmpty()) {
if (chooseManaType.getChoices().size() > 1) {
chooseManaType.getChoices().add("Colorless");
chooseManaType.setMessage("Choose mana color to reduce from " + perm.getName());
if (!controller.choose(Outcome.Benefit, chooseManaType, game)) {
return false;
}
} else {
chooseManaType.setChoice(chooseManaType.getChoices().iterator().next());
}
if (chooseManaType.getChoice().equals("Black")) {
manaPool.addMana(Mana.BlackMana(1), game, source);
manaPool.unlockManaType(ManaType.BLACK);
}
if (chooseManaType.getChoice().equals("Blue")) {
manaPool.addMana(Mana.BlueMana(1), game, source);
manaPool.unlockManaType(ManaType.BLUE);
}
if (chooseManaType.getChoice().equals("Green")) {
manaPool.addMana(Mana.GreenMana(1), game, source);
manaPool.unlockManaType(ManaType.GREEN);
}
if (chooseManaType.getChoice().equals("White")) {
manaPool.addMana(Mana.WhiteMana(1), game, source);
manaPool.unlockManaType(ManaType.WHITE);
}
if (chooseManaType.getChoice().equals("Red")) {
manaPool.addMana(Mana.RedMana(1), game, source);
manaPool.unlockManaType(ManaType.RED);
}
if (chooseManaType.getChoice().equals("Colorless")) {
manaPool.addMana(Mana.ColorlessMana(1), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
}
manaName = chooseManaType.getChoice().toLowerCase(Locale.ENGLISH);
} else {
manaPool.addMana(Mana.ColorlessMana(1), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
manaName = "colorless";
}
game.fireEvent(GameEvent.getEvent(GameEvent.EventType.CONVOKED, perm.getId(), source, source.getControllerId()));
game.informPlayers("Convoke: " + controller.getLogName() + " taps " + perm.getLogName() + " to pay one " + manaName + " mana");
// can't use mana abilities after that (convoke cost must be payed after mana abilities only)
spell.setCurrentActivatingManaAbilitiesStep(ActivationManaAbilityStep.AFTER);
}
}
return true;
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class BloodlineShamanEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (controller != null && sourceObject != null && controller.choose(outcome, typeChoice, game)) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
FilterCard filterSubtype = new FilterCard();
filterSubtype.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
// Reveal the top card of your library.
if (controller.getLibrary().hasCards()) {
Card card = controller.getLibrary().getFromTop(game);
Cards cards = new CardsImpl(card);
controller.revealCards(sourceObject.getIdName(), cards, game);
if (card != null) {
// If that card is a creature card of the chosen type, put it into your hand.
if (filterSubtype.match(card, game)) {
controller.moveCards(card, Zone.HAND, source, game);
// Otherwise, put it into your graveyard.
} else {
controller.moveCards(card, Zone.GRAVEYARD, source, game);
}
}
}
return true;
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class ChromeMoxManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Permanent permanent = game.getPermanent(source.getSourceId());
Player player = game.getPlayer(source.getControllerId());
if (permanent != null && player != null) {
List<UUID> imprinted = permanent.getImprinted();
if (imprinted != null && !imprinted.isEmpty()) {
Card imprintedCard = game.getCard(imprinted.get(0));
if (imprintedCard != null) {
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick a mana color");
ObjectColor color = imprintedCard.getColor(game);
if (color.isBlack()) {
choice.getChoices().add("Black");
}
if (color.isRed()) {
choice.getChoices().add("Red");
}
if (color.isBlue()) {
choice.getChoices().add("Blue");
}
if (color.isGreen()) {
choice.getChoices().add("Green");
}
if (color.isWhite()) {
choice.getChoices().add("White");
}
if (!choice.getChoices().isEmpty()) {
if (choice.getChoices().size() == 1) {
choice.setChoice(choice.getChoices().iterator().next());
} else {
if (!player.choose(outcome, choice, game)) {
return mana;
}
}
switch(choice.getChoice()) {
case "Black":
// player.getManaPool().addMana(Mana.BlackMana(1), game, source);
mana.add(Mana.BlackMana(1));
break;
case "Blue":
// player.getManaPool().addMana(Mana.BlueMana(1), game, source);
mana.add(Mana.BlueMana(1));
break;
case "Red":
// player.getManaPool().addMana(Mana.RedMana(1), game, source);
mana.add(Mana.RedMana(1));
break;
case "Green":
// player.getManaPool().addMana(Mana.GreenMana(1), game, source);
mana.add(Mana.GreenMana(1));
break;
case "White":
// player.getManaPool().addMana(Mana.WhiteMana(1), game, source);
mana.add(Mana.WhiteMana(1));
break;
default:
break;
}
}
}
}
}
return mana;
}
use of mage.choices.Choice in project mage by magefree.
the class FatespinnerSkipEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
if (player != null) {
Choice choice = new ChoiceImpl(true);
choice.setMessage("Choose phase or step to skip");
choice.setChoices(choices);
if (!player.choose(outcome, choice, game)) {
return false;
}
String chosenPhase = choice.getChoice();
game.informPlayers(player.getLogName() + " has chosen to skip " + chosenPhase.toLowerCase(Locale.ENGLISH) + '.');
game.addEffect(new FatespinnerSkipEffect(chosenPhase), source);
return true;
}
return false;
}
Aggregations