use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class OmenOfFireEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
Player player = game.getPlayer(playerId);
if (player != null) {
int whitePermanents = game.getBattlefield().countAll(filterWhite2, playerId, game);
if (whitePermanents > 0) {
Effect effect = new SacrificeEffect(filterWhite1, whitePermanents, "");
effect.setTargetPointer(new FixedTarget(playerId));
effect.apply(game, source);
}
}
}
return true;
}
return false;
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class PirsWhimEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes();
if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) {
return false;
}
for (Player player : choice.getFriends()) {
if (player != null) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, StaticFilters.FILTER_CARD_LAND);
if (player.searchLibrary(target, source, game)) {
player.moveCards(new CardsImpl(target.getTargets()).getCards(game), Zone.BATTLEFIELD, source, game, true, false, true, null);
player.shuffleLibrary(source, game);
}
}
}
for (Player player : choice.getFoes()) {
if (player != null) {
Effect effect = new SacrificeEffect(StaticFilters.FILTER_PERMANENT_ARTIFACT_OR_ENCHANTMENT, 1, "");
effect.setTargetPointer(new FixedTarget(player.getId(), game));
effect.apply(game, source);
}
}
return true;
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class PhyrexianTotemTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(getSourceId())) {
getEffects().get(0).setTargetPointer(new FixedTarget(getControllerId()));
((SacrificeEffect) getEffects().get(0)).setAmount(StaticValue.get(event.getAmount()));
return true;
}
return false;
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class SkullStormEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
game.getOpponents(source.getControllerId()).forEach((playerId) -> {
Player player = game.getPlayer(playerId);
if (player != null) {
FilterPermanent filter = new FilterCreaturePermanent();
filter.add(new ControllerIdPredicate(playerId));
if (game.getBattlefield().getActivePermanents(filter, source.getControllerId(), game).isEmpty()) {
int lifeToLose = (int) Math.ceil(player.getLife() / 2f);
player.loseLife(lifeToLose, game, source, false);
} else {
Effect effect = new SacrificeEffect(StaticFilters.FILTER_PERMANENT_CREATURE, 1, null);
effect.setTargetPointer(new FixedTarget(playerId, game));
effect.apply(game, source);
}
}
});
return true;
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class PhyrexianObliteratorTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.sourceId)) {
UUID controller = game.getControllerId(event.getSourceId());
if (controller != null) {
Player player = game.getPlayer(controller);
if (player != null) {
getEffects().get(0).setTargetPointer(new FixedTarget(player.getId()));
((SacrificeEffect) getEffects().get(0)).setAmount(StaticValue.get(event.getAmount()));
return true;
}
}
}
return false;
}
Aggregations