Search in sources :

Example 1 with ConditionalMana

use of mage.ConditionalMana in project mage by magefree.

the class OpenTheOmenpathsCondition method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    Mana mana = ManaChoice.chooseTwoDifferentColors(player, game);
    mana.add(mana);
    ConditionalMana conditionalMana = new ConditionalMana(mana);
    conditionalMana.addCondition(new OpenTheOmenpathsCondition());
    player.getManaPool().addMana(conditionalMana, game, source);
    return true;
}
Also used : Player(mage.players.Player) ConditionalMana(mage.ConditionalMana) Mana(mage.Mana) ConditionalMana(mage.ConditionalMana)

Example 2 with ConditionalMana

use of mage.ConditionalMana in project mage by magefree.

the class NarsetOfTheAncientWayDrawEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.gainLife(2, game, source);
    ChoiceColor choice = new ChoiceColor();
    choice.getChoices().remove("Green");
    choice.getChoices().remove("Black");
    player.choose(Outcome.PutManaInPool, choice, game);
    ConditionalMana mana = new ConditionalMana(choice.getMana(1));
    mana.addCondition(new NarsetOfTheAncientWayManaCondition());
    player.getManaPool().addMana(mana, game, source);
    return true;
}
Also used : Player(mage.players.Player) ConditionalMana(mage.ConditionalMana) ChoiceColor(mage.choices.ChoiceColor)

Example 3 with ConditionalMana

use of mage.ConditionalMana in project mage by magefree.

the class ManaTypeInManaPoolCount method calculate.

@Override
public int calculate(Game game, Ability sourceAbility, Effect effect) {
    int amount = 0;
    Player player = game.getPlayer(sourceAbility.getControllerId());
    if (player != null) {
        amount = player.getManaPool().get(manaType);
        for (ConditionalMana mana : player.getManaPool().getConditionalMana()) {
            amount += mana.get(manaType);
        }
    }
    return amount;
}
Also used : Player(mage.players.Player) ConditionalMana(mage.ConditionalMana)

Example 4 with ConditionalMana

use of mage.ConditionalMana in project mage by magefree.

the class ManaOptions method toString.

@Override
public String toString() {
    Iterator<Mana> it = this.iterator();
    if (!it.hasNext()) {
        return "[]";
    }
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    for (; ; ) {
        Mana mana = it.next();
        sb.append(mana.toString());
        if (mana instanceof ConditionalMana) {
            sb.append(((ConditionalMana) mana).getConditionString());
        }
        if (!it.hasNext()) {
            return sb.append(']').toString();
        }
        sb.append(',').append(' ');
    }
}
Also used : Mana(mage.Mana) ConditionalMana(mage.ConditionalMana) ConditionalMana(mage.ConditionalMana)

Example 5 with ConditionalMana

use of mage.ConditionalMana in project mage by magefree.

the class ManaPool method addMana.

public void addMana(Mana manaToAdd, Game game, Ability source, boolean dontLoseUntilEOT) {
    if (manaToAdd != null) {
        Mana mana = manaToAdd.copy();
        if (!game.replaceEvent(new ManaEvent(EventType.ADD_MANA, source.getId(), source, playerId, mana))) {
            if (mana instanceof ConditionalMana) {
                ConditionalMana conditionalMana = (ConditionalMana) mana;
                ManaPoolItem item = new ManaPoolItem(conditionalMana, source.getSourceObject(game), conditionalMana.getManaProducerOriginalId() != null ? conditionalMana.getManaProducerOriginalId() : source.getOriginalId());
                if (dontLoseUntilEOT) {
                    item.setDuration(Duration.EndOfTurn);
                }
                this.manaItems.add(item);
            } else {
                ManaPoolItem item = new ManaPoolItem(mana.getRed(), mana.getGreen(), mana.getBlue(), mana.getWhite(), mana.getBlack(), mana.getGeneric() + mana.getColorless(), source.getSourceObject(game), source.getOriginalId(), mana.getFlag());
                if (dontLoseUntilEOT) {
                    item.setDuration(Duration.EndOfTurn);
                }
                this.manaItems.add(item);
            }
            ManaEvent manaEvent = new ManaEvent(EventType.MANA_ADDED, source.getId(), source, playerId, mana);
            manaEvent.setData(mana.toString());
            game.fireEvent(manaEvent);
        }
    }
}
Also used : ConditionalMana(mage.ConditionalMana) Mana(mage.Mana) FilterMana(mage.filter.FilterMana) ConditionalMana(mage.ConditionalMana) ManaEvent(mage.game.events.ManaEvent)

Aggregations

ConditionalMana (mage.ConditionalMana)14 Mana (mage.Mana)9 Player (mage.players.Player)6 ChoiceColor (mage.choices.ChoiceColor)2 ArrayList (java.util.ArrayList)1 ApprovingObject (mage.ApprovingObject)1 MageObject (mage.MageObject)1 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)1 ManaOptions (mage.abilities.mana.ManaOptions)1 ManaType (mage.constants.ManaType)1 FilterMana (mage.filter.FilterMana)1 GameEvent (mage.game.events.GameEvent)1 ManaEvent (mage.game.events.ManaEvent)1 ManaPaidEvent (mage.game.events.ManaPaidEvent)1 ManaPool (mage.players.ManaPool)1 ManaPoolItem (mage.players.ManaPoolItem)1