use of mage.choices.ChoiceCardType in project mage by magefree.
the class CreepingRenaissanceEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Choice typeChoice = new ChoiceCardType(true, Arrays.stream(CardType.values()).filter(CardType::isPermanentType).collect(Collectors.toList()));
typeChoice.setMessage("Choose a permanent type");
if (!controller.choose(Outcome.ReturnToHand, typeChoice, game)) {
return false;
}
String typeName = typeChoice.getChoice();
CardType chosenType = CardType.fromString(typeChoice.getChoice());
if (chosenType == null) {
return false;
}
FilterCard filter = new FilterCard(chosenType.toString().toLowerCase(Locale.ENGLISH) + " card");
filter.add(chosenType.getPredicate());
return controller.moveCards(controller.getGraveyard().getCards(filter, source.getSourceId(), controller.getId(), game), Zone.HAND, source, game);
}
use of mage.choices.ChoiceCardType in project mage by magefree.
the class ChooseCardTypeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject mageObject = game.getPermanentEntering(source.getSourceId());
if (mageObject == null) {
mageObject = game.getObject(source.getSourceId());
}
if (controller != null && mageObject != null) {
Choice typeChoice = new ChoiceCardType(true, cardTypes);
if (controller.choose(outcome, typeChoice, game)) {
game.informPlayers(mageObject.getLogName() + ": " + controller.getLogName() + " has chosen: " + typeChoice.getChoice());
game.getState().setValue(source.getSourceId() + "_type", typeChoice.getChoice());
if (mageObject instanceof Permanent) {
((Permanent) mageObject).addInfo("chosen type", CardUtil.addToolTipMarkTags("Chosen type: " + typeChoice.getChoice()), game);
}
return true;
}
}
return false;
}
Aggregations