use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class HeartPiercerManticoreSacrificeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Target target = new TargetControlledCreaturePermanent(1, 1, StaticFilters.FILTER_CONTROLLED_ANOTHER_CREATURE, true);
if (!controller.choose(outcome, target, source.getSourceId(), game)) {
return false;
}
Permanent toSacrifice = game.getPermanent(target.getFirstTarget());
if (toSacrifice == null) {
return false;
}
int power = toSacrifice.getPower().getValue();
if (!toSacrifice.sacrifice(source, game)) {
return false;
}
ReflexiveTriggeredAbility trigger = new ReflexiveTriggeredAbility(new DamageTargetEffect(power), false, "{this} deals damage equal to that creature's power to any target.");
trigger.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(trigger, source);
return true;
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class SpareDaggerEffect method makeAbility.
@Override
protected Ability makeAbility(Game game, Ability source) {
if (source == null || game == null) {
return null;
}
String sourceName = source.getSourcePermanentIfItStillExists(game).getName();
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(1), false, "This creature deals 1 damage to any target");
ability.addTarget(new TargetAnyTarget());
return new AttacksTriggeredAbility(new DoWhenCostPaid(ability, useAttachedCost.copy().setMageObjectReference(source, game), "Sacrifice " + sourceName + "?"), false, "Whenever this creature attacks, you may sacrifice " + sourceName + ". When you do, this creature deals 1 damage to any target.");
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class LeylineTyrantDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
String manaString;
if (costX == 0) {
manaString = "{0}";
} else {
manaString = "";
for (int i = 0; i < costX; i++) {
manaString += "{R}";
}
}
Cost cost = new ManaCostsImpl<>(manaString);
cost.clearPaid();
if (!cost.pay(source, game, source, source.getControllerId(), false)) {
return false;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(costX), false, "{this} deals " + costX + " damage to any target");
ability.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class MartyrdomRedirectDamageTargetEffect method applies.
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getBattlefield().getPermanent(source.getSourceId());
if (permanent != null) {
if (filter.match(permanent, permanent.getId(), permanent.getControllerId(), game)) {
if (event.getTargetId().equals(getTargetPointer().getFirst(game, source))) {
if (event.getTargetId() != null) {
TargetAnyTarget target = new TargetAnyTarget();
target.add(source.getSourceId(), game);
redirectTarget = target;
return true;
}
}
}
}
return false;
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class ToralfsHammerEffect method checkTrigger.
@Override
public boolean checkTrigger(GameEvent event, Game game) {
DamagedEvent dEvent = (DamagedEvent) event;
if (dEvent.getExcess() < 1 || dEvent.isCombatDamage() || !game.getOpponents(getControllerId()).contains(game.getControllerId(event.getTargetId()))) {
return false;
}
this.getEffects().clear();
this.getTargets().clear();
this.addEffect(new DamageTargetEffect(dEvent.getExcess()));
FilterCreaturePlayerOrPlaneswalker filter = new FilterCreaturePlayerOrPlaneswalker();
filter.getPermanentFilter().add(Predicates.not(new MageObjectReferencePredicate(new MageObjectReference(event.getTargetId(), game))));
this.addTarget(new TargetAnyTarget(filter));
return true;
}
Aggregations