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