use of mage.target.common.TargetCardInHand in project mage by magefree.
the class PutCardFromHandOnTopOfLibrary method pay.
@Override
public boolean pay(Ability ability, Game game, Ability source, UUID controllerId, boolean noMana, Cost costToPay) {
Player controller = game.getPlayer(controllerId);
if (controller != null) {
TargetCardInHand target = new TargetCardInHand();
controller.chooseTarget(Outcome.ReturnToHand, target, ability, game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card != null) {
controller.putCardsOnTopOfLibrary(new CardsImpl(card), game, ability, false);
paid = true;
}
}
return paid;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class MishraArtificerProdigyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
FilterCard filter = new FilterCard("card named " + this.cardName);
filter.add(new NamePredicate(cardName));
Card card = null;
// Graveyard
if (controller.chooseUse(Outcome.Neutral, "Search your graveyard?", source, game)) {
// You can't fail to find the card in your graveyard because it's not hidden
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(1, 1, filter);
if (controller.choose(Outcome.PutCardInPlay, controller.getGraveyard(), target, game)) {
card = game.getCard(target.getFirstTarget());
}
}
// Hand
if (card == null && controller.chooseUse(Outcome.Neutral, "Search your hand?", source, game)) {
TargetCardInHand target = new TargetCardInHand(0, 1, filter);
if (controller.choose(Outcome.PutCardInPlay, controller.getHand(), target, game)) {
card = game.getCard(target.getFirstTarget());
}
}
// Library
if (card == null && controller.chooseUse(Outcome.Neutral, "Search your library?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
if (controller.searchLibrary(target, source, game)) {
card = game.getCard(target.getFirstTarget());
}
controller.shuffleLibrary(source, game);
}
// Put on battlefield
if (card != null) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
}
return true;
}
return false;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class MinionOfTheMightyEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
TargetCardInHand target = new TargetCardInHand(filter);
if (controller == null) {
return false;
}
target.choose(outcome, controller.getId(), source.getSourceId(), game);
Card card = controller.getHand().get(target.getFirstTarget(), game);
if (card == null) {
return false;
}
controller.moveCards(card, Zone.BATTLEFIELD, source, game, true, false, true, null);
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
game.getCombat().addAttackingCreature(permanent.getId(), game);
}
return true;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class NightshadeAssassinEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
FilterCard filter = new FilterCard();
filter.add(new ColorPredicate(ObjectColor.BLACK));
int blackCards = controller.getHand().count(filter, source.getSourceId(), source.getControllerId(), game);
int cardsToReveal = controller.getAmount(0, blackCards, "Reveal how many black cards?", game);
game.informPlayers(controller.getLogName() + " chooses to reveal " + cardsToReveal + " black cards.");
if (cardsToReveal > 0) {
TargetCardInHand target = new TargetCardInHand(cardsToReveal, cardsToReveal, filter);
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
controller.revealCards(sourceObject.getIdName(), new CardsImpl(target.getTargets()), game);
int unboost = target.getTargets().size() * -1;
ContinuousEffect effect = new BoostTargetEffect(unboost, unboost, Duration.EndOfTurn);
effect.setTargetPointer(getTargetPointer());
game.addEffect(effect, source);
}
}
return true;
}
use of mage.target.common.TargetCardInHand in project mage by magefree.
the class NightshadeSeerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
RevealTargetFromHandCost cost = new RevealTargetFromHandCost(new TargetCardInHand(0, Integer.MAX_VALUE, filter));
if (!cost.pay(source, game, source, source.getControllerId(), true)) {
return false;
}
int xValue = -1 * cost.getNumberRevealedCards();
game.addEffect(new BoostTargetEffect(xValue, xValue, Duration.EndOfTurn), source);
return true;
}
Aggregations