use of mage.Mana in project mage by magefree.
the class PaleMoonReplacementEffect method replaceEvent.
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
ManaEvent manaEvent = (ManaEvent) event;
Mana mana = manaEvent.getMana();
mana.setToMana(Mana.ColorlessMana(mana.count()));
return false;
}
use of mage.Mana in project mage by magefree.
the class SelvalaExplorerReturnedEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
if (game != null) {
int parleyCount = ParleyCount.getInstance().calculate(game, source, this);
Player player = getPlayer(game, source);
if (player != null) {
player.gainLife(parleyCount, game, source);
}
return Mana.GreenMana(parleyCount);
}
return new Mana();
}
use of mage.Mana in project mage by magefree.
the class XenagosExileEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player != null) {
int x = game.getBattlefield().count(new FilterControlledCreaturePermanent(), source.getSourceId(), source.getControllerId(), game);
if (x == 0) {
return false;
}
Mana mana = new Mana();
int redCount = player.getAmount(0, x, "How much <b>RED</b> mana add to pool? (available: " + x + ", another mana goes to <b>GREEN</b>)?", game);
int greenCount = Math.max(0, x - redCount);
mana.setRed(redCount);
mana.setGreen(greenCount);
if (mana.count() > 0) {
player.getManaPool().addMana(mana, game, source);
return true;
}
}
return false;
}
use of mage.Mana in project mage by magefree.
the class ManaUtilTest method testManaAvailEnough.
/**
* Checks if the given available Mana is enough to pay a given mana cost
*
* @param manaCostsToPay
* @param availablyAny
* @param available
* @param expected
*/
private void testManaAvailEnough(String manaCostsToPay, int availablyAny, String available, boolean expected) {
ManaCost unpaid = new ManaCostsImpl(manaCostsToPay);
ManaCost costAvailable = new ManaCostsImpl(available);
Mana manaAvailable = costAvailable.getMana();
manaAvailable.setAny(availablyAny);
if (expected) {
Assert.assertTrue("The available Mana " + costAvailable.getText() + " should be enough to pay the costs " + unpaid.getText(), unpaid.getMana().enough(manaAvailable));
} else {
Assert.assertFalse("The available Mana " + costAvailable.getText() + " shouldn't be enough to pay the costs " + unpaid.getText(), unpaid.getMana().enough(manaAvailable));
}
}
use of mage.Mana in project mage by magefree.
the class AssistEffect method getManaOptions.
@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
ManaOptions options = new ManaOptions();
if (unpaid.getMana().getGeneric() == 0) {
// nothing to pay
return options;
}
// AI can't use assist (can't ask another player to help), maybe in teammode it can be enabled, but tests must works all the time
// Outcome.AIDontUseIt
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && controller.isComputer()) {
return options;
}
// search opponents who can help with generic pay
int opponentCanPayMax = 0;
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
Player opponent = game.getPlayer(opponentId);
if (opponent != null) {
// basic and pool, but no coditional mana
ManaOptions availableMana = opponent.getManaAvailable(game);
// availableMana.addMana(opponent.getManaPool().getMana());
for (Mana mana : availableMana) {
if (mana.count() > 0) {
opponentCanPayMax = Math.max(opponentCanPayMax, mana.count());
}
}
}
}
if (opponentCanPayMax > 0) {
options.addMana(Mana.GenericMana(Math.min(unpaid.getMana().getGeneric(), opponentCanPayMax)));
}
return options;
}
Aggregations