Search in sources :

Example 16 with TargetControlledCreaturePermanent

use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.

the class ScourgeOfNelTothPlayEffect method applies.

@Override
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
    if (sourceId.equals(source.getSourceId()) && source.isControlledBy(affectedControllerId)) {
        if (game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) {
            Player player = game.getPlayer(affectedControllerId);
            if (player != null) {
                // can sometimes be cast with base mana cost from grave????
                Costs<Cost> costs = new CostsImpl<>();
                costs.add(new SacrificeTargetCost(new TargetControlledCreaturePermanent(2)));
                player.setCastSourceIdWithAlternateMana(sourceId, new ManaCostsImpl<>("{B}{B}"), costs);
                return true;
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) CostsImpl(mage.abilities.costs.CostsImpl) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) Cost(mage.abilities.costs.Cost) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 17 with TargetControlledCreaturePermanent

use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.

the class VictimizeEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledCreaturePermanent(FILTER_CONTROLLED_CREATURE_SHORT_TEXT));
        if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
            // To end effects of the sacrificed creature
            game.getState().processAction(game);
            controller.moveCards(new CardsImpl(getTargetPointer().getTargets(game, source)).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) SacrificeTargetCost(mage.abilities.costs.common.SacrificeTargetCost) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) CardsImpl(mage.cards.CardsImpl)

Example 18 with TargetControlledCreaturePermanent

use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.

the class CrushUnderfootEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        // Choose a Giant creature you control (not targeted, happens during effect resolving )
        Target target = new TargetControlledCreaturePermanent(1, 1, filter, false);
        if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.chooseTarget(outcome, target, source, game)) {
            Permanent giant = game.getPermanent(target.getFirstTarget());
            if (giant != null) {
                game.informPlayers("Crush Underfoot: Chosen Giant is " + giant.getName());
                Permanent targetCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
                if (targetCreature != null) {
                    targetCreature.damage(giant.getPower().getValue(), source.getSourceId(), source, game, false, true);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) TargetCreaturePermanent(mage.target.common.TargetCreaturePermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 19 with TargetControlledCreaturePermanent

use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.

the class GaleaKindlerOfHopeEffect method makeAbility.

private static Ability makeAbility() {
    Ability ability = new EntersBattlefieldTriggeredAbility(new AttachEffect(Outcome.BoostCreature, "attach it to target creature you control"), false).setTriggerPhrase("When this Equipment enters the battlefield, ");
    ability.addTarget(new TargetControlledCreaturePermanent());
    return ability;
}
Also used : SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) VigilanceAbility(mage.abilities.keyword.VigilanceAbility) Ability(mage.abilities.Ability) EntersBattlefieldTriggeredAbility(mage.abilities.common.EntersBattlefieldTriggeredAbility) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) AttachEffect(mage.abilities.effects.common.AttachEffect)

Example 20 with TargetControlledCreaturePermanent

use of mage.target.common.TargetControlledCreaturePermanent in project mage by magefree.

the class LiegeOfThePitEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent sourcePermanent = game.getPermanent(source.getSourceId());
    if (sourcePermanent == null) {
        sourcePermanent = (Permanent) game.getLastKnownInformation(source.getSourceId(), Zone.BATTLEFIELD);
    }
    if (player == null || sourcePermanent == null) {
        return false;
    }
    FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("creature other than " + sourcePermanent.getName());
    filter.add(AnotherPredicate.instance);
    Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
    if (target.canChoose(source.getSourceId(), player.getId(), game)) {
        player.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
        Permanent permanent = game.getPermanent(target.getFirstTarget());
        if (permanent != null) {
            permanent.sacrifice(source, game);
            return true;
        }
    } else {
        player.damage(7, source.getSourceId(), source, game);
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Aggregations

TargetControlledCreaturePermanent (mage.target.common.TargetControlledCreaturePermanent)78 Player (mage.players.Player)73 Permanent (mage.game.permanent.Permanent)64 Target (mage.target.Target)41 UUID (java.util.UUID)29 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)27 TargetPermanent (mage.target.TargetPermanent)18 ArrayList (java.util.ArrayList)14 Cost (mage.abilities.costs.Cost)10 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)9 SacrificeTargetCost (mage.abilities.costs.common.SacrificeTargetCost)8 FixedTarget (mage.target.targetpointer.FixedTarget)8 Ability (mage.abilities.Ability)6 FilterPermanent (mage.filter.FilterPermanent)6 MageObject (mage.MageObject)5 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)5 OneShotEffect (mage.abilities.effects.OneShotEffect)4 Card (mage.cards.Card)4 SimpleActivatedAbility (mage.abilities.common.SimpleActivatedAbility)3 SimpleStaticAbility (mage.abilities.common.SimpleStaticAbility)3