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;
}
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);
}
Aggregations