use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class KindredDominanceEffect 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, typeChoice, game)) {
game.informPlayers(controller.getLogName() + " has chosen " + typeChoice.getChoice());
FilterCreaturePermanent filter = new FilterCreaturePermanent("All creatures not of the chosen type");
filter.add(Predicates.not(SubType.byDescription(typeChoice.getChoice()).getPredicate()));
return new DestroyAllEffect(filter).apply(game, source);
}
return false;
}
use of mage.choices.ChoiceCreatureType in project mage by magefree.
the class ChangeCreatureTypeTargetEffect method init.
@Override
public void init(Ability source, Game game) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return;
}
if (fromSubType == null) {
Choice typeChoice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
typeChoice.setMessage("Choose creature type to change to Vampire");
if (!controller.choose(outcome, typeChoice, game)) {
discard();
return;
}
fromSubType = SubType.byDescription(typeChoice.getChoice());
if (!game.isSimulation()) {
game.informPlayers(controller.getLogName() + " has chosen the creature type: " + fromSubType.toString());
}
}
// To change body of generated methods, choose Tools | Templates.
super.init(source, game);
}
use of mage.choices.ChoiceCreatureType 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.ChoiceCreatureType 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.ChoiceCreatureType in project mage by magefree.
the class BecomesChosenCreatureTypeControlledEffect 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";
typeChoice.setMessage(msg);
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()) {
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game)) {
ContinuousEffect effect = new BecomesCreatureTypeTargetEffect(Duration.EndOfTurn, SubType.byDescription(chosenType));
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
}
return true;
}
}
return false;
}
Aggregations