use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class BecomesChosenCreatureTypeTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = game.getCard(source.getSourceId());
String chosenType = "";
if (player != null && card != null) {
Choice typeChoice = new ChoiceCreatureType();
String msg = "Choose a creature type";
if (nonWall) {
msg += " other than Wall";
}
typeChoice.setMessage(msg);
if (nonWall) {
typeChoice.getChoices().remove(SubType.WALL.getDescription());
}
while (!player.choose(Outcome.BoostCreature, typeChoice, game)) {
if (!player.canRespond()) {
return false;
}
}
game.informPlayers(card.getName() + ": " + player.getLogName() + " has chosen " + typeChoice.getChoice());
chosenType = typeChoice.getChoice();
if (chosenType != null && !chosenType.isEmpty()) {
// ADD TYPE TO TARGET
ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(duration, SubType.byDescription(chosenType));
effect.setTargetPointer(new FixedTarget(getTargetPointer().getFirst(game, source), game));
game.addEffect(effect, source);
return true;
}
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class GraveSifterEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
typeChoice.setMessage("Choose creature type to return cards from your graveyard");
Player controller = game.getPlayer(source.getControllerId());
Set<Card> toHand = new HashSet<>();
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
typeChoice.clearChoice();
if (player.choose(outcome, typeChoice, game)) {
game.informPlayers(player.getLogName() + " has chosen: " + typeChoice.getChoice());
FilterCard filter = new FilterCreatureCard("creature cards with creature type " + typeChoice.getChoice() + " from your graveyard");
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
Target target = new TargetCardInYourGraveyard(0, Integer.MAX_VALUE, filter);
player.chooseTarget(outcome, target, source, game);
toHand.addAll(new CardsImpl(target.getTargets()).getCards(game));
}
}
}
// must happen simultaneously Rule 101.4
controller.moveCards(toHand, Zone.HAND, source, game, false, false, true, null);
return true;
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class DistantMelodyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
if (controller != null && controller.choose(Outcome.BoostCreature, typeChoice, game)) {
FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
filter.add(SubType.byDescription(typeChoice.getChoice()).getPredicate());
return new DrawCardSourceControllerEffect(new PermanentsOnBattlefieldCount(filter)).apply(game, source);
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class ExtinctionEffect 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.destroy(source, game, true);
}
return true;
}
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class HarshMercyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && sourceObject != null) {
Set<String> chosenTypes = new HashSet<>();
PlayerIteration: for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
Choice typeChoice = new ChoiceCreatureType(sourceObject);
if (player != null && !player.choose(Outcome.DestroyPermanent, typeChoice, game)) {
continue PlayerIteration;
}
String chosenType = typeChoice.getChoice();
if (chosenType != null) {
game.informPlayers(sourceObject.getIdName() + ": " + player.getLogName() + " has chosen " + chosenType);
chosenTypes.add(chosenType);
}
}
FilterPermanent filter = new FilterCreaturePermanent("creatures");
for (String type : chosenTypes) {
filter.add(Predicates.not(SubType.byDescription(type).getPredicate()));
}
return new DestroyAllEffect(filter, true).apply(game, source);
}
return false;
}
Aggregations