Package mage.target

Examples of mage.target.Target


    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null) {
            Target target = new TargetCreaturePermanent(0,1,new FilterCreaturePermanent("creature to keep"), true);
            target.setRequired(true);
            Permanent creatureToKeep = null;
            if (controller.choose(outcome, target, source.getSourceId(), game)) {
                creatureToKeep = game.getPermanent(target.getFirstTarget());
            }
            for(Permanent creature: game.getBattlefield().getActivePermanents(new FilterCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) {
                if (creature != creatureToKeep) {
                    creature.destroy(source.getSourceId(), game, false);
                }
View Full Code Here


    @Override
    public boolean apply(Game game, Ability source) {
        Player controller = game.getPlayer(source.getControllerId());
        if (controller != null && source.getTargets().size() > 0) {
            Target multiTarget = source.getTargets().get(0);
            for (UUID target: multiTarget.getTargets()) {
                Permanent permanent = game.getPermanent(target);
                if (permanent != null) {
                    permanent.addCounters(CounterType.P1P1.createInstance(multiTarget.getTargetAmount(target)), game);
                    game.informPlayers(new StringBuilder(controller.getName()).append(" puts ").append(multiTarget.getTargetAmount(target)).append(" ").append(CounterType.P1P1.getName().toLowerCase()).append(" counter on ").append(permanent.getName()).toString());
                }
            }
            return true;
        }
        return false;
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        Permanent sourcePermanent = game.getPermanent(source.getSourceId());
        if (player != null && sourcePermanent != null) {
            Target target = new TargetPermanent(filter);
            target.setNotTarget(true);
            if (target.canChoose(source.getControllerId(), game)) {
                player.choose(Outcome.Copy, target, source.getSourceId(), game);
                Permanent copyFromPermanent = game.getPermanent(target.getFirstTarget());
                if (copyFromPermanent != null) {
                    game.copyPermanent(copyFromPermanent, sourcePermanent, source, new ApplyToPermanent() {
                        @Override
                        public Boolean apply(Game game, Permanent permanent) {
                            if (!permanent.getCardType().contains(CardType.ENCHANTMENT)) {
View Full Code Here

        // Flying
        this.addAbility(FlyingAbility.getInstance());
        // Whenever Trained Condor attacks, another target creature you control gains flying until end of turn.
        Effect effect = new GainAbilityTargetEffect(FlyingAbility.getInstance(), Duration.EndOfTurn);
        Ability ability = new AttacksTriggeredAbility(effect, false);
        Target target = new TargetControlledCreaturePermanent(1, 1, filter, true);
        ability.addTarget(target);
        this.addAbility(ability);
    }
View Full Code Here

        // Flying
        this.addAbility(FlyingAbility.getInstance());
        // When Shadowborn Demon enters the battlefield, destroy target non-Demon creature.
        Ability ability = new EntersBattlefieldTriggeredAbility(new DestroyTargetEffect(),false);
        Target target = new TargetCreaturePermanent(filter);
        ability.addTarget(target);
        this.addAbility(ability);
        // At the beginning of your upkeep, if there are fewer than six creature cards in your graveyard, sacrifice a creature.
        TriggeredAbility triggeredAbility = new BeginningOfUpkeepTriggeredAbility(new SacrificeTargetEffect(), TargetController.YOU, false);
        target = new TargetControlledCreaturePermanent();
        target.setNotTarget(false);
        triggeredAbility.addTarget(target);
        this.addAbility(new ConditionalTriggeredAbility(
                triggeredAbility,
                new InvertCondition(new CreatureCardsInControllerGraveCondition(6)),
                "At the beginning of your upkeep, if there are fewer than six creature cards in your graveyard, sacrifice a creature"));
View Full Code Here

        this.getSpellAbility().addEffect(effect);
        effect = new FightTargetsEffect();
        effect.setText("Then that creature fights target creature you don't control");
        this.getSpellAbility().addEffect(effect);
        this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent());
        Target target = new TargetCreaturePermanent(filter);
        this.getSpellAbility().addTarget(target);

    }
View Full Code Here

    @Override
    public void adjustTargets(Ability ability, Game game) {
        int xValue = new GetXValue().calculate(game, ability, null);
        if (xValue > 0) {
            Target target = new TargetCreatureOrPlayer(xValue);
            ability.addTarget(target);
        }
    }
View Full Code Here

        Token token = new NahiriTheLithomancerKorSoldierToken();
        if (token.putOntoBattlefield(1, game, source.getSourceId(), source.getControllerId())) {
            Permanent tokenPermanent = game.getPermanent(token.getLastAddedToken());
            if (tokenPermanent != null) {
                //TODO: Make sure the Equipment can legally enchant the token, preferably on targetting.
                Target target = new TargetControlledPermanent(0, 1, filter, true);
                if (target.choose(Outcome.Neutral, source.getControllerId(), source.getSourceId(), game)) {
                    Permanent equipmentPermanent = game.getPermanent(target.getFirstTarget());
                    if (equipmentPermanent != null) {
                        Permanent attachedTo = game.getPermanent(equipmentPermanent.getAttachedTo());
                        if (attachedTo != null) {
                            attachedTo.removeAttachment(equipmentPermanent.getId(), game);
                        }
View Full Code Here

    @Override
    public void assignDamage(int damage, List<UUID> targets, String singleTargetName, UUID sourceId, Game game) {
        updateGameStatePriority("assignDamage", game);
        int remainingDamage = damage;
        while (remainingDamage > 0) {
            Target target = new TargetCreatureOrPlayer();
            if (singleTargetName != null) {
                target.setTargetName(singleTargetName);
            }
            choose(Outcome.Damage, target, sourceId, game);
            if (targets.isEmpty() || targets.contains(target.getFirstTarget())) {
                int damageAmount = getAmount(0, remainingDamage, "Select amount", game);
                Permanent permanent = game.getPermanent(target.getFirstTarget());
                if (permanent != null) {
                    permanent.damage(damageAmount, sourceId, game, false, true);
                    remainingDamage -= damageAmount;
                }
                else {
                    Player player = game.getPlayer(target.getFirstTarget());
                    if (player != null) {
                        player.damage(damageAmount, sourceId, game, false, true);
                        remainingDamage -= damageAmount;
                    }
                }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            if (player.chooseUse(Outcome.PutCardInPlay, "Put an Equipment from hand? (No = from graveyard)", game)) {
                Target target = new TargetCardInHand(0, 1, filter);
                target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
                Card card = player.getHand().get(target.getFirstTarget(), game);
                if (card != null) {
                    player.putOntoBattlefieldWithInfo(card, game, Zone.HAND, source.getSourceId());
                }
            }
            else {
                Target target = new TargetCardInYourGraveyard(0, 1, filter);
                target.choose(Outcome.PutCardInPlay, source.getControllerId(), source.getSourceId(), game);
                Card card = player.getGraveyard().get(target.getFirstTarget(), game);
                if (card != null) {
                    player.putOntoBattlefieldWithInfo(card, game, Zone.GRAVEYARD, source.getSourceId());
                }
            }
            return true;
View Full Code Here

TOP

Related Classes of mage.target.Target

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.