Search in sources :

Example 26 with Mana

use of mage.Mana in project mage by magefree.

the class SarkhanUnbrokenAbility1 method apply.

@Override
public boolean apply(Game game, Ability source) {
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null) {
        controller.drawCards(1, source, game);
        game.fireUpdatePlayersEvent();
        Choice manaChoice = new ChoiceImpl();
        Set<String> choices = new LinkedHashSet<>();
        choices.add("White");
        choices.add("Blue");
        choices.add("Black");
        choices.add("Red");
        choices.add("Green");
        manaChoice.setChoices(choices);
        manaChoice.setMessage("Select color of mana to add");
        Mana mana = new Mana();
        if (!controller.choose(Outcome.Benefit, manaChoice, game)) {
            return false;
        }
        switch(manaChoice.getChoice()) {
            case "White":
                mana.increaseWhite();
                break;
            case "Blue":
                mana.increaseBlue();
                break;
            case "Black":
                mana.increaseBlack();
                break;
            case "Red":
                mana.increaseRed();
                break;
            case "Green":
                mana.increaseGreen();
                break;
        }
        controller.getManaPool().addMana(mana, game, source);
        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)

Example 27 with Mana

use of mage.Mana in project mage by magefree.

the class SasayasEssenceManaEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    List<Mana> netMana = new ArrayList<>();
    Player controller = game.getPlayer(source.getControllerId());
    Mana producedMana = (Mana) this.getValue("mana");
    Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
    if (controller != null && producedMana != null && permanent != null) {
        FilterPermanent filter = new FilterLandPermanent();
        filter.add(Predicates.not(new PermanentIdPredicate(permanent.getId())));
        filter.add(new NamePredicate(permanent.getName()));
        int count = game.getBattlefield().countAll(filter, controller.getId(), game);
        if (count > 0) {
            if (producedMana.getBlack() > 0) {
                netMana.add(Mana.BlackMana(count));
            }
            if (producedMana.getRed() > 0) {
                netMana.add(Mana.RedMana(count));
            }
            if (producedMana.getBlue() > 0) {
                netMana.add(Mana.BlueMana(count));
            }
            if (producedMana.getGreen() > 0) {
                netMana.add(Mana.GreenMana(count));
            }
            if (producedMana.getWhite() > 0) {
                netMana.add(Mana.WhiteMana(count));
            }
            if (producedMana.getColorless() > 0) {
                netMana.add(Mana.ColorlessMana(count));
            }
        }
    }
    return netMana;
}
Also used : PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) Player(mage.players.Player) NamePredicate(mage.filter.predicate.mageobject.NamePredicate) Mana(mage.Mana) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) FilterPermanent(mage.filter.FilterPermanent) FilterLandPermanent(mage.filter.common.FilterLandPermanent) Permanent(mage.game.permanent.Permanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ArrayList(java.util.ArrayList)

Example 28 with Mana

use of mage.Mana in project mage by magefree.

the class UrzaAcademyHeadmasterBrainstormEffect 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);
        Choice manaChoice = new ChoiceImpl();
        Set<String> choices = new LinkedHashSet<>();
        choices.add("White");
        choices.add("Blue");
        choices.add("Black");
        choices.add("Red");
        choices.add("Green");
        manaChoice.setChoices(choices);
        manaChoice.setMessage("Select color of mana to add");
        for (int i = 0; i < x; i++) {
            Mana mana = new Mana();
            if (!player.choose(Outcome.Benefit, manaChoice, game)) {
                return false;
            }
            if (manaChoice.getChoice() == null) {
                // can happen if player leaves game
                return false;
            }
            switch(manaChoice.getChoice()) {
                case "White":
                    mana.increaseWhite();
                    break;
                case "Blue":
                    mana.increaseBlue();
                    break;
                case "Black":
                    mana.increaseBlack();
                    break;
                case "Red":
                    mana.increaseRed();
                    break;
                case "Green":
                    mana.increaseGreen();
                    break;
            }
            player.getManaPool().addMana(mana, game, source);
        }
        return true;
    }
    return false;
}
Also used : Player(mage.players.Player) TargetPlayer(mage.target.TargetPlayer) Choice(mage.choices.Choice) Mana(mage.Mana) ChoiceImpl(mage.choices.ChoiceImpl)

Example 29 with Mana

use of mage.Mana in project mage by magefree.

the class AddConditionalManaEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    if (game != null && game.inCheckPlayableState() && netAmount != null) {
        List<Mana> maxAvailableMana = new ArrayList<>();
        int amountAvailableMana = netAmount.calculate(game, source, this);
        if (amountAvailableMana > 0) {
            Mana calculatedMana = mana.copy();
            for (ManaType manaType : ManaType.getTrueManaTypes()) {
                calculatedMana.set(manaType, CardUtil.overflowMultiply(calculatedMana.get(manaType), amountAvailableMana));
            }
            maxAvailableMana.add(manaBuilder.setMana(calculatedMana, source, game).build());
        }
        return maxAvailableMana;
    }
    // To change body of generated methods, choose Tools | Templates.
    return super.getNetMana(game, source);
}
Also used : Mana(mage.Mana) ArrayList(java.util.ArrayList) ManaType(mage.constants.ManaType)

Example 30 with Mana

use of mage.Mana in project mage by magefree.

the class AddManaAnyColorAttachedControllerEffect method produceMana.

@Override
public Mana produceMana(Game game, Ability source) {
    if (game != null) {
        Permanent enchantment = game.getPermanent(source.getSourceId());
        if (enchantment != null) {
            Permanent land = game.getPermanent(enchantment.getAttachedTo());
            if (land != null) {
                Player player = game.getPlayer(land.getControllerId());
                ChoiceColor choice = new ChoiceColor();
                if (player != null && player.choose(outcome, choice, game)) {
                    return choice.getMana(1);
                }
            }
        }
    }
    return new Mana();
}
Also used : Player(mage.players.Player) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) ChoiceColor(mage.choices.ChoiceColor)

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