Search in sources :

Example 26 with ChoiceCreatureType

use of mage.choices.ChoiceCreatureType in project mage by magefree.

the class CallousOppressorChooseCreatureTypeEffect 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) {
        TargetOpponent target = new TargetOpponent(true);
        if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
            while (!target.isChosen() && target.canChoose(source.getSourceId(), controller.getId(), game) && controller.canRespond()) {
                controller.chooseTarget(outcome, target, source, game);
            }
        } else {
            return false;
        }
        Player opponent = game.getPlayer(target.getFirstTarget());
        if (opponent != null && mageObject != null) {
            Choice typeChoice = new ChoiceCreatureType(mageObject);
            typeChoice.setMessage("Choose creature type");
            if (!opponent.choose(outcome, typeChoice, game)) {
                return false;
            }
            if (typeChoice.getChoice() == null) {
                return false;
            }
            if (!game.isSimulation()) {
                game.informPlayers(mageObject.getName() + ": " + opponent.getLogName() + " has chosen " + typeChoice.getChoice());
            }
            game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(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) TargetOpponent(mage.target.common.TargetOpponent) Choice(mage.choices.Choice) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 27 with ChoiceCreatureType

use of mage.choices.ChoiceCreatureType in project mage by magefree.

the class ChooseCreatureTypeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject mageObject = game.getObject(source.getSourceId());
    Choice typeChoice = new ChoiceCreatureType(mageObject);
    if (controller != null && mageObject != null && controller.choose(outcome, typeChoice, game)) {
        if (!game.isSimulation()) {
            game.informPlayers(mageObject.getName() + ": " + controller.getLogName() + " has chosen " + typeChoice.getChoice());
        }
        game.getState().setValue(mageObject.getId() + "_type", SubType.byDescription(typeChoice.getChoice()));
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType)

Example 28 with ChoiceCreatureType

use of mage.choices.ChoiceCreatureType in project mage by magefree.

the class CoordinatedBarrageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Choice choice = new ChoiceCreatureType(game.getObject(source.getSourceId()));
        if (controller.choose(Outcome.Damage, choice, game)) {
            String chosenType = choice.getChoice();
            FilterControlledPermanent filter = new FilterControlledPermanent();
            filter.add(SubType.byDescription(chosenType).getPredicate());
            int damageDealt = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
            Permanent permanent = game.getPermanent(this.getTargetPointer().getFirst(game, source));
            if (permanent != null) {
                permanent.damage(damageDealt, source.getSourceId(), source, game, false, true);
            }
            return true;
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) ChoiceCreatureType(mage.choices.ChoiceCreatureType) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent)

Example 29 with ChoiceCreatureType

use of mage.choices.ChoiceCreatureType in project mage by magefree.

the class DefensiveManeuversEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    MageObject sourceObject = source.getSourceObject(game);
    if (player == null || sourceObject == null) {
        return false;
    }
    Choice choice = new ChoiceCreatureType(sourceObject);
    SubType subType = null;
    if (player.choose(outcome, choice, game)) {
        subType = SubType.byDescription(choice.getChoice());
    }
    if (subType == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(subType.getPredicate());
    game.addEffect(new BoostAllEffect(0, 4, Duration.EndOfTurn, filter, false), source);
    return true;
}
Also used : Player(mage.players.Player) Choice(mage.choices.Choice) SubType(mage.constants.SubType) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) MageObject(mage.MageObject) ChoiceCreatureType(mage.choices.ChoiceCreatureType) BoostAllEffect(mage.abilities.effects.common.continuous.BoostAllEffect)

Aggregations

ChoiceCreatureType (mage.choices.ChoiceCreatureType)29 Player (mage.players.Player)29 Choice (mage.choices.Choice)28 MageObject (mage.MageObject)15 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)13 Permanent (mage.game.permanent.Permanent)9 ContinuousEffect (mage.abilities.effects.ContinuousEffect)6 PermanentsOnBattlefieldCount (mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount)5 FixedTarget (mage.target.targetpointer.FixedTarget)5 BoostAllEffect (mage.abilities.effects.common.continuous.BoostAllEffect)4 FilterCard (mage.filter.FilterCard)4 UUID (java.util.UUID)3 Card (mage.cards.Card)3 CardsImpl (mage.cards.CardsImpl)3 FilterPermanent (mage.filter.FilterPermanent)3 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)3 FilterCreatureCard (mage.filter.common.FilterCreatureCard)3 HashSet (java.util.HashSet)2 DestroyAllEffect (mage.abilities.effects.common.DestroyAllEffect)2 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)2