Search in sources :

Example 86 with Mana

use of mage.Mana in project mage by magefree.

the class EmergeAbility method getMinimumCostToActivate.

@Override
public ManaOptions getMinimumCostToActivate(UUID playerId, Game game) {
    int maxCMC = 0;
    for (Permanent creature : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), playerId, this.getSourceId(), game)) {
        int cmc = creature.getManaValue();
        if (cmc > maxCMC) {
            maxCMC = cmc;
        }
    }
    ManaOptions manaOptions = super.getMinimumCostToActivate(playerId, game);
    for (Mana mana : manaOptions) {
        if (mana.getGeneric() > maxCMC) {
            mana.setGeneric(mana.getGeneric() - maxCMC);
        } else {
            mana.setGeneric(0);
        }
    }
    return manaOptions;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Mana(mage.Mana) Permanent(mage.game.permanent.Permanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) TargetPermanent(mage.target.TargetPermanent) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent)

Example 87 with Mana

use of mage.Mana in project mage by magefree.

the class ConvokeEffect method getManaOptions.

@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
    ManaOptions options = new ManaOptions();
    FilterControlledCreaturePermanent filterBasic = new FilterControlledCreaturePermanent();
    // each creature can give {1} or color mana
    game.getBattlefield().getActivePermanents(filterBasic, source.getControllerId(), source.getSourceId(), game).stream().filter(permanent -> !permanent.isTapped()).forEach(permanent -> {
        ManaOptions permMana = new ManaOptions();
        permMana.add(Mana.GenericMana(1));
        for (ObjectColor color : permanent.getColor(game).getColors()) {
            if (color.isBlack())
                permMana.add(Mana.BlackMana(1));
            if (color.isBlue())
                permMana.add(Mana.BlueMana(1));
            if (color.isGreen())
                permMana.add(Mana.GreenMana(1));
            if (color.isRed())
                permMana.add(Mana.RedMana(1));
            if (color.isWhite())
                permMana.add(Mana.WhiteMana(1));
        }
        options.addMana(permMana);
    });
    options.removeDuplicated();
    return options;
}
Also used : Target(mage.target.Target) SimpleStaticAbility(mage.abilities.common.SimpleStaticAbility) Zone(mage.constants.Zone) SpecialAction(mage.abilities.SpecialAction) TappedPredicate(mage.filter.predicate.permanent.TappedPredicate) Predicates(mage.filter.predicate.Predicates) Player(mage.players.Player) ArrayList(java.util.ArrayList) ManaOptions(mage.abilities.mana.ManaOptions) ValueHint(mage.abilities.hint.ValueHint) AbilityType(mage.constants.AbilityType) ManaPool(mage.players.ManaPool) ManaCost(mage.abilities.costs.mana.ManaCost) Locale(java.util.Locale) ManaType(mage.constants.ManaType) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ColorPredicate(mage.filter.predicate.mageobject.ColorPredicate) Spell(mage.game.stack.Spell) ObjectColor(mage.ObjectColor) ChoiceColor(mage.choices.ChoiceColor) Choice(mage.choices.Choice) ActivationManaAbilityStep(mage.abilities.costs.mana.ActivationManaAbilityStep) AlternateManaPaymentAbility(mage.abilities.costs.mana.AlternateManaPaymentAbility) Outcome(mage.constants.Outcome) OneShotEffect(mage.abilities.effects.OneShotEffect) UUID(java.util.UUID) Game(mage.game.Game) List(java.util.List) GameEvent(mage.game.events.GameEvent) Permanent(mage.game.permanent.Permanent) PermanentsOnBattlefieldCount(mage.abilities.dynamicvalue.common.PermanentsOnBattlefieldCount) TargetControlledCreaturePermanent(mage.target.common.TargetControlledCreaturePermanent) Mana(mage.Mana) Ability(mage.abilities.Ability) ManaOptions(mage.abilities.mana.ManaOptions) FilterControlledCreaturePermanent(mage.filter.common.FilterControlledCreaturePermanent) ObjectColor(mage.ObjectColor)

