use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class StreamOfThoughtEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
TargetCard target = new TargetCardInYourGraveyard(0, 4);
target.setNotTarget(true);
if (!player.choose(outcome, player.getGraveyard(), target, game)) {
return false;
}
Cards cards = new CardsImpl(target.getTargets());
player.putCardsOnTopOfLibrary(cards, game, source, false);
player.shuffleLibrary(source, game);
return true;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class TemptWithImmortalityEffect method returnCreatureFromGraveToBattlefield.
private boolean returnCreatureFromGraveToBattlefield(Player player, Ability source, Game game) {
Target target = new TargetCardInYourGraveyard(StaticFilters.FILTER_CARD_CREATURE);
target.setNotTarget(false);
if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) {
if (player.chooseTarget(outcome, target, source, game)) {
Card card = game.getCard(target.getFirstTarget());
if (card != null) {
return player.moveCards(card, Zone.BATTLEFIELD, source, game);
}
}
}
return false;
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class ExileFromZoneTargetEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player == null) {
return false;
}
Target target = null;
switch(zone) {
case HAND:
target = new TargetCardInHand(Math.min(player.getHand().count(filter, game), amount), filter);
break;
case GRAVEYARD:
target = new TargetCardInYourGraveyard(Math.min(player.getGraveyard().count(filter, game), amount), filter);
break;
default:
}
if (target == null || !target.canChoose(source.getSourceId(), player.getId(), game)) {
return true;
}
target.chooseTarget(Outcome.Exile, player.getId(), source, game);
Cards cards = new CardsImpl(target.getTargets());
if (withSource) {
return player.moveCardsToExile(cards.getCards(game), source, game, true, CardUtil.getExileZoneId(game, source), CardUtil.getSourceName(game, source));
}
return player.moveCards(cards, Zone.EXILED, source, game);
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class DelveEffect method addSpecialAction.
@Override
public void addSpecialAction(Ability source, Game game, ManaCost unpaid) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && !controller.getGraveyard().isEmpty()) {
if (source.getAbilityType() == AbilityType.SPELL && unpaid.getMana().getGeneric() > 0) {
SpecialAction specialAction = new DelveSpecialAction(this);
specialAction.setControllerId(source.getControllerId());
specialAction.setSourceId(source.getSourceId());
int unpaidAmount = unpaid.getMana().getGeneric();
if (!controller.getManaPool().isAutoPayment() && unpaidAmount > 1) {
unpaidAmount = 1;
}
specialAction.addCost(new ExileFromGraveCost(new TargetCardInYourGraveyard(0, Math.min(controller.getGraveyard().size(), unpaidAmount), new FilterCard("cards from your graveyard"), true)));
if (specialAction.canActivate(source.getControllerId(), game).canActivate()) {
game.getState().getSpecialActions().add(specialAction);
}
}
}
}
use of mage.target.common.TargetCardInYourGraveyard in project mage by magefree.
the class DeadlyBrewEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
List<Permanent> toSacrifice = new ArrayList<>();
Permanent yours = null;
for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) {
Player player = game.getPlayer(playerId);
if (player == null) {
continue;
}
TargetPermanent target = new TargetPermanent(filter);
target.setNotTarget(true);
if (!target.canChoose(source.getSourceId(), playerId, game)) {
continue;
}
player.choose(outcome, target, source.getSourceId(), game);
Permanent permanent = game.getPermanent(target.getFirstTarget());
if (permanent == null) {
continue;
}
if (permanent.isControlledBy(source.getControllerId())) {
yours = permanent;
} else {
toSacrifice.add(permanent);
}
}
for (Permanent permanent : toSacrifice) {
if (permanent == null) {
continue;
}
permanent.sacrifice(source, game);
}
Cards yourGrave = new CardsImpl(controller.getGraveyard());
yourGrave.removeIf(uuid -> !game.getCard(uuid).isPermanent(game));
if (yours == null || !yours.sacrifice(source, game)) {
return true;
}
TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_PERMANENT, true);
controller.choose(outcome, yourGrave, target, game);
Card card = controller.getGraveyard().get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
}
return true;
}
Aggregations