Search in sources :

Example 81 with Mana

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;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) TargetCardInHand(mage.target.common.TargetCardInHand) Cards(mage.cards.Cards) CardsImpl(mage.cards.CardsImpl)

Example 82 with 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;
}
Also used : Player(mage.players.Player) Mana(mage.Mana) AddManaToManaPoolSourceControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolSourceControllerEffect) AddManaToManaPoolSourceControllerEffect(mage.abilities.effects.mana.AddManaToManaPoolSourceControllerEffect) OneShotEffect(mage.abilities.effects.OneShotEffect) ClashEffect(mage.abilities.effects.common.ClashEffect) Effect(mage.abilities.effects.Effect) AtTheBeginOfMainPhaseDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheBeginOfMainPhaseDelayedTriggeredAbility) Spell(mage.game.stack.Spell) TargetSpell(mage.target.TargetSpell)

Example 83 with Mana

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;
}
Also used : Mana(mage.Mana) ArrayList(java.util.ArrayList)

Example 84 with Mana

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);
}
Also used : FilterMana(mage.filter.FilterMana) Mana(mage.Mana) FilterMana(mage.filter.FilterMana) PayLifeCost(mage.abilities.costs.common.PayLifeCost)

Example 85 with Mana

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;
}
Also used : Mana(mage.Mana) ArrayList(java.util.ArrayList)

Aggregations

Mana (mage.Mana)147 Player (mage.players.Player)76 ConditionalMana (mage.ConditionalMana)33 Permanent (mage.game.permanent.Permanent)32 ArrayList (java.util.ArrayList)26 Choice (mage.choices.Choice)23 ChoiceColor (mage.choices.ChoiceColor)23 ChoiceImpl (mage.choices.ChoiceImpl)14 TappedForManaEvent (mage.game.events.TappedForManaEvent)14 Card (mage.cards.Card)13 ManaEvent (mage.game.events.ManaEvent)11 ObjectColor (mage.ObjectColor)8 ManaOptions (mage.abilities.mana.ManaOptions)8 FilterMana (mage.filter.FilterMana)8 LinkedHashSet (java.util.LinkedHashSet)7 UUID (java.util.UUID)7 FilterPermanent (mage.filter.FilterPermanent)6 MageObject (mage.MageObject)5 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)5 FilterCard (mage.filter.FilterCard)5