Search in sources :

Example 1 with ChoiceCardType

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);
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) Choice(mage.choices.Choice) ChoiceCardType(mage.choices.ChoiceCardType) CardType(mage.constants.CardType) ChoiceCardType(mage.choices.ChoiceCardType)

Example 2 with ChoiceCardType

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;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) Permanent(mage.game.permanent.Permanent) ChoiceCardType(mage.choices.ChoiceCardType) MageObject(mage.MageObject)

Aggregations

Choice (mage.choices.Choice)2 ChoiceCardType (mage.choices.ChoiceCardType)2 Player (mage.players.Player)2 MageObject (mage.MageObject)1 CardType (mage.constants.CardType)1 FilterCard (mage.filter.FilterCard)1 Permanent (mage.game.permanent.Permanent)1