use of mage.target.common.TargetLandPermanent in project mage by magefree.
the class DeusOfCalamityTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getSourceId().equals(this.getSourceId()) && event.getAmount() > 5 && game.getOpponents(this.getControllerId()).contains(event.getTargetId())) {
FilterLandPermanent filter = new FilterLandPermanent("land of the damaged player");
filter.add(new ControllerIdPredicate(event.getTargetId()));
Target target = new TargetLandPermanent(filter);
this.getTargets().clear();
this.addTarget(target);
return true;
}
return false;
}
use of mage.target.common.TargetLandPermanent in project mage by magefree.
the class HokoriDustDrinkerUntapEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(game.getActivePlayerId());
FilterLandPermanent filter = new FilterLandPermanent("land you control");
filter.add(new ControllerIdPredicate(game.getActivePlayerId()));
Target target = new TargetLandPermanent(filter);
if (player != null && player.chooseTarget(Outcome.Untap, target, source, game)) {
for (UUID landId : target.getTargets()) {
Permanent land = game.getPermanent(landId);
if (land != null) {
land.untap(game);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetLandPermanent in project mage by magefree.
the class UntapLandsEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int tappedLands;
if (upTo) {
tappedLands = game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game).size();
} else {
tappedLands = game.getBattlefield().getAllActivePermanents(filter, game).size();
}
TargetLandPermanent target = new TargetLandPermanent(upTo ? 0 : Math.min(tappedLands, amount), amount, filter, true);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
// UI Shortcut: Check if any lands are already tapped. If there are equal/fewer than amount, give the option to add those in to be untapped now.
if (tappedLands <= amount && upTo) {
if (controller.chooseUse(outcome, "Include your tapped lands to untap?", source, game)) {
for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, controller.getId(), game)) {
target.addTarget(land.getId(), source, game);
}
}
}
if (target.choose(Outcome.Untap, source.getControllerId(), source.getSourceId(), game)) {
for (UUID targetId : target.getTargets()) {
Permanent p = game.getPermanent(targetId);
if (p != null) {
p.untap(game);
}
}
}
}
return true;
}
return false;
}
use of mage.target.common.TargetLandPermanent in project mage by magefree.
the class KeldonFirebombersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Permanent> landsToSacrifice = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int amount = game.getBattlefield().getAllActivePermanents(filter, playerId, game).size() - 3;
if (amount > 0) {
FilterLandPermanent playerFilter = filter.copy();
playerFilter.add(new ControllerIdPredicate(playerId));
Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
player.choose(outcome.Sacrifice, target, source.getSourceId(), game);
for (UUID landId : target.getTargets()) {
Permanent land = game.getPermanent(landId);
if (land != null) {
landsToSacrifice.add(land);
}
}
}
}
}
for (Permanent land : landsToSacrifice) {
land.sacrifice(source, game);
}
return true;
}
use of mage.target.common.TargetLandPermanent in project mage by magefree.
the class ThoughtsOfRuinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = controller.getHand().size();
if (amount > 0) {
List<Permanent> permanentsToSacrifice = new ArrayList<>();
// select all lands to sacrifice
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int lands = game.getState().getBattlefield().countAll(filter, playerId, game);
if (amount >= lands) {
permanentsToSacrifice.addAll(game.getState().getBattlefield().getAllActivePermanents(filter, playerId, game));
} else {
FilterLandPermanent playerFilter = filter.copy();
playerFilter.add(new ControllerIdPredicate(playerId));
Target target = new TargetLandPermanent(amount, amount, playerFilter, true);
player.choose(outcome, target, source.getSourceId(), game);
for (UUID landId : target.getTargets()) {
Permanent permanent = game.getPermanent(landId);
if (permanent != null) {
permanentsToSacrifice.add(permanent);
}
}
}
}
}
// sacrifice all lands
for (Permanent permanent : permanentsToSacrifice) {
permanent.sacrifice(source, game);
}
}
}
return false;
}
Aggregations