Package mage.filter.predicate.permanent

Examples of mage.filter.predicate.permanent.ControllerIdPredicate


        if (event.getType().equals(EventType.DAMAGED_PLAYER)
                && event.getSourceId().equals(this.getSourceId())
                && event.getAmount() > 5
                && game.getOpponents(this.getControllerId()).contains(event.getTargetId())) {
            FilterLandPermanent filter = new FilterLandPermanent("land of the damaged player");
            filter.add(new ControllerIdPredicate(event.getTargetId()));
            Target target = new TargetLandPermanent(filter);
            this.getTargets().clear();
            this.addTarget(target);
            return true;
        }
View Full Code Here


        if (event instanceof DamagedPlayerEvent
                && ((DamagedPlayerEvent) event).isCombatDamage()
                && event.getSourceId().equals(sourceId)) {

            FilterCreaturePermanent filter = new FilterCreaturePermanent("nonblack creature that player controls");
            filter.add(new ControllerIdPredicate(event.getPlayerId()));
            filter.add(Predicates.not(new ColorPredicate(ObjectColor.BLACK)));
            filter.setMessage("nonblack creature controlled by " + game.getPlayer(event.getTargetId()).getName());
            this.getTargets().clear();
            this.addTarget(new TargetPermanent(filter));
            return true;
View Full Code Here

        if (source.getFirstTarget() == null) {
            return false;
        }

        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(new ControllerIdPredicate(source.getFirstTarget()));

        List<Permanent> creatures = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
        for (Permanent creature : creatures) {
            creature.tap(game);
        }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
        if (defenderId != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ControllerIdPredicate(defenderId));
            List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
            for (Permanent permanent : permanents) {
                permanent.damage(1, source.getSourceId(), game, false, true);
            }
            return true;
View Full Code Here

    @Override
    public int calculate(Game game, Ability sourceAbility, Effect effect) {
        if (sourceAbility.getFirstTarget() != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ControllerIdPredicate(sourceAbility.getFirstTarget()));
            int value = game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
            return value;
        } else {
            return 0;
        }
View Full Code Here

    @Override
    public boolean apply(Game game, Ability source) {
        UUID defenderId = game.getCombat().getDefenderId(source.getSourceId());
        if (defenderId != null) {
            FilterCreaturePermanent filter = new FilterCreaturePermanent();
            filter.add(new ControllerIdPredicate(defenderId));
            List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
            for (Permanent permanent : permanents) {
                permanent.damage(6, source.getSourceId(), game, false, true);
            }
            return true;
View Full Code Here

        if (event.getType() == GameEvent.EventType.UPKEEP_STEP_PRE) {
            Player player = game.getPlayer(event.getPlayerId());
            if (player != null) {
                FilterCreaturePermanent filter = new FilterCreaturePermanent("nonartifact creature you control");
                filter.add(Predicates.not(new CardTypePredicate(CardType.ARTIFACT)));
                filter.add(new ControllerIdPredicate(player.getId()));
                Target target = new TargetCreaturePermanent(filter);
                if (target.canChoose(this.getSourceId(), this.getControllerId(), game) && player.chooseTarget(Outcome.DestroyPermanent, target, this, game)) {
                    for (Effect effect: this.getEffects()) {
                        if (effect instanceof DestroyTargetEffect) {
                            effect.setTargetPointer(new FixedTarget(target.getFirstTarget()));
View Full Code Here

        @Override
        public boolean canTarget(UUID controllerId, UUID id, Ability source, Game game) {
                Player player = game.getPlayer(source.getFirstTarget());
                if (player != null) {
                    this.filter = filterTemplate.copy();
                    this.filter.add(new ControllerIdPredicate(player.getId()));
                    return super.canTarget(controllerId, id, source, game);
                }
        return false;
    }
View Full Code Here

    public void adjustTargets(Ability ability, Game game) {
        if (ability instanceof DealsDamageToAPlayerAttachedTriggeredAbility) {
            UUID playerId = ability.getEffects().get(0).getTargetPointer().getFirst(game, ability);
            if (playerId != null) {
                FilterCreaturePermanent filter = new FilterCreaturePermanent("creature that player controls");
                filter.add(new ControllerIdPredicate(playerId));
                Target target = new TargetCreaturePermanent(filter);
                ability.getTargets().clear();
                ability.addTarget(target);
                ability.getEffects().get(0).setTargetPointer(new FirstTargetPointer());
            }
View Full Code Here

        Permanent target = (Permanent) game.getLastKnownInformation(source.getFirstTarget(), Zone.BATTLEFIELD);
        if (target != null) {
            UUID opponent = target.getControllerId();
            if (opponent != null) {
                FilterCreaturePermanent filter = new FilterCreaturePermanent("each other creature that player controls");
                filter.add(new ControllerIdPredicate(opponent));
                filter.add(Predicates.not(new PermanentIdPredicate(target.getId())));
                ContinuousEffect effect = new BoostAllEffect(-2,0, Duration.EndOfTurn, filter, false);
                game.addEffect(effect, source);
                return true;
            }
View Full Code Here

TOP

Related Classes of mage.filter.predicate.permanent.ControllerIdPredicate

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.