use of mage.abilities.costs.Cost in project mage by magefree.
the class FalkenrathTorturerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost) {
Permanent sacrificedCreature = ((SacrificeTargetCost) cost).getPermanents().get(0);
Permanent sourceCreature = game.getPermanent(source.getSourceId());
if (sacrificedCreature.hasSubtype(SubType.HUMAN, game) && sourceCreature != null) {
sourceCreature.addCounters(CounterType.P1P1.createInstance(), source.getControllerId(), source, game);
return true;
}
}
}
return false;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class EyeOfYawgmothEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller == null) {
return false;
}
int power = 0;
for (Cost cost : source.getCosts()) {
if (cost instanceof SacrificeTargetCost && !((SacrificeTargetCost) cost).getPermanents().isEmpty()) {
power = ((SacrificeTargetCost) cost).getPermanents().get(0).getPower().getValue();
break;
}
}
if (power > 0) {
Cards cards = new CardsImpl(controller.getLibrary().getTopCards(game, power));
controller.revealCards(source, cards, game);
TargetCard target = new TargetCard(Zone.LIBRARY, new FilterCard("card to put into your hand"));
if (controller.choose(Outcome.DrawCard, cards, target, game)) {
Card card = cards.get(target.getFirstTarget(), game);
if (card != null) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.moveCards(cards, Zone.EXILED, source, game);
}
return true;
}
use of mage.abilities.costs.Cost 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.Cost in project mage by magefree.
the class GlacianPowerstoneEngineerCost method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
int xValue = source.getManaCostsToPay().getX();
for (Cost cost : source.getCosts()) {
if (cost instanceof GlacianPowerstoneEngineerCost) {
xValue = ((GlacianPowerstoneEngineerCost) cost).getAmount();
break;
}
}
if (xValue < 1) {
return false;
}
Cards cards = new CardsImpl(player.getLibrary().getTopCards(game, xValue));
if (cards.isEmpty()) {
return false;
}
TargetCard targetCard = new TargetCardInLibrary(1, StaticFilters.FILTER_CARD);
player.choose(outcome, cards, targetCard, game);
Card card = game.getCard(targetCard.getFirstTarget());
if (card != null && player.moveCards(card, Zone.HAND, source, game)) {
cards.remove(card);
}
player.moveCards(cards, Zone.GRAVEYARD, source, game);
return true;
}
use of mage.abilities.costs.Cost in project mage by magefree.
the class GorexTheTombshellReturnEffect method apply.
@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
SpellAbility spellAbility = (SpellAbility) abilityToModify;
for (Cost cost : spellAbility.getCosts()) {
if (!(cost instanceof ExileXFromYourGraveCost)) {
continue;
}
if (game.inCheckPlayableState()) {
// allows to cast in getPlayable
int reduction = ((ExileXFromYourGraveCost) cost).getMaxValue(spellAbility, game);
CardUtil.adjustCost(spellAbility, reduction * 2);
} else {
// real cast
int reduction = ((ExileXFromYourGraveCost) cost).getAmount();
CardUtil.adjustCost(spellAbility, reduction * 2);
}
break;
}
return true;
}
Aggregations