Search in sources :

Example 1 with TapAllEffect

use of mage.abilities.effects.common.TapAllEffect in project mage by magefree.

the class RohgahhOfKherKeepEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    Permanent permanent = game.getPermanent(source.getSourceId());
    if (player == null) {
        return false;
    }
    Cost cost = new ManaCostsImpl("{R}{R}{R}");
    if (!cost.canPay(source, source, player.getId(), game) || !player.chooseUse(Outcome.Benefit, "Pay {R}{R}{R}?", source, game) || !cost.pay(source, game, source, player.getId(), false)) {
        TargetOpponent target = new TargetOpponent();
        Player opponent = null;
        if (target.choose(Outcome.Detriment, player.getId(), source.getSourceId(), game)) {
            opponent = game.getPlayer(target.getFirstTarget());
        }
        new TapAllEffect(filter).apply(game, source);
        if (permanent != null) {
            permanent.tap(source, game);
        }
        if (opponent != null) {
            new GainControlAllEffect(Duration.Custom, filter, opponent.getId()).apply(game, source);
            if (permanent != null) {
                ContinuousEffect effect = new GainControlTargetEffect(Duration.Custom, true, opponent.getId());
                effect.setTargetPointer(new FixedTarget(permanent, game));
                game.addEffect(effect, source);
            }
        }
        return true;
    }
    return false;
}
Also used : TapAllEffect(mage.abilities.effects.common.TapAllEffect) FixedTarget(mage.target.targetpointer.FixedTarget) Player(mage.players.Player) TargetOpponent(mage.target.common.TargetOpponent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) GainControlAllEffect(mage.abilities.effects.common.continuous.GainControlAllEffect) ContinuousEffect(mage.abilities.effects.ContinuousEffect) Cost(mage.abilities.costs.Cost) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) GainControlTargetEffect(mage.abilities.effects.common.continuous.GainControlTargetEffect)

Example 2 with TapAllEffect

use of mage.abilities.effects.common.TapAllEffect in project mage by magefree.

the class RegnasSanctionEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
    if (!choice.chooseFriendOrFoe(controller, source, game)) {
        return false;
    }
    FilterPermanent filterToTap = new FilterCreaturePermanent();
    for (Player player : choice.getFoes()) {
        TargetPermanent target = new TargetPermanent(filter);
        target.setNotTarget(true);
        if (game.getBattlefield().contains(filter, source, game, 1) && player.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
            filterToTap.add(Predicates.not(new PermanentIdPredicate(target.getFirstTarget())));
        }
    }
    choice.getFriends().stream().map(MageItem::getId).map(ControllerIdPredicate::new).map(Predicates::not).forEach(filterToTap::add);
    for (Permanent permanent : game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)) {
        if (choice.getFriends().stream().map(MageItem::getId).anyMatch(permanent::isControlledBy)) {
            permanent.addCounters(CounterType.P1P1.createInstance(), source, game);
        }
    }
    return new TapAllEffect(filterToTap).apply(game, source);
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) TapAllEffect(mage.abilities.effects.common.TapAllEffect) Player(mage.players.Player) FilterPermanent(mage.filter.FilterPermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) FilterPermanent(mage.filter.FilterPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) ChooseFriendsAndFoes(mage.choices.ChooseFriendsAndFoes) ControllerIdPredicate(mage.filter.predicate.permanent.ControllerIdPredicate) TargetPermanent(mage.target.TargetPermanent)

Aggregations

TapAllEffect (mage.abilities.effects.common.TapAllEffect)2 FilterCreaturePermanent (mage.filter.common.FilterCreaturePermanent)2 Permanent (mage.game.permanent.Permanent)2 Player (mage.players.Player)2 Cost (mage.abilities.costs.Cost)1 ManaCostsImpl (mage.abilities.costs.mana.ManaCostsImpl)1 ContinuousEffect (mage.abilities.effects.ContinuousEffect)1 GainControlAllEffect (mage.abilities.effects.common.continuous.GainControlAllEffect)1 GainControlTargetEffect (mage.abilities.effects.common.continuous.GainControlTargetEffect)1 ChooseFriendsAndFoes (mage.choices.ChooseFriendsAndFoes)1 FilterPermanent (mage.filter.FilterPermanent)1 FilterControlledCreaturePermanent (mage.filter.common.FilterControlledCreaturePermanent)1 ControllerIdPredicate (mage.filter.predicate.permanent.ControllerIdPredicate)1 PermanentIdPredicate (mage.filter.predicate.permanent.PermanentIdPredicate)1 TargetPermanent (mage.target.TargetPermanent)1 TargetOpponent (mage.target.common.TargetOpponent)1 FixedTarget (mage.target.targetpointer.FixedTarget)1