Search in sources :

Example 1 with TargetSource

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

the class ShamanEnKorRedirectFromTargetEffect method init.

@Override
public void init(Ability source, Game game) {
    Player player = game.getPlayer(source.getControllerId());
    if (player != null) {
        TargetSource target = new TargetSource();
        target.choose(Outcome.PreventDamage, player.getId(), source.getSourceId(), game);
        this.sourceObject = new MageObjectReference(target.getFirstTarget(), game);
    } else {
        discard();
    }
}
Also used : TargetSource(mage.target.TargetSource) Player(mage.players.Player) MageObjectReference(mage.MageObjectReference)

Example 2 with TargetSource

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

the class InterventionPactPreventDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        Target target = new TargetSource();
        target.setRequired(true);
        target.setNotTarget(true);
        if (controller.chooseTarget(outcome, target, source, game)) {
            ContinuousEffect continuousEffect = new InterventionPactPreventDamageEffect();
            continuousEffect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
            game.addEffect(continuousEffect, source);
        }
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetSource(mage.target.TargetSource) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) ContinuousEffect(mage.abilities.effects.ContinuousEffect)

Example 3 with TargetSource

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

the class MournersShieldEffect method init.

@Override
public void init(Ability source, Game game) {
    ObjectColor colorsAmongImprinted = new ObjectColor();
    Permanent sourceObject = game.getPermanent(source.getSourceId());
    ExileZone exileZone = game.getExile().getExileZone(CardUtil.getCardExileZoneId(game, source.getSourceId()));
    if (sourceObject == null || sourceObject.getImprinted() == null) {
        noneExiled = true;
        return;
    }
    for (UUID imprinted : sourceObject.getImprinted()) {
        if (imprinted != null && exileZone.contains(imprinted)) {
            Card card = game.getCard(imprinted);
            if (card != null) {
                colorsAmongImprinted = colorsAmongImprinted.union(card.getColor(game));
            }
        }
    }
    FilterObject filterObject = new FilterObject("a source of your choice that shares a color with the exiled card");
    filterObject.add(new SharesColorPredicate(colorsAmongImprinted));
    this.target = new TargetSource(filterObject);
    this.target.choose(Outcome.PreventDamage, source.getControllerId(), source.getSourceId(), game);
    if (target.getFirstTarget() != null) {
        mageObjectReference = new MageObjectReference(target.getFirstTarget(), game);
    } else {
        mageObjectReference = null;
    }
}
Also used : TargetSource(mage.target.TargetSource) Permanent(mage.game.permanent.Permanent) SharesColorPredicate(mage.filter.predicate.mageobject.SharesColorPredicate) FilterObject(mage.filter.FilterObject) ObjectColor(mage.ObjectColor) ExileZone(mage.game.ExileZone) UUID(java.util.UUID) MageObjectReference(mage.MageObjectReference) Card(mage.cards.Card)

Aggregations

TargetSource (mage.target.TargetSource)3 MageObjectReference (mage.MageObjectReference)2 Player (mage.players.Player)2 UUID (java.util.UUID)1 ObjectColor (mage.ObjectColor)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 Card (mage.cards.Card)1 FilterObject (mage.filter.FilterObject)1 SharesColorPredicate (mage.filter.predicate.mageobject.SharesColorPredicate)1 ExileZone (mage.game.ExileZone)1 Permanent (mage.game.permanent.Permanent)1 Target (mage.target.Target)1 FixedTarget (mage.target.targetpointer.FixedTarget)1