use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class ManifestTargetPlayerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (targetPlayer != null) {
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = targetPlayer.getLibrary().getTopCards(game, amount);
for (Card card : cards) {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility().getManaCosts();
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
targetPlayer.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
for (Card card : cards) {
Permanent permanent = game.getPermanent(card.getId());
if (permanent != null) {
permanent.setManifested(true);
}
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class HeroOfLeinaTowerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player you = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}");
if (you != null && you.chooseUse(Outcome.BoostCreature, "Do you want to to pay {X}?", source, game)) {
int costX = you.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
Permanent sourcePermanent = game.getPermanent(source.getSourceId());
if (sourcePermanent != null) {
return new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX), true).apply(game, source);
}
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class WildbornPreserverCreateReflexiveTriggerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}");
if (player == null) {
return false;
}
if (!player.chooseUse(outcome, "Pay " + cost.getText() + "?", source, game)) {
return false;
}
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (!cost.pay(source, game, source, source.getControllerId(), false, null)) {
return false;
}
game.fireReflexiveTriggeredAbility(new ReflexiveTriggeredAbility(new AddCountersSourceEffect(CounterType.P1P1.createInstance(costX)), false, "put X +1/+1 counters on {this}"), source);
return true;
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class FlameblastDragonEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}{R}");
if (player != null) {
if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + "? If you do, Flameblast Dragon deals X damage to any target", source, game)) {
int costX = player.announceXMana(0, Integer.MAX_VALUE, "Announce the value for {X}", game, source);
cost.add(new GenericManaCost(costX));
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
Permanent permanent = game.getPermanent(source.getFirstTarget());
if (permanent != null) {
permanent.damage(costX, source.getSourceId(), source, game, false, true);
return true;
}
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
targetPlayer.damage(costX, source.getSourceId(), source, game);
return true;
}
return false;
}
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class GhastlyConscriptionEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(getTargetPointer().getFirst(game, source));
if (controller != null && targetPlayer != null) {
List<Card> cardsToManifest = new ArrayList<>();
for (Card card : targetPlayer.getGraveyard().getCards(StaticFilters.FILTER_CARD_CREATURE, game)) {
cardsToManifest.add(card);
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.GRAVEYARD, true);
}
if (cardsToManifest.isEmpty()) {
return true;
}
Collections.shuffle(cardsToManifest);
game.informPlayers(controller.getLogName() + " shuffles the face-down pile");
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
for (Card card : cardsToManifest) {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility().getManaCosts();
if (manaCosts == null) {
manaCosts = new ManaCostsImpl("{0}");
}
}
MageObjectReference objectReference = new MageObjectReference(card.getId(), card.getZoneChangeCounter(game) + 1, game);
game.addEffect(new BecomesFaceDownCreatureEffect(manaCosts, objectReference, Duration.Custom, FaceDownType.MANIFESTED), newSource);
}
Set<Card> toBattlefield = new LinkedHashSet();
toBattlefield.addAll(cardsToManifest);
controller.moveCards(toBattlefield, Zone.BATTLEFIELD, source, game, false, true, false, null);
return true;
}
return false;
}
Aggregations