use of mage.target.common.TargetOpponentsCreaturePermanent in project mage by magefree.
the class CemeteryDesecratorRemoveCountersEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
TargetCardInGraveyard target = new TargetCardInGraveyard(filter);
target.setNotTarget(true);
controller.choose(outcome, target, source.getSourceId(), game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
int manaValue = card.getManaValue();
if (controller.moveCards(card, Zone.EXILED, source, game)) {
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new CemeteryDesecratorRemoveCountersEffect(manaValue), false, triggerText);
ability.addTarget(new TargetPermanent());
Mode mode = new Mode(new BoostTargetEffect(-manaValue, -manaValue, Duration.EndOfTurn).setText("Target creature an opponent controls gets -X/-X until end of turn, where X is the mana value of the exiled card"));
mode.addTarget(new TargetOpponentsCreaturePermanent());
ability.addMode(mode);
game.fireReflexiveTriggeredAbility(ability, source);
return true;
}
}
}
return false;
}
use of mage.target.common.TargetOpponentsCreaturePermanent in project mage by magefree.
the class ViviensInvocationDamageEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, 7));
if (cards.isEmpty()) {
return true;
}
TargetCard target = new TargetCard(Zone.LIBRARY, filter);
target.setNotTarget(true);
controller.choose(Outcome.PutCreatureInPlay, cards, target, game);
Card card = cards.get(target.getFirstTarget(), game);
if (card == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
cards.remove(card);
}
Permanent permanent = game.getPermanent(card.getId());
if (permanent == null) {
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
ReflexiveTriggeredAbility ability = new ReflexiveTriggeredAbility(new ViviensInvocationDamageEffect(new MageObjectReference(permanent, game)), false, "it deals damage equals to its power to target creature an opponent controls");
ability.addTarget(new TargetOpponentsCreaturePermanent());
game.fireReflexiveTriggeredAbility(ability, source);
controller.putCardsOnBottomOfLibrary(cards, game, source, false);
return true;
}
use of mage.target.common.TargetOpponentsCreaturePermanent in project mage by magefree.
the class CinderheartGiantEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null || game.getBattlefield().count(StaticFilters.FILTER_OPPONENTS_PERMANENT_CREATURE, source.getSourceId(), source.getControllerId(), game) < 1) {
return false;
}
TargetPermanent target = new TargetOpponentsCreaturePermanent();
target.setNotTarget(true);
target.setRandom(true);
target.chooseTarget(outcome, player.getId(), source, game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
return permanent != null && permanent.damage(7, source.getSourceId(), source, game) > 0;
}
Aggregations