Search in sources :

Example 86 with Target

use of mage.target.Target in project mage by magefree.

the class MassMutinyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = false;
    for (Target target : source.getTargets()) {
        if (target instanceof TargetCreaturePermanent) {
            Permanent targetCreature = game.getPermanent(target.getFirstTarget());
            if (targetCreature != null) {
                ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
                effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
                game.addEffect(effect1, source);
                ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
                game.addEffect(effect2, source);
                targetCreature.untap(game);
                result = true;
            }
        }
    }
    return result;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 87 with Target

use of mage.target.Target in project mage by magefree.

the class MoltenPrimordialEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    boolean result = false;
    for (Target target : source.getTargets()) {
        if (target instanceof TargetCreaturePermanent) {
            Permanent targetCreature = game.getPermanent(target.getFirstTarget());
            if (targetCreature != null) {
                ContinuousEffect effect1 = new GainControlTargetEffect(Duration.EndOfTurn);
                effect1.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
                game.addEffect(effect1, source);
                ContinuousEffect effect2 = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn);
                effect2.setTargetPointer(new FixedTarget(targetCreature.getId(), game));
                game.addEffect(effect2, source);
                targetCreature.untap(game);
                result = true;
            }
        }
    }
    return result;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 88 with Target

use of mage.target.Target in project mage by magefree.

the class NecromanticSelectionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    MageObject sourceObject = game.getObject(source.getSourceId());
    if (sourceObject != null && controller != null) {
        Cards cards = new CardsImpl();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, controller.getId(), source.getSourceId(), game)) {
            permanent.destroy(source, game, false);
            // Meren of the Clan Nel Toth bug #8515
            game.checkStateAndTriggered();
            if (game.getState().getZone(permanent.getId()) == Zone.GRAVEYARD) {
                cards.add(permanent);
            }
        }
        FilterCard filter = new FilterCreatureCard("creature card put into a graveyard with " + sourceObject.getLogName());
        List<Predicate<MageObject>> cardIdPredicates = new ArrayList<>();
        for (UUID cardId : cards) {
            cardIdPredicates.add(new CardIdPredicate(cardId));
        }
        filter.add(Predicates.or(cardIdPredicates));
        Target target = new TargetCardInGraveyard(filter);
        target.setNotTarget(true);
        if (controller.chooseTarget(Outcome.Benefit, target, source, game)) {
            Card card = game.getCard(target.getFirstTarget());
            if (card != null) {
                controller.moveCards(card, Zone.BATTLEFIELD, source, game);
                ContinuousEffect effect = new BecomesBlackZombieAdditionEffect();
                effect.setText("It's a black Zombie in addition to its other colors and types");
                effect.setTargetPointer(new FixedTarget(card.getId(), game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) MageObject(mage.MageObject) ArrayList(java.util.ArrayList) BecomesBlackZombieAdditionEffect(mage.abilities.effects.common.continuous.BecomesBlackZombieAdditionEffect) Predicate(mage.filter.predicate.Predicate) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate) FilterCreatureCard(mage.filter.common.FilterCreatureCard) FilterCard(mage.filter.FilterCard) FilterCard(mage.filter.FilterCard) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) TargetCardInGraveyard(mage.target.common.TargetCardInGraveyard) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Example 89 with Target

use of mage.target.Target in project mage by magefree.

the class NecromancyChangeAbilityEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent enchantment = game.getPermanent(source.getSourceId());
    Card cardInGraveyard = game.getCard(getTargetPointer().getFirst(game, source));
    if (controller != null && enchantment != null && cardInGraveyard != null) {
        controller.moveCards(cardInGraveyard, Zone.BATTLEFIELD, source, game);
        Permanent enchantedCreature = game.getPermanent(cardInGraveyard.getId());
        if (enchantedCreature != null) {
            enchantedCreature.addAttachment(enchantment.getId(), source, game);
            FilterCreaturePermanent filter = new FilterCreaturePermanent("enchant creature put onto the battlefield with " + enchantment.getIdName());
            filter.add(new PermanentIdPredicate(cardInGraveyard.getId()));
            Target target = new TargetCreaturePermanent(filter);
            target.addTarget(enchantedCreature.getId(), source, game);
            game.addEffect(new NecromancyChangeAbilityEffect(target), source);
        }
        return true;
    }
    return false;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreatureCard(mage.filter.common.FilterCreatureCard) Card(mage.cards.Card)

Example 90 with Target

use of mage.target.Target in project mage by magefree.

the class NecriteTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    if (super.checkTrigger(event, game)) {
        UUID defendingPlayerId = game.getCombat().getDefendingPlayerId(getSourceId(), game);
        FilterPermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(defendingPlayerId));
        Target target = new TargetPermanent(filter);
        this.getTargets().clear();
        this.addTarget(target);
        return true;
    }
    return false;
}
Also used : Target(mage.target.Target) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent) UUID(java.util.UUID)

Aggregations

Target (mage.target.Target)385 Player (mage.players.Player)291 Permanent (mage.game.permanent.Permanent)223 UUID (java.util.UUID)155 Card (mage.cards.Card)86 TargetPermanent (mage.target.TargetPermanent)80 FilterCard (mage.filter.FilterCard)62 FilterPermanent (mage.filter.FilterPermanent)56 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)54 FixedTarget (mage.target.targetpointer.FixedTarget)49 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)45 TargetControlledPermanent (mage.target.common.TargetControlledPermanent)45 MageObject (mage.MageObject)43 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)42 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)38 TargetOpponent (mage.target.common.TargetOpponent)35 CardsImpl (mage.cards.CardsImpl)32 ArrayList (java.util.ArrayList)31 ContinuousEffect (mage.abilities.effects.ContinuousEffect)31 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)30