Search in sources :

Example 51 with Mana

use of mage.Mana in project mage by magefree.

the class TheBloodskyMassacreEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    int berserkers = game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game);
    player.getManaPool().addMana(new Mana(ManaType.RED, berserkers), game, source, true);
    return true;
}
Also used : Player(mage.players.Player) Mana(mage.Mana)

Example 52 with Mana

use of mage.Mana in project mage by magefree.

the class BirgiGodOfStorytellingManaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player player = game.getPlayer(source.getControllerId());
    if (player == null) {
        return false;
    }
    player.getManaPool().addMana(new Mana(ManaType.RED, 1), game, source, true);
    return true;
}
Also used : Player(mage.players.Player) Mana(mage.Mana)

Example 53 with Mana

use of mage.Mana in project mage by magefree.

the class CadaverousBloomManaEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    if (game != null && game.inCheckPlayableState()) {
        List<Mana> netMana = new ArrayList<>();
        Player player = game.getPlayer(source.getControllerId());
        if (player != null) {
            int count = player.getHand().size();
            if (count > 0) {
                Mana mana = new Mana(getManaTemplate().getWhite() * count, getManaTemplate().getBlue() * count, getManaTemplate().getBlack() * count, getManaTemplate().getRed() * count, getManaTemplate().getGreen() * count, getManaTemplate().getGeneric() * count, getManaTemplate().getAny() * count, getManaTemplate().getColorless() * count);
                netMana.add(mana);
            }
        }
        return netMana;
    }
    return super.getNetMana(game, source);
}
Also used : Player(mage.players.Player) Mana(mage.Mana) ArrayList(java.util.ArrayList)

Example 54 with Mana

use of mage.Mana in project mage by magefree.

the class DeepWaterReplacementEffect method replaceEvent.

@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
    ManaEvent manaEvent = (ManaEvent) event;
    Mana mana = manaEvent.getMana();
    mana.setToMana(Mana.BlueMana(mana.count()));
    return false;
}
Also used : Mana(mage.Mana) ManaEvent(mage.game.events.ManaEvent) TappedForManaEvent(mage.game.events.TappedForManaEvent)

Example 55 with Mana

use of mage.Mana in project mage by magefree.

the class GrandWarlordRadhaEffect method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        CreaturesAttackedWatcher watcher = game.getState().getWatcher(CreaturesAttackedWatcher.class);
        if (watcher != null) {
            int attackingCreatures = 0;
            for (MageObjectReference attacker : watcher.getAttackedThisTurnCreatures()) {
                if (attacker.getPermanentOrLKIBattlefield(game).isControlledBy(controller.getId())) {
                    attackingCreatures++;
                }
            }
            if (attackingCreatures > 0) {
                Choice manaChoice = new ChoiceImpl();
                Set<String> choices = new LinkedHashSet<>();
                choices.add("Red");
                choices.add("Green");
                manaChoice.setChoices(choices);
                manaChoice.setMessage("Select color of mana to add");
                for (int i = 0; i < attackingCreatures; i++) {
                    Mana mana = new Mana();
                    if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
                        return false;
                    }
                    if (manaChoice.getChoice() == null) {
                        // can happen if player leaves game
                        return false;
                    }
                    switch(manaChoice.getChoice()) {
                        case "Green":
                            mana.increaseGreen();
                            break;
                        case "Red":
                            mana.increaseRed();
                            break;
                    }
                    controller.getManaPool().addMana(mana, game, source, true);
                }
                return true;
            }
            return true;
        }
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Choice(mage.choices.Choice) Mana(mage.Mana) ChoiceImpl(mage.choices.ChoiceImpl) MageObjectReference(mage.MageObjectReference)

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