Package mage

Examples of mage.Mana


    public AddManaOfAnyColorEffect() {
        this(1);
    }

    public AddManaOfAnyColorEffect(final int amount) {
        super(new Mana(0,0,0,0,0,0,1));
        this.amount = amount;
        this.staticText = new StringBuilder("add ")
                .append(CardUtil.numberToText(amount))
                .append(" mana of any ")
                .append(amount > 1 ?"one ":"")
View Full Code Here


            if (controller.choose(outcome, choice, game)) {
                if (choice.getColor() == null) {
                    return false; // it happenes, don't know how
                }
                Mana createdMana = null;
                if (choice.getColor().isBlack()) {
                    createdMana = Mana.BlackMana(amount);
                } else if (choice.getColor().isBlue()) {
                    createdMana = Mana.BlueMana(amount);
                } else if (choice.getColor().isRed()) {
View Full Code Here

        return amount;
    }

    @Override
    public Mana getMana() {
        return (new Mana(0,0,0,0,0,0,amount));
    }
View Full Code Here

        }


        if (unpaid != null)  {
            ManaSymbols symbols = ManaSymbols.buildFromManaCost(unpaid);
            Mana unpaidMana = unpaid.getMana();

            if (!symbols.isEmpty()) {
                return getManaAbilitiesUsingManaSymbols(useableAbilities, symbols, unpaidMana);
            } else {
                return getManaAbilitiesUsingMana(unpaid, useableAbilities);
View Full Code Here

     * @param unpaid
     * @param useableAbilities
     * @return
     */
    private static LinkedHashMap<UUID, ManaAbility> getManaAbilitiesUsingMana(ManaCost unpaid, LinkedHashMap<UUID, ManaAbility> useableAbilities) {
        Mana mana = unpaid.getMana();

        int countColorfull = 0;
        int countColorless = 0;
        ManaAbility chosenManaAbility = null;
        for (ManaAbility ability : useableAbilities.values()) {
            if (ability instanceof RedManaAbility && mana.contains(Mana.RedMana)) {
                chosenManaAbility = ability;
                countColorfull++;
            }
            if (ability instanceof BlackManaAbility && mana.contains(Mana.BlackMana)) {
                chosenManaAbility = ability;
                countColorfull++;
            }
            if (ability instanceof BlueManaAbility && mana.contains(Mana.BlueMana)) {
                chosenManaAbility = ability;
                countColorfull++;
            }
            if (ability instanceof WhiteManaAbility && mana.contains(Mana.WhiteMana)) {
                chosenManaAbility = ability;
                countColorfull++;
            }
            if (ability instanceof GreenManaAbility && mana.contains(Mana.GreenMana)) {
                chosenManaAbility = ability;
                countColorfull++;
            }
        }

        if (countColorfull == 0) { // seems there is no colorful mana we can use
            // try to pay {1}
            if (mana.getColorless() > 0) {
                // use any (lets choose first)
                return replace(useableAbilities, useableAbilities.values().iterator().next());
            }

            // return map as-is without any modification
View Full Code Here

        boolean result = false;
        for (int i = 0; i < amount; i++) {
            ChoiceColor choice = (ChoiceColor) source.getChoices().get(i);

            Mana mana = null;
            if (choice.getColor().isBlack()) {
                mana = manaBuilder.setMana(Mana.BlackMana(1), source, game).build();
            } else if (choice.getColor().isBlue()) {
                mana = manaBuilder.setMana(Mana.BlueMana(1), source, game).build();
            } else if (choice.getColor().isRed()) {
View Full Code Here

        }
    }

    public void addMana(List<ManaAbility> abilities, Game game) {
        if (isEmpty()) {
            this.add(new Mana());
        }
        if (!abilities.isEmpty()) {
            if (abilities.size() == 1) {
                //if there is only one mana option available add it to all the existing options
                addMana(abilities.get(0).getNetMana(game));
            }
            else if (abilities.size() > 1) {
                //perform a union of all existing options and the new options
                List<Mana> copy = copy();
                this.clear();
                for (ManaAbility ability: abilities) {
                    for (Mana mana: copy) {
                        Mana newMana = new Mana();
                        newMana.add(mana);
                        newMana.add(ability.getNetMana(game));
                        this.add(newMana);
                    }
                }
            }
        }
View Full Code Here

        }
    }

    public void addManaWithCost(List<ManaAbility> abilities, Game game) {
        if (isEmpty()) {
            this.add(new Mana());
        }
        if (!abilities.isEmpty()) {
            if (abilities.size() == 1) {
                //if there is only one mana option available add it to all the existing options
                ManaAbility ability = abilities.get(0);
                if (ability.getManaCosts().isEmpty()) {
                    addMana(ability.getNetMana(game));
                }
                else {
                    addMana(ability.getManaCosts().getMana(), ability.getNetMana(game));
                }
            }
            else if (abilities.size() > 1) {
                //perform a union of all existing options and the new options
                List<Mana> copy = copy();
                this.clear();
                for (ManaAbility ability: abilities) {
                    if (ability.getManaCosts().isEmpty()) {
                        for (Mana mana: copy) {
                            Mana newMana = new Mana();
                            newMana.add(mana);
                            newMana.add(ability.getNetMana(game));
                            this.add(newMana);
                        }
                    }
                    else {
                        for (Mana mana: copy) {
                            Mana newMana = new Mana();
                            newMana.add(mana);
                            if (mana.contains(ability.getManaCosts().getMana())) {
                                newMana.subtract(ability.getManaCosts().getMana());
                                newMana.add(ability.getNetMana(game));
                            }
                            this.add(newMana);
                        }
                    }
                }
View Full Code Here

        }
    }

    public void addMana(Mana addMana) {
        if (isEmpty()) {
            this.add(new Mana());
        }
        for (Mana mana: this) {
            mana.add(addMana);
        }
    }
View Full Code Here

        }
    }

    public void addMana(ManaOptions options) {
        if (isEmpty()) {
            this.add(new Mana());
        }
        if (!options.isEmpty()) {
            if (options.size() == 1) {
                //if there is only one mana option available add it to all the existing options
                addMana(options.get(0));
            }
            else if (options.size() > 1) {
                //perform a union of all existing options and the new options
                List<Mana> copy = copy();
                this.clear();
                for (Mana addMana: options) {
                    for (Mana mana: copy) {
                        Mana newMana = new Mana();
                        newMana.add(mana);
                        newMana.add(addMana);
                        this.add(newMana);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of mage.Mana

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.