use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class DoomForetoldEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(game.getActivePlayerId());
if (controller == null || player == null) {
return false;
}
FilterPermanent filter2 = filter.copy();
filter2.add(new ControllerIdPredicate(player.getId()));
if (game.getBattlefield().contains(filter2, source, game, 1)) {
TargetPermanent target = new TargetPermanent(filter2);
target.setNotTarget(true);
if (player.choose(Outcome.Sacrifice, target, source.getSourceId(), game)) {
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null && permanent.sacrifice(source, game)) {
return true;
}
}
}
player.discard(1, false, false, source, game);
player.loseLife(2, game, source, false);
controller.drawCards(1, source, game);
controller.gainLife(2, game, source);
effect1.apply(game, source);
effect2.apply(game, source);
return true;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class FatalLoreEffect 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 draws three cards. If no, the controller gets to destroy up to two target creatures that you control and you get to draw up to 3 cards. Those creatures can't be regenerated.", source, game)) {
controller.drawCards(3, source, game);
} else {
FilterCreaturePermanent filter = new FilterCreaturePermanent("chosen opponent's creature");
filter.add(new ControllerIdPredicate(chosenOpponent.getId()));
TargetCreaturePermanent target = new TargetCreaturePermanent(0, 2, filter, false);
if (target.canChoose(source.getSourceId(), controller.getId(), game) && controller.choose(Outcome.DestroyPermanent, target, source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Effect destroyCreature = new DestroyTargetEffect(true);
destroyCreature.setTargetPointer(new FixedTarget(targetId, game));
destroyCreature.apply(game, source);
}
Effect opponentDrawsCards = new DrawCardTargetEffect(StaticValue.get(3), false, true);
opponentDrawsCards.setTargetPointer(new FixedTarget(chosenOpponent.getId()));
opponentDrawsCards.apply(game, source);
return true;
}
}
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class JolraelEmpressOfBeastsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
FilterPermanent filter = new FilterLandPermanent();
filter.add(new ControllerIdPredicate(targetPlayer.getId()));
game.addEffect(new BecomesCreatureAllEffect(new CreatureToken(3, 3), "lands", filter, Duration.EndOfTurn, false), source);
return true;
}
return false;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class OKagachiVengefulKamiWatcher method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
Player player = game.getPlayer(event.getTargetId());
if (player == null || !((DamagedPlayerEvent) event).isCombatDamage() || !event.getSourceId().equals(getSourceId())) {
return false;
}
this.getEffects().setValue("damagedPlayer", event.getTargetId());
FilterPermanent filter = new FilterNonlandPermanent("nonland permanent controlled by " + player.getName());
filter.add(new ControllerIdPredicate(event.getTargetId()));
this.getTargets().clear();
this.addTarget(new TargetPermanent(filter));
return true;
}
use of mage.filter.predicate.permanent.ControllerIdPredicate in project mage by magefree.
the class SoulSeizerEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedPlayerEvent damageEvent = (DamagedPlayerEvent) event;
if (damageEvent.isCombatDamage() && event.getSourceId().equals(this.getSourceId())) {
Player opponent = game.getPlayer(event.getPlayerId());
if (opponent != null) {
FilterCreaturePermanent filter = new FilterCreaturePermanent("creature " + opponent.getLogName() + " controls");
filter.add(new ControllerIdPredicate(opponent.getId()));
this.getTargets().clear();
this.addTarget(new TargetCreaturePermanent(filter));
return true;
}
}
return false;
}
Aggregations