use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class HidetsuguDevouringChaosEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.getLibrary().getFromTop(game);
if (card == null) {
return false;
}
PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(game, source, card, TargetController.YOU, Duration.EndOfTurn, false, false, false);
if (card.isLand(game)) {
return true;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getManaValue()), false);
ability.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class CustomTestCard method addCustomEffect_TargetDamage.
/**
* Add target damage ability that can be called by text: "target damage xxx"
*
* @param controller
* @param damageAmount
*/
protected void addCustomEffect_TargetDamage(TestPlayer controller, int damageAmount) {
Ability ability = new SimpleActivatedAbility(new DamageTargetEffect(damageAmount).setText("target damage " + damageAmount), new ManaCostsImpl(""));
ability.addTarget(new TargetAnyTarget());
addCustomCardWithAbility("target damage " + damageAmount + " for " + controller.getName(), controller, ability);
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class FireballTargetCreatureOrPlayer method getTargetOptions.
/**
* This is only used by AI players
*
* @param source
* @param game
* @return
*/
@Override
public List<TargetAnyTarget> getTargetOptions(Ability source, Game game) {
List<TargetAnyTarget> options = new ArrayList<>();
int xVal = source.getManaCostsToPay().getX();
if (xVal < 1) {
return options;
}
for (int numberTargets = 1; numberTargets == 1 || xVal / (numberTargets - 1) > 1; numberTargets++) {
Set<UUID> possibleTargets = possibleTargets(source.getSourceId(), source.getControllerId(), game);
// less possible targets than we're trying to set
if (possibleTargets.size() < numberTargets) {
return options;
}
// less than 1 damage per target = 0, add no such options
if ((xVal - (numberTargets - 1)) / numberTargets < 1) {
continue;
}
possibleTargets.removeAll(getTargets());
for (UUID targetId : possibleTargets) {
TargetAnyTarget target = this.copy();
target.clearChosen();
target.addTarget(targetId, source, game, true);
if (target.getTargets().size() == numberTargets) {
chosen = true;
}
if (!target.isChosen()) {
Iterator<UUID> it2 = possibleTargets.iterator();
while (it2.hasNext() && !target.isChosen()) {
UUID nextTargetId = it2.next();
target.addTarget(nextTargetId, source, game, true);
if (target.getTargets().size() == numberTargets) {
chosen = true;
}
}
}
if (target.isChosen()) {
options.add(target);
}
}
}
return options;
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class MountVelusManticoreEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Card card = player.discard(0, 1, false, source, game).getRandom(game);
if (card == null) {
return false;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(card.getCardType(game).size()), false, "{this} deals X damage " + "to any target, where X is the number of card types the discarded card has");
ability.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
use of mage.target.common.TargetAnyTarget in project mage by magefree.
the class TheRoyalScionsCreateReflexiveTriggerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
effect.apply(game, source);
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new DamageTargetEffect(CardsInControllerHandCount.instance), false, "{this} deals damage to any target equal to the number of cards in your hand");
ability.addTarget(new TargetAnyTarget());
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
Aggregations