Example 88 with Mana

use of mage.Mana in project mage by magefree.

the class ManaChoice method chooseTwoDifferentColors.

public static Mana chooseTwoDifferentColors(Player player, Game game) {
    Mana mana = new Mana();
    if (game == null || player == null) {
        return mana;
    }
    ChoiceColor color1 = new ChoiceColor(true, "Choose color 1");
    if (!player.choose(Outcome.PutManaInPool, color1, game) || color1.getColor() == null) {
        return mana;
    }
    ChoiceColor color2 = new ChoiceColor(true, "Choose color 2");
    color2.removeColorFromChoices(color1.getChoice());
    if (!player.choose(Outcome.PutManaInPool, color2, game) || color2.getColor() == null) {
        return mana;
    }
    if (color1.getColor().equals(color2.getColor())) {
        game.informPlayers("Player " + player.getName() + " is cheating with mana choices.");
        return mana;
    }
    mana.add(color1.getMana(1));
    mana.add(color2.getMana(1));
    return mana;
}
Also used : Mana(mage.Mana)

Example 89 with Mana

use of mage.Mana in project mage by magefree.

the class FluctuatorEffect method apply.

@Override
public boolean apply(Game game, Ability source, Ability abilityToModify) {
    Player controller = game.getPlayer(abilityToModify.getControllerId());
    if (controller != null) {
        Mana mana = abilityToModify.getManaCostsToPay().getMana();
        int reduceMax = mana.getGeneric();
        if (reduceMax > 2) {
            reduceMax = 2;
        }
        if (reduceMax > 0) {
            int reduce;
            if (game.inCheckPlayableState() || controller.isComputer()) {
                reduce = reduceMax;
            } else {
                ChoiceImpl choice = new ChoiceImpl(true);
                Set<String> set = new LinkedHashSet<>();
                for (int i = 0; i <= reduceMax; i++) {
                    set.add(String.valueOf(i));
                }
                choice.setChoices(set);
                choice.setMessage("Reduce cycling cost");
                if (controller.choose(Outcome.Benefit, choice, game)) {
                    reduce = Integer.parseInt(choice.getChoice());
                } else {
                    return false;
                }
            }
            CardUtil.reduceCost(abilityToModify, reduce);
        }
        return true;
    }
    return false;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) Player(mage.players.Player) Mana(mage.Mana) ChoiceImpl(mage.choices.ChoiceImpl)

Example 90 with Mana

use of mage.Mana in project mage by magefree.

the class GauntletOfPowerManaEffect2 method checkTrigger.

@Override
public boolean checkTrigger(GameEvent event, Game game) {
    TappedForManaEvent mEvent = (TappedForManaEvent) event;
    Permanent permanent = mEvent.getPermanent();
    if (permanent == null || !permanent.isLand() || !permanent.isBasic()) {
        return false;
    }
    ObjectColor color = (ObjectColor) game.getState().getValue(getSourceId() + "_color");
    if (color == null) {
        return false;
    }
    Mana mana = mEvent.getMana();
    if ((!color.isBlack() || mana.getBlack() < 1) && (!color.isBlue() || mana.getBlue() < 1) && (!color.isGreen() || mana.getGreen() < 1) && (!color.isWhite() || mana.getWhite() < 1) && (!color.isRed() || mana.getRed() < 1)) {
        return false;
    }
    getEffects().setValue("mana", mEvent.getMana());
    getEffects().setTargetPointer(new FixedTarget(permanent, game));
    return true;
}
Also used : FixedTarget(mage.target.targetpointer.FixedTarget) Mana(mage.Mana) FilterCreaturePermanent(mage.filter.common.FilterCreaturePermanent) Permanent(mage.game.permanent.Permanent) ObjectColor(mage.ObjectColor) TappedForManaEvent(mage.game.events.TappedForManaEvent)

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