use of mage.target.common.TargetCardInHand in project mage by magefree.
the class ThroughTheBreachEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
if (controller.chooseUse(Outcome.PutCreatureInPlay, choiceText, source, game)) {
TargetCardInHand target = new TargetCardInHand(StaticFilters.FILTER_CARD_CREATURE);
if (controller.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
if (controller.moveCards(card, Zone.BATTLEFIELD, source, game)) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
ContinuousEffect effect = new GainAbilityTargetEffect(HasteAbility.getInstance(), Duration.Custom);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
SacrificeTargetEffect sacrificeEffect = new SacrificeTargetEffect("sacrifice " + card.getName(), source.getControllerId());
sacrificeEffect.setTargetPointer(new FixedTarget(permanent, game));
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(sacrificeEffect);
game.addDelayedTriggeredAbility(delayedAbility, source);
return true;
}
}
}
return false;
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class ValakutAwakeningEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard targetCard = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_CARDS);
player.choose(outcome, player.getHand(), targetCard, game);
Cards cards = new CardsImpl(targetCard.getTargets());
player.putCardsOnBottomOfLibrary(cards, game, source, true);
player.drawCards(cards.size() + 1, source, game);
return true;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class WildfireEternalCastEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterCard filter = new FilterInstantOrSorceryCard();
int cardsToCast = controller.getHand().count(filter, source.getControllerId(), source.getSourceId(), game);
if (cardsToCast > 0 && controller.chooseUse(outcome, "Cast an instant or sorcery card from your " + "hand without paying its mana cost?", source, game)) {
TargetCardInHand target = new TargetCardInHand(filter);
controller.chooseTarget(outcome, target, source, game);
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), Boolean.TRUE);
controller.cast(controller.chooseAbilityForCast(card, game, true), game, true, new ApprovingObject(source, game));
game.getState().setValue("PlayFromNotOwnHandZone" + card.getId(), null);
}
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class ExileCardsFromHandAdjuster method adjustCosts.
@Override
public void adjustCosts(Ability ability, Game game) {
if (game.inCheckPlayableState()) {
return;
}
Player player = game.getPlayer(ability.getControllerId());
if (player == null) {
return;
}
int cardCount = player.getHand().count(filter, game);
int toExile = cardCount > 0 ? player.getAmount(0, cardCount, "Choose how many " + filter.getMessage() + " to exile", game) : 0;
if (toExile > 0) {
ability.addCost(new ExileFromHandCost(new TargetCardInHand(toExile, filter)));
CardUtil.reduceCost(ability, 2 * toExile);
}
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class PutCardFromHandOnTopOfLibraryCost method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
TargetCardInHand targetCardInHand = new TargetCardInHand();
targetCardInHand.setRequired(false);
Card card;
if (targetCardInHand.canChoose(source.getSourceId(), controllerId, game) && controller.choose(Outcome.PreventDamage, targetCardInHand, source.getSourceId(), game)) {
card = game.getCard(targetCardInHand.getFirstTarget());
paid = card != null && controller.moveCardToLibraryWithInfo(card, source, game, Zone.HAND, true, true);
}
return paid;
}
Aggregations