Search in sources :

Example 16 with ColoredManaSymbol

use of mage.constants.ColoredManaSymbol in project mage by magefree.

the class ManaTest method shouldCreateManaFromBlueColoredManaSymbol.

@Test
public void shouldCreateManaFromBlueColoredManaSymbol() {
    // given
    ColoredManaSymbol symbol = ColoredManaSymbol.U;
    // when
    Mana mana = new Mana(symbol);
    // then
    assertEquals(0, mana.getGreen());
    assertEquals(0, mana.getRed());
    assertEquals(0, mana.getBlack());
    assertEquals(1, mana.getBlue());
    assertEquals(0, mana.getWhite());
}
Also used : FilterMana(mage.filter.FilterMana) ColoredManaSymbol(mage.constants.ColoredManaSymbol) Test(org.junit.Test)

Example 17 with ColoredManaSymbol

use of mage.constants.ColoredManaSymbol in project mage by magefree.

the class ManaTest method shouldNotCreateManaFromNullColoredManaSymbol.

@Test
public void shouldNotCreateManaFromNullColoredManaSymbol() {
    // given
    ColoredManaSymbol nullSymbol = null;
    expectedException.expect(NullPointerException.class);
    expectedException.expectMessage("The passed in ColoredManaSymbol can not be null");
    // when
    new Mana(nullSymbol);
}
Also used : FilterMana(mage.filter.FilterMana) ColoredManaSymbol(mage.constants.ColoredManaSymbol) Test(org.junit.Test)

Example 18 with ColoredManaSymbol

use of mage.constants.ColoredManaSymbol in project mage by magefree.

the class AddManaInAnyCombinationEffect method getNetMana.

@Override
public List<Mana> getNetMana(Game game, Ability source) {
    List<Mana> netMana = new ArrayList<>();
    if (game != null) {
        if (game.inCheckPlayableState()) {
            int count = netAmount.calculate(game, source, this);
            if (count > 0) {
                // add color combinations
                ManaOptions allPossibleMana = new ManaOptions();
                for (int i = 0; i < count; ++i) {
                    ManaOptions currentPossibleMana = new ManaOptions();
                    for (ColoredManaSymbol coloredManaSymbol : manaSymbols) {
                        currentPossibleMana.add(new Mana(coloredManaSymbol));
                    }
                    allPossibleMana.addMana(currentPossibleMana);
                }
                allPossibleMana.removeDuplicated();
                return allPossibleMana.stream().collect(Collectors.toList());
            }
        } else {
            int amountOfManaLeft = amount.calculate(game, source, this);
            if (amountOfManaLeft > 0) {
                netMana.add(Mana.AnyMana(amountOfManaLeft));
            }
        }
    }
    return netMana;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Mana(mage.Mana) ColoredManaSymbol(mage.constants.ColoredManaSymbol)

Example 19 with ColoredManaSymbol

use of mage.constants.ColoredManaSymbol in project mage by magefree.

the class DeckGeneratorPool method landProducesChosenColors.

/**
 * Returns if this land will produce the chosen colors for this pool.
 * @param card a non-basic land card.
 * @return if this land card taps to produces the colors chosen.
 */
private boolean landProducesChosenColors(Card card) {
    // All mock card abilities will be MockAbilities so we can't differentiate between ManaAbilities
    // and other Abilities so we have to do some basic string matching on land cards for now.
    List<Ability> landAbilities = card.getAbilities();
    int count = 0;
    for (Ability ability : landAbilities) {
        String abilityString = ability.getRule();
        // Lands that tap to produce mana of the chosen colors
        for (ColoredManaSymbol symbol : allowedColors) {
            if (landTapsForAllowedColor(abilityString, symbol.toString())) {
                count++;
            }
        }
        if (count > 1) {
            return true;
        }
    }
    return false;
}
Also used : Ability(mage.abilities.Ability) ColoredManaSymbol(mage.constants.ColoredManaSymbol)

Example 20 with ColoredManaSymbol

use of mage.constants.ColoredManaSymbol in project mage by magefree.

the class DeckGeneratorPool method countManaProduced.

/**
 * Calculates how many of each mana the non-basic lands produce.
 * @param deckLands the non-basic lands which will be used in the deck.
 * @return a mapping of colored mana symbol to the amount that can be produced.
 */
public Map<String, Integer> countManaProduced(List<Card> deckLands) {
    Map<String, Integer> manaCounts = new HashMap<>();
    for (final ColoredManaSymbol color : ColoredManaSymbol.values()) {
        manaCounts.put(color.toString(), 0);
    }
    for (Card land : deckLands) {
        for (Ability landAbility : land.getAbilities()) {
            for (ColoredManaSymbol symbol : allowedColors) {
                String abilityString = landAbility.getRule();
                if (landTapsForAllowedColor(abilityString, symbol.toString())) {
                    Integer count = manaCounts.get(symbol.toString());
                    manaCounts.put(symbol.toString(), count + 1);
                }
            }
        }
    }
    return manaCounts;
}
Also used : Ability(mage.abilities.Ability) ColoredManaSymbol(mage.constants.ColoredManaSymbol) Card(mage.cards.Card)

Aggregations

ColoredManaSymbol (mage.constants.ColoredManaSymbol)20 FilterMana (mage.filter.FilterMana)7 Test (org.junit.Test)7 Mana (mage.Mana)4 Card (mage.cards.Card)4 Ability (mage.abilities.Ability)2 CardCriteria (mage.cards.repository.CardCriteria)2 CardInfo (mage.cards.repository.CardInfo)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 ManaOptions (mage.abilities.mana.ManaOptions)1 CardSetInfo (mage.cards.CardSetInfo)1 Island (mage.cards.basiclands.Island)1 RateCallback (mage.interfaces.rate.RateCallback)1 Player (mage.players.Player)1