Search in sources :

Example 11 with GainControlTargetEffect

use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.

the class SowerOfTemptationGainControlEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    ConditionalContinuousEffect effect = new ConditionalContinuousEffect(new GainControlTargetEffect(Duration.Custom), new SourceRemainsInZoneCondition(Zone.BATTLEFIELD), "gain control of target creature for as long as {this} remains on the battlefield");
    game.addEffect(effect, source);
    return false;
}
Also used : SourceRemainsInZoneCondition(mage.abilities.condition.common.SourceRemainsInZoneCondition) ConditionalContinuousEffect(mage.abilities.decorator.ConditionalContinuousEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 12 with GainControlTargetEffect

use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.

the class BesmirchEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    if (game.getPermanent(source.getFirstTarget()) != null) {
        TargetPointer target = new FixedTarget(source.getFirstTarget(), game);
        // gain control
        game.addEffect(new GainControlTargetEffect(Duration.EndOfTurn).setTargetPointer(target), source);
        // haste
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn).setTargetPointer(target), source);
        // goad
        game.addEffect(new GoadTargetEffect().setTargetPointer(target), source);
        // untap
        new UntapTargetEffect().setTargetPointer(target).apply(game, source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) TargetPointer(mage.target.targetpointer.TargetPointer) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) GoadTargetEffect(mage.abilities.effects.common.combat.GoadTargetEffect)

Example 13 with GainControlTargetEffect

use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.

the class BucknardsEverfullPurseEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    new TreasureToken().putOntoBattlefield(player.rollDice(outcome, source, game, 4), game, source, source.getControllerId());
    Permanent permanent = source.getSourcePermanentIfItStillExists(game);
    if (permanent == null) {
        return true;
    }
    UUID playerToRightId = game.getState().getPlayersInRange(source.getControllerId(), game).stream().reduce((u1, u2) -> u2).orElse(null);
    if (playerToRightId == null) {
        return false;
    }
    game.addEffect(new GainControlTargetEffect(Duration.Custom, true, playerToRightId).setTargetPointer(new FixedTarget(permanent, game)), source);
    return true;
}
Also used : SimpleActivatedAbility(mage.abilities.common.SimpleActivatedAbility) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Player(mage.players.Player) FixedTarget(mage.target.targetpointer.FixedTarget) CardSetInfo(mage.cards.CardSetInfo) Duration(mage.constants.Duration) Game(mage.game.Game) TapSourceCost(mage.abilities.costs.common.TapSourceCost) GenericManaCost(mage.abilities.costs.mana.GenericManaCost) CardImpl(mage.cards.CardImpl) Permanent(mage.game.permanent.Permanent) CardType(mage.constants.CardType) TreasureToken(mage.game.permanent.token.TreasureToken) Ability(mage.abilities.Ability) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TreasureToken(mage.game.permanent.token.TreasureToken) UUID(java.util.UUID) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 14 with GainControlTargetEffect

use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.

the class FumbleEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget());
    Player player = game.getPlayer(source.getControllerId());
    if (player == null || permanent == null) {
        return false;
    }
    List<Permanent> attachments = new ArrayList<>();
    for (UUID permId : permanent.getAttachments()) {
        Permanent attachment = game.getPermanent(permId);
        if (attachment != null) {
            if (attachment.hasSubtype(SubType.AURA, game) || attachment.hasSubtype(SubType.EQUIPMENT, game)) {
                attachments.add(attachment);
            }
        }
    }
    new ReturnToHandTargetEffect().apply(game, source);
    if (!attachments.isEmpty()) {
        Target target = new TargetCreaturePermanent(1, 1, StaticFilters.FILTER_PERMANENT_CREATURE, true);
        Permanent newCreature = null;
        if (player.choose(Outcome.BoostCreature, target, source.getSourceId(), game)) {
            newCreature = game.getPermanent(target.getFirstTarget());
        }
        for (Permanent attachment : attachments) {
            if (!attachment.hasSubtype(SubType.AURA, game) && !attachment.hasSubtype(SubType.EQUIPMENT, game)) {
                continue;
            }
            ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, player.getId());
            effect.setTargetPointer(new FixedTarget(attachment, game));
            game.addEffect(effect, source);
            if (newCreature != null) {
                attachment.attachTo(newCreature.getId(), source, game);
            }
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) Target(mage.target.Target) FixedTarget(mage.target.targetpointer.FixedTarget) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) ArrayList(java.util.ArrayList) ReturnToHandTargetEffect(mage.abilities.effects.common.ReturnToHandTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 15 with GainControlTargetEffect

use of mage.abilities.effects.common.continuous.GainControlTargetEffect in project mage by magefree.

the class HammerHelperEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Permanent targetCreature = game.getPermanent(source.getFirstTarget());
    if (controller != null && targetCreature != null) {
        source.getEffects().get(0).setTargetPointer(new FixedTarget(targetCreature.getId(), game));
        game.addEffect(new GainControlTargetEffect(Duration.EndOfTurn), source);
        targetCreature.untap(game);
        int amount = controller.rollDice(outcome, source, game, 6);
        game.addEffect(new BoostTargetEffect(amount, 0, Duration.EndOfTurn), source);
        game.addEffect(new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.EndOfTurn), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) BoostTargetEffect(mage.abilities.effects.common.continuous.BoostTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Aggregations

GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)57 FixedTarget (mage.target.targetpointer.FixedTarget)52 Permanent (mage.game.permanent.Permanent)48 ContinuousEffect (mage.abilities.effects.ContinuousEffect)42 Player (mage.players.Player)40 UUID (java.util.UUID)22 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)15 TargetPermanent (mage.target.TargetPermanent)13 FilterPermanent (mage.filter.FilterPermanent)12 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)12 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)9 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)9 Target (mage.target.Target)8 TargetPlayer (mage.target.TargetPlayer)7 MageObject (mage.MageObject)5 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)5 OneShotEffect (mage.abilities.effects.OneShotEffect)4 TargetOpponent (mage.target.common.TargetOpponent)4 ArrayList (java.util.ArrayList)3 HashSet (java.util.HashSet)3