use of mage.abilities.effects.common.SacrificeEffect 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.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class LabyrinthRaptorEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = getTargetPointer().getFirstTargetPermanentOrLKI(game, source);
if (permanent == null) {
return false;
}
Player player = game.getPlayer(game.getCombat().getDefendingPlayerId(permanent.getId(), game));
if (player == null) {
return false;
}
FilterPermanent filterPermanent = new FilterPermanent("creature blocking " + permanent.getIdName());
filterPermanent.add(new BlockingAttackerIdPredicate(permanent.getId()));
Effect effect = new SacrificeEffect(filterPermanent, 1, "");
effect.setTargetPointer(new FixedTarget(player.getId(), game));
return effect.apply(game, source);
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class PhyrexianNegatorTriggeredAbility method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
if (event.getTargetId().equals(this.sourceId)) {
UUID controller = game.getControllerId(event.getTargetId());
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;
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class ConsumeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player player = game.getPlayer(source.getFirstTarget());
if (player == null || controller == null) {
return false;
}
int greatestPower = 0;
for (Permanent permanent : game.getBattlefield().getAllActivePermanents(player.getId())) {
if (permanent != null && permanent.isCreature(game)) {
greatestPower = Math.max(permanent.getPower().getValue(), greatestPower);
}
}
FilterPermanent filter = new FilterCreaturePermanent("creature with power " + greatestPower);
filter.add(new PowerPredicate(ComparisonType.EQUAL_TO, greatestPower));
new SacrificeEffect(filter, 1, "").apply(game, source);
controller.gainLife(greatestPower, game, source);
return true;
}
use of mage.abilities.effects.common.SacrificeEffect in project mage by magefree.
the class EarthlinkEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = (Permanent) game.getLastKnownInformation(this.getTargetPointer().getFirst(game, source), Zone.BATTLEFIELD);
if (permanent != null) {
Player controller = game.getPlayer(permanent.getControllerId());
if (controller != null) {
Effect effect = new SacrificeEffect(StaticFilters.FILTER_LAND, 1, "that creature's controller");
effect.setTargetPointer(new FixedTarget(controller.getId(), game));
effect.apply(game, source);
}
}
return false;
}
Aggregations