use of mage.choices.Choice in project mage by magefree.
the class MindblazeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
Player playerControls = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (player == null || playerControls == null || sourceObject == null) {
return false;
}
Choice numberChoice = new ChoiceImpl();
numberChoice.setMessage("Choose a number greater than 0");
Set<String> numbers = new HashSet<>();
for (int i = 1; i <= 4; i++) {
numbers.add(Integer.toString(i));
}
numberChoice.setChoices(numbers);
String cardName = ChooseACardNameEffect.TypeOfName.NON_LAND_NAME.getChoice(playerControls, game, source, false);
playerControls.choose(Outcome.Neutral, numberChoice, game);
game.informPlayers(sourceObject.getIdName() + " - Chosen number: [" + numberChoice.getChoice() + ']');
Cards cards = new CardsImpl();
cards.addAll(player.getLibrary().getCards(game));
playerControls.revealCards("Library", cards, game);
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(cardName));
int count = Integer.parseInt(numberChoice.getChoice());
if (player.getLibrary().count(filter, game) == count) {
player.damage(8, source.getSourceId(), source, game);
}
player.shuffleLibrary(source, game);
return true;
}
use of mage.choices.Choice in project mage by magefree.
the class PacksDisdainEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (player != null && player.choose(Outcome.UnboostCreature, typeChoice, game)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
DynamicValue negativePermanentsCount = new PermanentsOnBattlefieldCount(filter, -1);
ContinuousEffect effect = new BoostTargetEffect(negativePermanentsCount, negativePermanentsCount, Duration.EndOfTurn, true);
effect.setTargetPointer(new FixedTarget(source.getFirstTarget(), game));
game.addEffect(effect, source);
return true;
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class RiptideShapeshifterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller != null && sourceObject != null) {
Choice choice = new ChoiceCreatureType(sourceObject);
if (!controller.choose(Outcome.BoostCreature, choice, game)) {
return false;
}
Cards revealedCards = new CardsImpl();
for (Card card : controller.getLibrary().getCards(game)) {
if (card.isCreature(game) && card.hasSubtype(SubType.byDescription(choice.getChoice()), game)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
revealedCards.add(card);
}
controller.revealCards(sourceObject.getIdName(), revealedCards, game);
controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class RiptideChronologistEffect 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 && sourceObject != null) {
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(sourceObject.getLogName() + " chosen type: " + typeChoice.getChoice());
FilterCreaturePermanent filterCreaturePermanent = new FilterCreaturePermanent();
filterCreaturePermanent.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
for (Permanent creature : game.getBattlefield().getActivePermanents(filterCreaturePermanent, source.getSourceId(), game)) {
creature.untap(game);
}
return true;
}
}
return false;
}
use of mage.choices.Choice in project mage by magefree.
the class SquanderedResourcesEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Choice choice = ManaType.getChoiceOfManaTypes(getManaTypesFromSacrificedPermanent(game, source), false);
if (!choice.getChoices().isEmpty()) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return mana;
}
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":
mana.setBlack(1);
break;
case "Blue":
mana.setBlue(1);
break;
case "Red":
mana.setRed(1);
break;
case "Green":
mana.setGreen(1);
break;
case "White":
mana.setWhite(1);
break;
case "Colorless":
mana.setColorless(1);
break;
}
}
return mana;
}
Aggregations