Search in sources :

Example 1 with SourceTappedCondition

use of mage.abilities.condition.common.SourceTappedCondition in project mage by magefree.

the class PreacherEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    Permanent targetPermanent = game.getPermanent(source.getFirstTarget());
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && sourcePermanent != null && targetPermanent != null) {
        SourceTappedCondition sourceTappedCondition = SourceTappedCondition.TAPPED;
        ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), sourceTappedCondition, "Gain control of target creature of an opponent's choice that they control for as long as {this} remains tapped");
        effect.setTargetPointer(new FixedTarget(targetPermanent.getId(), game));
        game.addEffect(effect, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponentsChoicePermanent(mage.target.common.TargetOpponentsChoicePermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) SourceTappedCondition(mage.abilities.condition.common.SourceTappedCondition) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Aggregations

SourceTappedCondition (mage.abilities.condition.common.SourceTappedCondition)1 ConditionalContinuousEffect (mage.abilities.decorator.ConditionalContinuousEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 Permanent (mage.game.permanent.Permanent)1 Player (mage.players.Player)1 TargetOpponentsChoicePermanent (mage.target.common.TargetOpponentsChoicePermanent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1