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());
}
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);
}
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;
}
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;
}
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;
}
Aggregations