Search in sources :

Example 51 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class ManaSkimmerTriggeredAbility method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    Permanent source = game.getPermanent(event.getSourceId());
    if (source != null && source.getId().equals(this.getSourceId())) {
        FilterLandPermanent filter = new FilterLandPermanent("land that player controls");
        filter.add(new ControllerIdPredicate(event.getPlayerId()));
        filter.setMessage("land controlled by " + game.getPlayer(event.getTargetId()).getLogName());
        this.getTargets().clear();
        this.addTarget(new TargetPermanent(filter));
        return true;
    }
    return false;
}
Also used : FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) TargetPermanent(mage.target.TargetPermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Example 52 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class MisfortuneEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    Player chosenOpponent = game.getPlayer(targetPointer.getFirst(game, source));
    if (controller != null && chosenOpponent != null) {
        if (chosenOpponent.chooseUse(Outcome.Neutral, "If you choose Yes, the controller puts a +1/+1 counter" + "on each creature they control and they gain 4 life. If no, the controller puts a -1/-1 counter" + "on each creature you control and {this} deals 4 damage to you.", source, game)) {
            Effect putP1P1CounterOnEachControlledCreature = new AddCountersAllEffect(CounterType.P1P1.createInstance(), new FilterControlledCreaturePermanent());
            putP1P1CounterOnEachControlledCreature.apply(game, source);
            controller.gainLife(4, game, source);
        } else {
            FilterCreaturePermanent filterOpponentCreatures = new FilterCreaturePermanent();
            filterOpponentCreatures.add(new ControllerIdPredicate(chosenOpponent.getId()));
            Effect putM1M1CounterOnEachOpponentCreature = new AddCountersAllEffect(CounterType.M1M1.createInstance(), filterOpponentCreatures);
            putM1M1CounterOnEachOpponentCreature.apply(game, source);
            chosenOpponent.damage(4, source.getSourceId(), source, game);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) OneShotEffect(mage.abilities.effects.OneShotEffect) AddCountersAllEffect(mage.abilities.effects.common.counter.AddCountersAllEffect) Effect(mage.abilities.effects.Effect) AddCountersAllEffect(mage.abilities.effects.common.counter.AddCountersAllEffect)

Example 53 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class OrzhovAdvokistEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        List<UUID> players = new ArrayList<>();
        List<UUID> creatures = new ArrayList<>();
        for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
            Player player = game.getPlayer(playerId);
            if (player != null) {
                if (player.chooseUse(outcome, "Put two +1/+1 counters on a creature you control?", source, game)) {
                    Target target = new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature you control (to add two +1/+1 counters on it)"));
                    if (player.choose(outcome, target, playerId, game)) {
                        creatures.add(target.getFirstTarget());
                        players.add(player.getId());
                    }
                }
            }
        }
        for (UUID creatureId : creatures) {
            Permanent creature = game.getPermanent(creatureId);
            if (creature != null) {
                creature.addCounters(CounterType.P1P1.createInstance(2), creature.getControllerId(), source, game);
            }
        }
        for (UUID playerId : players) {
            if (!Objects.equals(playerId, source.getControllerId())) {
                FilterCreaturePermanent filter = new FilterCreaturePermanent();
                filter.add(new ControllerIdPredicate(playerId));
                game.addEffect(new CantAttackYouAllEffect(Duration.UntilYourNextTurn, filter, true), source);
            }
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) Target(mage.target.Target) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) ArrayList(java.util.ArrayList) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) UUID(java.util.UUID) CantAttackYouAllEffect(mage.abilities.effects.common.combat.CantAttackYouAllEffect) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent)

Example 54 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class ReinsOfPowerEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    UUID opponentId = this.getTargetPointer().getFirst(game, source);
    if (opponentId != null) {
        // Untap all creatures you control and all creatures target opponent controls.
        FilterCreaturePermanent filter = new FilterCreaturePermanent();
        filter.add(Predicates.or(new ControllerIdPredicate(source.getControllerId()), new ControllerIdPredicate(opponentId)));
        new UntapAllEffect(filter).apply(game, source);
        // You and that opponent each gain control of all creatures the other controls until end of turn.
        Set<UUID> yourCreatures = new HashSet<>();
        Set<UUID> opponentCreatures = new HashSet<>();
        for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), source.getControllerId(), source.getSourceId(), game)) {
            yourCreatures.add(permanent.getId());
        }
        FilterCreaturePermanent filterOpponent = new FilterCreaturePermanent();
        filterOpponent.add(new ControllerIdPredicate(opponentId));
        for (Permanent permanent : game.getBattlefield().getActivePermanents(filterOpponent, source.getControllerId(), source.getSourceId(), game)) {
            opponentCreatures.add(permanent.getId());
        }
        for (UUID creatureId : yourCreatures) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn, opponentId);
            effect.setTargetPointer(new FixedTarget(creatureId, game));
            game.addEffect(effect, source);
        }
        for (UUID creatureId : opponentCreatures) {
            ContinuousEffect effect = new GainControlTargetEffect(Duration.EndOfTurn);
            effect.setTargetPointer(new FixedTarget(creatureId, game));
            game.addEffect(effect, source);
        }
        // Those creatures gain haste until end of turn.
        game.addEffect(new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filter), source);
        return true;
    }
    return false;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ContinuousEffect(mage.abilities.effects.ContinuousEffect) UUID(java.util.UUID) UntapAllEffect(mage.abilities.effects.common.UntapAllEffect) GainAbilityAllEffect(mage.abilities.effects.common.continuous.GainAbilityAllEffect) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect) HashSet(java.util.HashSet)

Example 55 with ControllerIdPredicate

use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.

the class RowanKenrithDamageEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    FilterCreaturePermanent filter = new FilterCreaturePermanent();
    filter.add(TappedPredicate.TAPPED);
    filter.add(new ControllerIdPredicate(source.getFirstTarget()));
    return new DamageAllEffect(3, filter).apply(game, source);
}
Also used : FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) DamageAllEffect(mage.abilities.effects.common.DamageAllEffect)

Aggregations

ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)153 Player (mage.players.Player)105 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)87 Permanent (mage.game.permanent.Permanent)70 UUID (java.util.UUID)53 TargetPermanent (mage.target.TargetPermanent)53 FilterPermanent (mage.filter.FilterPermanent)51 TargetCreaturePermanent (mage.target.common.TargetCreaturePermanent)41 Target (mage.target.Target)29 FixedTarget (mage.target.targetpointer.FixedTarget)21 TargetPlayer (mage.target.TargetPlayer)16 ContinuousEffect (mage.abilities.effects.ContinuousEffect)15 Effect (mage.abilities.effects.Effect)14 OneShotEffect (mage.abilities.effects.OneShotEffect)13 FilterLandPermanent (mage.filter.common.FilterLandPermanent)13 DamagedPlayerEvent (mage.game.events.DamagedPlayerEvent)11 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)9 FilterNonlandPermanent (mage.filter.common.FilterNonlandPermanent)9 MageObject (mage.MageObject)8 HashSet (java.util.HashSet)7