Search in sources :

Example 1 with BlocksIfAbleTargetEffect

use of mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect in project mage by magefree.

the class BorosBattleshaperEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent creature1 = game.getPermanent(this.getTargetPointer().getFirst(game, source));
    if (creature1 != null) {
        if (game.getOpponents(creature1.getControllerId()).contains(game.getActivePlayerId())) {
            // Blocks
            ContinuousEffectImpl effect = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
            effect = new GainAbilityTargetEffect(BlocksThisTurnMarkerAbility.getInstance(), Duration.EndOfTurn, "");
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
        } else {
            // Attacks
            ContinuousEffectImpl effect = new AttacksIfAbleTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
            effect = new GainAbilityTargetEffect(AttacksThisTurnMarkerAbility.getInstance(), Duration.EndOfTurn, "");
            effect.setTargetPointer(new FixedTarget(creature1.getId(), game));
            game.addEffect(effect, source);
        }
    }
    Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget());
    if (creature2 != null) {
        if (game.getOpponents(creature2.getControllerId()).contains(game.getActivePlayerId())) {
            // Blocks
            ContinuousEffectImpl effect = new CantBlockTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature2.getId(), game));
            game.addEffect(effect, source);
        } else {
            // Attacks
            ContinuousEffectImpl effect = new CantAttackTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creature2.getId(), game));
            game.addEffect(effect, source);
        }
    }
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) CantAttackTargetEffect(mage.abilities.effects.common.combat.CantAttackTargetEffect) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) CantBlockTargetEffect(mage.abilities.effects.common.combat.CantBlockTargetEffect) GainAbilityTargetEffect(mage.abilities.effects.common.continuous.GainAbilityTargetEffect) ContinuousEffectImpl(mage.abilities.effects.ContinuousEffectImpl) AttacksIfAbleTargetEffect(mage.abilities.effects.common.combat.AttacksIfAbleTargetEffect)

Example 2 with BlocksIfAbleTargetEffect

use of mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect in project mage by magefree.

the class BerserkersFrenzyEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    TargetPermanent target = new TargetCreaturePermanent(0, Integer.MAX_VALUE);
    target.setNotTarget(true);
    player.choose(outcome, target, source.getSourceId(), game);
    game.addEffect(new BlocksIfAbleTargetEffect(Duration.EndOfTurn).setTargetPointer(new FixedTargets(new CardsImpl(target.getTargets()), game)), source);
    return true;
}
Also used : TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) Player(mage.players.Player) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) FixedTargets(mage.target.targetpointer.FixedTargets) TargetPermanent(mage.target.TargetPermanent) CardsImpl(mage.cards.CardsImpl)

Example 3 with BlocksIfAbleTargetEffect

use of mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect in project mage by magefree.

the class DomineeringWillEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
    if (targetPlayer != null) {
        ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, targetPlayer.getId());
        effect.setTargetPointer(new SecondTargetPointer());
        effect.setText("Target player gains control of up to three target nonattacking creatures until end of turn");
        game.addEffect(effect, source);
        Effect effect2 = new UntapTargetEffect();
        effect2.setTargetPointer(new SecondTargetPointer());
        effect2.setText("Untap those creatures");
        effect2.apply(game, source);
        RequirementEffect effect3 = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
        effect3.setTargetPointer(new SecondTargetPointer());
        effect3.setText("They block this turn if able");
        game.addEffect(effect3, source);
        return true;
    }
    return false;
}
Also used : SecondTargetPointer(mage.target.targetpointer.SecondTargetPointer) RequirementEffect(mage.abilities.effects.RequirementEffect) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) RequirementEffect(mage.abilities.effects.RequirementEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) Effect(mage.abilities.effects.Effect) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UntapTargetEffect(mage.abilities.effects.common.UntapTargetEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 4 with BlocksIfAbleTargetEffect

use of mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect in project mage by magefree.

the class MarkForDeathEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Permanent target = game.getPermanent(source.getFirstTarget());
    if (target == null) {
        return false;
    }
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(new ControllerIdPredicate(target.getControllerId()));
    filter.add(Predicates.not(new CardIdPredicate(target.getId())));
    ContinuousEffect effect = new BlocksIfAbleTargetEffect(Duration.EndOfTurn);
    effect.setTargetPointer(new FixedTarget(target.getId()));
    game.addEffect(effect, source);
    target.untap(game);
    ContinuousEffect effect2 = new CantBlockAllEffect(filter, Duration.EndOfTurn);
    game.addEffect(effect2, source);
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) BlocksIfAbleTargetEffect(mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect) CantBlockAllEffect(mage.abilities.effects.common.combat.CantBlockAllEffect) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ContinuousEffect(mage.abilities.effects.ContinuousEffect) CardIdPredicate(mage.filter.predicate.mageobject.CardIdPredicate)

Aggregations

BlocksIfAbleTargetEffect (mage.abilities.effects.common.combat.BlocksIfAbleTargetEffect)4 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)3 ContinuousEffect (mage.abilities.effects.ContinuousEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 Permanent (mage.game.permanent.Permanent)2 Player (mage.players.Player)2 FixedTarget (mage.target.targetpointer.FixedTarget)2 ContinuousEffectImpl (mage.abilities.effects.ContinuousEffectImpl)1 Effect (mage.abilities.effects.Effect)1 OneShotEffect (mage.abilities.effects.OneShotEffect)1 RequirementEffect (mage.abilities.effects.RequirementEffect)1 UntapTargetEffect (mage.abilities.effects.common.UntapTargetEffect)1 AttacksIfAbleTargetEffect (mage.abilities.effects.common.combat.AttacksIfAbleTargetEffect)1 CantAttackTargetEffect (mage.abilities.effects.common.combat.CantAttackTargetEffect)1 CantBlockAllEffect (mage.abilities.effects.common.combat.CantBlockAllEffect)1 CantBlockTargetEffect (mage.abilities.effects.common.combat.CantBlockTargetEffect)1 GainAbilityTargetEffect (mage.abilities.effects.common.continuous.GainAbilityTargetEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 CardsImpl (mage.cards.CardsImpl)1 CardIdPredicate (mage.filter.predicate.mageobject.CardIdPredicate)1