Search in sources :

Example 1 with SpecialAction

use of mage.abilities.SpecialAction in project mage by magefree.

the class ImproviseEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    int canPayCount = untappedCount.calculate(game, source, null);
    if (controller != null && canPayCount > 0) {
        if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
            SpecialAction specialAction = new ImproviseSpecialAction(unpaid, this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            // create filter for possible artifacts to tap
            Target target = new TargetControlledPermanent(1, unpaid.getMana().getGeneric(), filterUntapped, true);
            target.setTargetName("artifact to tap as Improvise's pay");
            specialAction.addTarget(target);
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : TargetControlledPermanent(mage.target.common.TargetControlledPermanent) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) Target(mage.target.Target) ValueHint(mage.abilities.hint.ValueHint)

Example 2 with SpecialAction

use of mage.abilities.SpecialAction in project mage by magefree.

the class CreateSpecialActionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    SpecialAction newAction = (SpecialAction) action.copy();
    newAction.setSourceId(source.getSourceId());
    newAction.setControllerId(source.getControllerId());
    newAction.getTargets().addAll(source.getTargets());
    game.getState().getSpecialActions().add(newAction);
    return true;
}
Also used : SpecialAction(mage.abilities.SpecialAction)

Example 3 with SpecialAction

use of mage.abilities.SpecialAction in project mage by magefree.

the class ConvokeEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && game.getBattlefield().containsControlled(filterUntapped, source, game, 1)) {
        if (source.getAbilityType() == AbilityType.SPELL) {
            SpecialAction specialAction = new ConvokeSpecialAction(unpaid, this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            // create filter for possible creatures to tap
            FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent();
            filter.add(TappedPredicate.UNTAPPED);
            if (unpaid.getMana().getGeneric() == 0) {
                List<ColorPredicate> colorPredicates = new ArrayList<>();
                if (unpaid.getMana().getBlack() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.BLACK));
                }
                if (unpaid.getMana().getBlue() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.BLUE));
                }
                if (unpaid.getMana().getRed() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.RED));
                }
                if (unpaid.getMana().getGreen() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.GREEN));
                }
                if (unpaid.getMana().getWhite() > 0) {
                    colorPredicates.add(new ColorPredicate(ObjectColor.WHITE));
                }
                filter.add(Predicates.or(colorPredicates));
            }
            Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
            target.setTargetName("tap creature card as convoke's pay");
            specialAction.addTarget(target);
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) Target(mage.target.Target) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ArrayList(java.util.ArrayList) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 4 with SpecialAction

use of mage.abilities.SpecialAction in project mage by magefree.

the class DelveEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && !controller.getGraveyard().isEmpty()) {
        if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
            SpecialAction specialAction = new DelveSpecialAction(this);
            specialAction.setControllerId(source.getControllerId());
            specialAction.setSourceId(source.getSourceId());
            int unpaidAmount = unpaid.getMana().getGeneric();
            if (!controller.getManaPool().isAutoPayment() && unpaidAmount > 1) {
                unpaidAmount = 1;
            }
            specialAction.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(0, Math.min(controller.getGraveyard().size(), unpaidAmount), new FilterCard("cards from your graveyard"), true)));
            if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
                game.getState().getSpecialActions().add(specialAction);
            }
        }
    }
}
Also used : FilterCard(mage.filter.FilterCard) Player(mage.players.Player) SpecialAction(mage.abilities.SpecialAction) ExileFromGraveCost(mage.abilities.costs.common.ExileFromGraveCost) TargetCardInYourGraveyard(mage.target.common.TargetCardInYourGraveyard) ValueHint(mage.abilities.hint.ValueHint)

Example 5 with SpecialAction

use of mage.abilities.SpecialAction in project mage by magefree.

the class AssistEffect method addSpecialAction.

@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() >= 1 && game.getState().getValue(source.getSourceId().toString() + game.getState().getZoneChangeCounter(source.getSourceId()) + "_assisted") == null) {
        SpecialAction specialAction = new AssistSpecialAction(unpaid, this);
        specialAction.setControllerId(source.getControllerId());
        specialAction.setSourceId(source.getSourceId());
        Target target = new TargetPlayer(1, 1, true, filter);
        specialAction.addTarget(target);
        if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
            game.getState().getSpecialActions().add(specialAction);
        }
    }
}
Also used : TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer) SpecialAction(mage.abilities.SpecialAction) Target(mage.target.Target) TargetPlayer(mage.target.TargetPlayer)

Aggregations

SpecialAction (mage.abilities.SpecialAction)8 Player (mage.players.Player)5 CreateSpecialActionEffect (mage.abilities.effects.common.CreateSpecialActionEffect)3 Target (mage.target.Target)3 CreateDelayedTriggeredAbilityEffect (mage.abilities.effects.common.CreateDelayedTriggeredAbilityEffect)2 ValueHint (mage.abilities.hint.ValueHint)2 Permanent (mage.game.permanent.Permanent)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 ExileFromGraveCost (mage.abilities.costs.common.ExileFromGraveCost)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 AttachEffect (mage.abilities.effects.common.AttachEffect)1 PreventDamageToTargetEffect (mage.abilities.effects.common.PreventDamageToTargetEffect)1 FilterCard (mage.filter.FilterCard)1 FilterPlayer (mage.filter.FilterPlayer)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 ColorPredicate (mage.filter.predicate.mageobject.ColorPredicate)1 TargetPlayer (mage.target.TargetPlayer)1 TargetCardInYourGraveyard (mage.target.common.TargetCardInYourGraveyard)1 TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)1