use of mage.Mana in project mage by magefree.
the class MetalworkerManaEffect method produceMana.
@Override
public Mana produceMana(Game game, Ability source) {
Mana mana = new Mana();
if (game == null) {
return mana;
}
Player controller = getPlayer(game, source);
if (controller == null) {
return mana;
}
int artifacts = controller.getHand().count(StaticFilters.FILTER_CARD_ARTIFACT, game);
if (artifacts > 0) {
TargetCardInHand target = new TargetCardInHand(0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_ARTIFACT);
if (controller.choose(Outcome.Benefit, target, source.getSourceId(), game)) {
Cards cards = new CardsImpl(target.getTargets());
controller.revealCards(source, cards, game);
return Mana.ColorlessMana(target.getTargets().size() * 2);
}
}
return mana;
}
use of mage.Mana in project mage by magefree.
the class ScatteringStrokeEffect method apply.
@Override
public boolean apply(Game game, Ability source) {
Spell spell = (Spell) game.getStack().getStackObject(getTargetPointer().getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId());
if (controller != null && spell != null) {
game.getStack().counter(spell.getId(), source, game);
if (ClashEffect.getInstance().apply(game, source)) {
Effect effect = new AddManaToManaPoolSourceControllerEffect(new Mana(0, 0, 0, 0, 0, 0, 0, spell.getManaValue()));
AtTheBeginOfMainPhaseDelayedTriggeredAbility delayedAbility = new AtTheBeginOfMainPhaseDelayedTriggeredAbility(effect, true, TargetController.YOU, AtTheBeginOfMainPhaseDelayedTriggeredAbility.PhaseSelection.NEXT_MAIN);
game.addDelayedTriggeredAbility(delayedAbility, source);
}
return true;
}
return false;
}
use of mage.Mana in project mage by magefree.
the class HybridManaCost method getManaOptions.
@Override
public List<Mana> getManaOptions() {
List<Mana> manaList = new ArrayList<>();
manaList.add(new Mana(mana1));
manaList.add(new Mana(mana2));
return manaList;
}
use of mage.Mana in project mage by magefree.
the class ManaCostsImpl method handleLikePhyrexianManaCosts.
private void handleLikePhyrexianManaCosts(Player player, Ability source, Game game) {
if (this.isEmpty()) {
// nothing to be done without any mana costs. prevents NRE from occurring here
return;
}
FilterMana phyrexianColors = player.getPhyrexianColors();
if (player.getPhyrexianColors() == null) {
return;
}
Costs<PayLifeCost> tempCosts = new CostsImpl<>();
Iterator<T> manaCostIterator = this.iterator();
while (manaCostIterator.hasNext()) {
ManaCost manaCost = manaCostIterator.next();
Mana mana = manaCost.getMana();
/* find which color mana is in the cost and set it in the temp Phyrexian cost */
if ((!phyrexianColors.isWhite() || mana.getWhite() <= 0) && (!phyrexianColors.isBlue() || mana.getBlue() <= 0) && (!phyrexianColors.isBlack() || mana.getBlack() <= 0) && (!phyrexianColors.isRed() || mana.getRed() <= 0) && (!phyrexianColors.isGreen() || mana.getGreen() <= 0)) {
continue;
}
PayLifeCost payLifeCost = new PayLifeCost(2);
if (payLifeCost.canPay(source, source, player.getId(), game) && player.chooseUse(Outcome.LoseLife, "Pay 2 life (using an active ability) instead of " + manaCost.getMana() + '?', source, game)) {
manaCostIterator.remove();
tempCosts.add(payLifeCost);
}
}
tempCosts.pay(source, game, source, player.getId(), false, null);
}
use of mage.Mana in project mage by magefree.
the class MonoHybridManaCost method getManaOptions.
@Override
public List<Mana> getManaOptions() {
List<Mana> manaList = new ArrayList<>();
manaList.add(new Mana(manaColor));
manaList.add(Mana.GenericMana(manaGeneric));
return manaList;
}
Aggregations