use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class SquealingDevilEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
ManaCosts cost = new ManaCostsImpl("{X}");
if (player != null) {
if (player.chooseUse(Outcome.BoostCreature, "Pay " + cost.getText() + "?", 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.isCreature(game)) {
ContinuousEffect effect = new BoostTargetEffect(costX, 0, Duration.EndOfTurn);
effect.setTargetPointer(new FixedTarget(permanent, game));
game.addEffect(effect, source);
return true;
}
return false;
}
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class ManifestEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = controller.getLibrary().getTopCards(game, amount);
for (Card card : cards) {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
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);
}
controller.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 HellkiteChargerEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
ManaCosts cost = new ManaCostsImpl("{5}{R}{R}");
if (player.chooseUse(Outcome.Damage, "Pay " + cost.getText() + '?', source, game)) {
cost.clearPaid();
if (cost.pay(source, game, source, source.getControllerId(), false, null)) {
new UntapAllControllerEffect(new FilterAttackingCreature(), "").apply(game, source);
game.getState().getTurnMods().add(new TurnMod(source.getControllerId(), TurnPhase.COMBAT, null, false));
return true;
}
}
}
return false;
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class TariffEffect method processPlayer.
private void processPlayer(Game game, Ability source, Player player) {
MageObject sourceObject = game.getObject(source.getSourceId());
List<Permanent> creatures = getPermanentsWithTheHighestCMC(game, player.getId(), new FilterControlledCreaturePermanent());
Permanent creatureToPayFor = chooseOnePermanent(game, player, creatures);
if (creatureToPayFor != null && sourceObject != null) {
ManaCosts manaCost = ManaCosts.removeVariableManaCost(creatureToPayFor.getManaCost());
String message = "Pay " + manaCost.getText() + " (otherwise sacrifice " + creatureToPayFor.getName() + ")?";
if (player.chooseUse(Outcome.Benefit, message, source, game)) {
if (manaCost.pay(source, game, source, player.getId(), false, null)) {
game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " has paid");
return;
}
}
game.informPlayers(sourceObject.getName() + ": " + player.getLogName() + " hasn't paid");
creatureToPayFor.sacrifice(source, game);
}
}
use of mage.abilities.costs.mana.ManaCosts in project mage by magefree.
the class ThievingAmalgamLifeLossEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player active = game.getPlayer(game.getActivePlayerId());
if (controller == null || active == null) {
return false;
}
Ability newSource = source.copy();
newSource.setWorksFaceDown(true);
Set<Card> cards = active.getLibrary().getTopCards(game, 1);
cards.stream().forEach(card -> {
ManaCosts manaCosts = null;
if (card.isCreature(game)) {
manaCosts = card.getSpellAbility() != null ? card.getSpellAbility().getManaCosts() : null;
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, BecomesFaceDownCreatureEffect.FaceDownType.MANIFESTED), newSource);
});
controller.moveCards(cards, Zone.BATTLEFIELD, source, game, false, true, false, null);
cards.stream().map(Card::getId).map(game::getPermanent).filter(permanent -> permanent != null).forEach(permanent -> permanent.setManifested(true));
return true;
}
Aggregations