use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class NilsDisciplineEnforcerEffect method getManaCostToPay.
@Override
public ManaCosts getManaCostToPay(GameEvent event, Ability source, Game game) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent == null) {
return null;
}
int count = permanent.getCounters(game).keySet().stream().mapToInt(permanent.getCounters(game)::getCount).sum();
if (count < 1) {
return null;
}
return new ManaCostsImpl("{" + count + '}');
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class RootwaterThiefEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Player damagedPlayer = game.getPlayer(targetPointer.getFirst(game, source));
if (controller == null || damagedPlayer == null) {
return false;
}
String message = "Pay {2} to exile a card from damaged player's library?";
Cost cost = new ManaCostsImpl("{2}");
if (controller.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source, controller.getId(), false, null)) {
TargetCardInLibrary target = new TargetCardInLibrary();
if (controller.searchLibrary(target, source, game, damagedPlayer.getId())) {
if (!target.getTargets().isEmpty()) {
Card card = damagedPlayer.getLibrary().remove(target.getFirstTarget(), game);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.LIBRARY, true);
}
}
}
damagedPlayer.shuffleLibrary(source, game);
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class StenchOfEvilEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
for (Permanent land : game.getBattlefield().getAllActivePermanents(filter, game)) {
UUID landControllerId = land.getControllerId();
if (land.destroy(source, game, false)) {
Cost cost = new ManaCostsImpl("{2}");
Player landController = game.getPlayer(landControllerId);
if (landController != null && cost.canPay(source, source, landControllerId, game) && !cost.pay(source, game, source, landControllerId, false)) {
landController.damage(1, source.getSourceId(), source, game);
}
}
}
return true;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class VaporousDjinnEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Permanent permanent = game.getPermanent(source.getSourceId());
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cost cost = new ManaCostsImpl("{U}{U}");
String message = "Pay {U}{U} to prevent this permanent from phasing out?";
if (!(controller.chooseUse(Outcome.Benefit, message, source, game) && cost.pay(source, game, source, controller.getId(), false, null))) {
permanent.phaseOut(game);
}
return true;
}
return false;
}
use of mage.abilities.costs.mana.ManaCostsImpl in project mage by magefree.
the class ManaPoolTest method test_ConditionalMana_OneXSpell.
@Test
public void test_ConditionalMana_OneXSpell() {
addCustomCardWithAbility("add 10", playerA, new SimpleActivatedAbility(Zone.ALL, new AddConditionalManaEffect(Mana.RedMana(10), new InstantOrSorcerySpellManaBuilder()), new ManaCostsImpl("")));
// {X}{R}{R}
addCard(Zone.HAND, playerA, "Volcanic Geyser");
// make mana
activateAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Add {R}");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10);
// use for spell
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Volcanic Geyser", playerB);
setChoice(playerA, "X=1");
waitStackResolved(1, PhaseStep.PRECOMBAT_MAIN);
checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 10 - 3);
checkLife("after", 1, PhaseStep.END_TURN, playerB, 20 - 1);
setStopAt(1, PhaseStep.END_TURN);
setStrictChooseMode(true);
execute();
assertAllCommandsUsed();
}
Aggregations