use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class DemilichPlayEffect method applies.
@Override
public boolean applies(UUID objectId, Ability source, UUID affectedControllerId, Game game) {
if (source.getSourceId().equals(objectId) && source.isControlledBy(affectedControllerId) && game.getState().getZone(objectId) == Zone.GRAVEYARD) {
Player controller = game.getPlayer(affectedControllerId);
if (controller != null) {
Costs<Cost> costs = new CostsImpl<>();
costs.add(new ExileFromGraveCost(new TargetCardInYourGraveyard(4, StaticFilters.FILTER_CARD_INSTANT_OR_SORCERY_FROM_YOUR_GRAVEYARD)));
controller.setCastSourceIdWithAlternateMana(objectId, new ManaCostsImpl<>("{U}{U}{U}{U}"), costs);
return true;
}
}
return false;
}
use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class UrzasTomeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
new DrawCardSourceControllerEffect(1).apply(game, source);
if (controller != null && controller.chooseUse(Outcome.Exile, "Exile a historic card from your graveyard?", source, game)) {
Cost cost = new ExileFromGraveCost(new TargetCardInYourGraveyard(new FilterHistoricCard()));
if (cost.canPay(source, source, controller.getId(), game)) {
if (cost.pay(source, game, source, controller.getId(), false, null)) {
return true;
}
}
}
if (controller != null) {
controller.discard(1, false, false, source, game);
return true;
}
return false;
}
use of mage.abilities.costs.common.ExileFromGraveCost 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.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class DelveEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Spell spell = game.getStack().getSpell(source.getSourceId());
if (controller != null && spell != null) {
ExileFromGraveCost exileFromGraveCost = (ExileFromGraveCost) source.getCosts().get(0);
List<Card> exiledCards = exileFromGraveCost.getExiledCards();
if (!exiledCards.isEmpty()) {
Cards toDelve = new CardsImpl();
for (Card card : exiledCards) {
toDelve.add(card);
}
ManaPool manaPool = controller.getManaPool();
manaPool.addMana(Mana.ColorlessMana(toDelve.size()), game, source);
manaPool.unlockManaType(ManaType.COLORLESS);
String keyString = CardUtil.getCardZoneString("delvedCards", source.getSourceId(), game);
@SuppressWarnings("unchecked") Cards delvedCards = (Cards) game.getState().getValue(keyString);
if (delvedCards == null) {
game.getState().setValue(keyString, toDelve);
} else {
delvedCards.addAll(toDelve);
}
// can't use mana abilities after that (delve cost must be payed after mana abilities only)
spell.setCurrentActivatingManaAbilitiesStep(ActivationManaAbilityStep.AFTER);
}
return true;
}
return false;
}
use of mage.abilities.costs.common.ExileFromGraveCost in project mage by magefree.
the class CorpseweftEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
int amount = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof ExileFromGraveCost) {
amount = ((ExileFromGraveCost) cost).getExiledCards().size() * 2;
new CreateTokenEffect(new CorpseweftZombieToken(amount, amount), 1, true, false).apply(game, source);
}
}
if (amount > 0) {
}
}
return false;
}
Aggregations