use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class TorrentOfSoulsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetedPlayer = game.getPlayer(source.getTargets().get(1).getFirstTarget());
if (targetedPlayer != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(targetedPlayer.getId()));
ContinuousEffect boostEffect = new BoostAllEffect(2, 0, Duration.EndOfTurn, filter, true);
ContinuousEffect gainAbilityEffect = new GainAbilityAllEffect(HasteAbility.getInstance(), Duration.EndOfTurn, filter);
game.addEffect(boostEffect, source);
game.addEffect(gainAbilityEffect, source);
return true;
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class ZndrspltsJudgmentEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
choice.chooseFriendOrFoe(controller, source, game);
for (Player player : choice.getFriends()) {
if (player == null) {
continue;
}
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
filter.add(new ControllerIdPredicate(player.getId()));
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
if (!player.choose(Outcome.Copy, target, source.getSourceId(), game)) {
continue;
}
Effect effect = new CreateTokenCopyTargetEffect(player.getId());
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
}
for (Player player : choice.getFoes()) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you control");
filter.add(new ControllerIdPredicate(player.getId()));
TargetCreaturePermanent target = new TargetCreaturePermanent(filter);
if (!player.choose(Outcome.ReturnToHand, target, source.getSourceId(), game)) {
continue;
}
Effect effect = new ReturnToHandTargetEffect();
effect.setTargetPointer(new FixedTarget(target.getFirstTarget(), game));
effect.apply(game, source);
}
return true;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class OpponentControlsPermanentCondition method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean conditionApplies = false;
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
FilterPermanent localFilter = filter.copy();
localFilter.add(new ControllerIdPredicate(opponentId));
if (ComparisonType.compare(game.getBattlefield().count(localFilter, source.getSourceId(), source.getControllerId(), game), type, this.count)) {
conditionApplies = true;
break;
}
}
return conditionApplies;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class EmissaryOfDespairCount method calculate.
@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
if (effect.getTargetPointer().getFirst(game, sourceAbility) == null) {
return 0;
}
FilterArtifactPermanent filter = new FilterArtifactPermanent();
filter.add(new ControllerIdPredicate(effect.getTargetPointer().getFirst(game, sourceAbility)));
return game.getBattlefield().count(filter, sourceAbility.getSourceId(), sourceAbility.getControllerId(), game);
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class EmberGaleEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
RestrictionEffect effect = new CantBlockAllEffect(filter, Duration.EndOfTurn);
game.addEffect(effect, source);
FilterPermanent filter2 = new FilterPermanent();
filter2.add(new ControllerIdPredicate(targetPlayer.getId()));
filter2.add(Predicates.or(new ColorPredicate(ObjectColor.WHITE), new ColorPredicate(ObjectColor.BLUE)));
filter2.add(CardType.CREATURE.getPredicate());
for (Permanent creature : game.getBattlefield().getAllActivePermanents(filter2, targetPlayer.getId(), game)) {
creature.damage(1, source.getSourceId(), source, game, false, true);
}
return true;
}
return false;
}
Aggregations