use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class FlashOfInsightEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller == null || sourceObject == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
for (Cost cost : source.getCosts()) {
if (cost instanceof ExileFromGraveCost) {
xValue = ((ExileFromGraveCost) cost).getExiledCards().size();
}
}
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, xValue));
controller.lookAtCards(sourceObject.getIdName(), cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
target.setNotTarget(true);
if (controller.chooseTarget(Outcome.DrawCard, cards, target, source, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class OsgirTheReconstructorCreateArtifactTokensEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
Card card = null;
for (Cost cost : source.getCosts()) {
if (!(cost instanceof ExileFromGraveCost)) {
continue;
}
card = ((ExileFromGraveCost) cost).getExiledCards().get(0);
}
if (player == null || card == null) {
return false;
}
CreateTokenCopyTargetEffect effect = new CreateTokenCopyTargetEffect(player.getId(), null, false, 2);
effect.setTargetPointer(new FixedTarget(card.getId(), game.getState().getZoneChangeCounter(card.getId())));
effect.apply(game, source);
return true;
}
use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class TaigamSidisisHandEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Permanent targetCreature = game.getPermanent(getTargetPointer().getFirst(game, source));
if (targetCreature != null) {
int amount = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof ExileFromGraveCost) {
amount = ((ExileFromGraveCost) cost).getExiledCards().size();
ContinuousEffect effect = new BoostTargetEffect(-amount, -amount, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(source.getTargets().getFirstTarget(), game));
game.addEffect(effect, source);
}
}
}
}
return false;
}
use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class WebOfInertiaRestrictionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(getTargetPointer().getFirst(game, source));
MageObject sourceObject = game.getObject(source.getSourceId());
if (player != null && sourceObject != null) {
Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard());
if (cost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.Detriment, "Exile a card from your graveyard?", source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, player.getId(), false, null)) {
if (!game.isSimulation()) {
game.informPlayers(player.getLogName() + " pays the cost to prevent the effect");
}
}
} else {
game.addEffect(new WebOfInertiaRestrictionEffect(player.getId()), source);
}
return true;
}
return false;
}
Aggregations