use of mage.filter.common.FilterControlledLandPermanent in project mage by magefree.
the class DinOfTheFireherdEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
boolean applied;
Token token = new DinOfTheFireherdToken();
applied = token.putOntoBattlefield(1, game, source, source.getControllerId());
int blackCreaturesControllerControls = game.getBattlefield().countAll(blackCreatureFilter, source.getControllerId(), game);
int redCreaturesControllerControls = game.getBattlefield().countAll(redCreatureFilter, source.getControllerId(), game);
Player targetOpponent = game.getPlayer(targetPointer.getFirst(game, source));
if (targetOpponent != null) {
Effect effect = new SacrificeEffect(new FilterControlledCreaturePermanent(), blackCreaturesControllerControls, "Target Opponent");
effect.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect.apply(game, source);
Effect effect2 = new SacrificeEffect(new FilterControlledLandPermanent(), redCreaturesControllerControls, "Target Opponent");
effect2.setTargetPointer(new FixedTarget(targetOpponent.getId()));
effect2.apply(game, source);
applied = true;
}
return applied;
}
use of mage.filter.common.FilterControlledLandPermanent in project mage by magefree.
the class HazezonTamarEntersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Effect effect = new CreateTokenEffect(new HazezonTamarSandWarriorToken(), new PermanentsOnBattlefieldCount(new FilterControlledLandPermanent()));
effect.setText("create X 1/1 Sand Warrior creature tokens that are red, green, and white, where X is the number of lands you control at that time");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfYourNextUpkeepDelayedTriggeredAbility(effect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
return false;
}
use of mage.filter.common.FilterControlledLandPermanent in project mage by magefree.
the class ScapeshiftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int amount = 0;
TargetControlledPermanent sacrificeLand = new TargetControlledPermanent(0, Integer.MAX_VALUE, new FilterControlledLandPermanent("lands you control"), true);
if (controller.chooseTarget(Outcome.Sacrifice, sacrificeLand, source, game)) {
for (UUID uuid : sacrificeLand.getTargets()) {
Permanent land = game.getPermanent(uuid);
if (land != null) {
land.sacrifice(source, game);
amount++;
}
}
}
TargetCardInLibrary target = new TargetCardInLibrary(amount, new FilterLandCard("lands"));
if (controller.searchLibrary(target, source, game)) {
controller.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, false, null);
controller.shuffleLibrary(source, game);
return true;
}
controller.shuffleLibrary(source, game);
return false;
}
use of mage.filter.common.FilterControlledLandPermanent in project mage by magefree.
the class CataclysmEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
List<Card> chosen = new ArrayList<>();
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledArtifactPermanent(), true);
Target target2 = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true);
Target target3 = new TargetControlledPermanent(1, 1, new FilterControlledEnchantmentPermanent(), true);
Target target4 = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true);
if (target1.canChoose(source.getSourceId(), player.getId(), game)) {
while (player.canRespond() && !target1.isChosen() && target1.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Benefit, target1, source, game);
}
Permanent artifact = game.getPermanent(target1.getFirstTarget());
if (artifact != null) {
chosen.add(artifact);
}
target1.clearChosen();
}
if (target2.canChoose(source.getSourceId(), player.getId(), game)) {
while (player.canRespond() && !target2.isChosen() && target2.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Benefit, target2, source, game);
}
Permanent creature = game.getPermanent(target2.getFirstTarget());
if (creature != null) {
chosen.add(creature);
}
target2.clearChosen();
}
if (target3.canChoose(source.getSourceId(), player.getId(), game)) {
while (player.canRespond() && !target3.isChosen() && target3.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Benefit, target3, source, game);
}
Permanent enchantment = game.getPermanent(target3.getFirstTarget());
if (enchantment != null) {
chosen.add(enchantment);
}
target3.clearChosen();
}
if (target4.canChoose(source.getSourceId(), player.getId(), game)) {
while (player.canRespond() && !target4.isChosen() && target4.canChoose(source.getSourceId(), player.getId(), game)) {
player.chooseTarget(Outcome.Benefit, target4, source, game);
}
Permanent land = game.getPermanent(target4.getFirstTarget());
if (land != null) {
chosen.add(land);
}
target4.clearChosen();
}
}
for (Permanent permanent : game.getBattlefield().getAllActivePermanents()) {
if (!chosen.contains(permanent)) {
permanent.sacrifice(source, game);
}
}
return true;
}
use of mage.filter.common.FilterControlledLandPermanent in project mage by magefree.
the class SerendibDjinnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Target target = new TargetControlledPermanent(1, 1, new FilterControlledLandPermanent(), true);
if (target.canChoose(source.getSourceId(), controller.getId(), game)) {
controller.choose(Outcome.Sacrifice, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent != null) {
permanent.sacrifice(source, game);
if (permanent.hasSubtype(SubType.ISLAND, game)) {
controller.damage(3, source.getSourceId(), source, game);
}
}
}
return true;
}
return false;
}
Aggregations