use of mage.abilities.mana.ManaOptions in project mage by magefree.
the class SquanderedResourcesEffect method getNetMana.
@Override
public List<Mana> getNetMana(Game game, Ability source) {
if (game != null && game.inCheckPlayableState()) {
// add color combinations of available mana
ManaOptions allPossibleMana = new ManaOptions();
for (Permanent land : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_LAND, source.getControllerId(), game)) {
ManaOptions currentPossibleMana = new ManaOptions();
Set<ManaType> manaTypes = AnyColorLandsProduceManaAbility.getManaTypesFromPermanent(land, game);
if (manaTypes.size() == 5 && !manaTypes.contains(ManaType.COLORLESS) || manaTypes.size() == 6) {
currentPossibleMana.add(Mana.AnyMana(1));
if (manaTypes.contains(ManaType.COLORLESS)) {
currentPossibleMana.add(new Mana(ManaType.COLORLESS));
}
} else {
for (ManaType manaType : manaTypes) {
currentPossibleMana.add(new Mana(manaType));
}
}
allPossibleMana.addMana(currentPossibleMana);
}
allPossibleMana.removeDuplicated();
return allPossibleMana.stream().collect(Collectors.toList());
}
return ManaType.getManaListFromManaTypes(getManaTypesFromSacrificedPermanent(game, source), false);
}
use of mage.abilities.mana.ManaOptions in project mage by magefree.
the class ImproviseEffect method getManaOptions.
@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
ManaOptions options = new ManaOptions();
Player controller = game.getPlayer(source.getControllerId());
int canPayCount = untappedCount.calculate(game, source, null);
if (controller != null && canPayCount > 0) {
options.addMana(Mana.GenericMana(Math.min(unpaid.getMana().getGeneric(), canPayCount)));
}
return options;
}
use of mage.abilities.mana.ManaOptions in project mage by magefree.
the class OfferingCostReductionEffect method getManaOptions.
@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
ManaOptions additionalManaOptionsForThisAbility = new ManaOptions();
// Creatures from the offerd type
game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game).stream().map(Card::getSpellAbility).filter(Objects::nonNull).forEach(spellAbility -> {
ManaOptions manaOptionsForThisPermanent = new ManaOptions();
for (ManaCost manaCost : spellAbility.getManaCosts()) {
if (manaCost instanceof HybridManaCost) {
ManaOptions manaOptionsForHybrid = new ManaOptions();
manaOptionsForHybrid.addAll(manaCost.getManaOptions());
manaOptionsForThisPermanent.addMana(manaOptionsForHybrid);
} else {
manaOptionsForThisPermanent.addMana(manaCost.getMana());
}
}
additionalManaOptionsForThisAbility.addAll(manaOptionsForThisPermanent);
});
additionalManaOptionsForThisAbility.removeDuplicated();
return additionalManaOptionsForThisAbility;
}
use of mage.abilities.mana.ManaOptions in project mage by magefree.
the class BestowTest method testEnchantedChangedWithSongOfTheDryads.
/**
* When a creature with Nighthowler attatched gets enchanted with Song of
* the Dryads, Nightholwer doesn't become a creature and gets turned into a
* card without stats.
*/
@Test
public void testEnchantedChangedWithSongOfTheDryads() {
// Enchantment Creature — Horror
// 0/0
// Bestow {2}{B}{B}
// Nighthowler and enchanted creature each get +X/+X, where X is the number of creature cards in all graveyards.
addCard(Zone.HAND, playerA, "Nighthowler");
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 4);
// {1}{W} 2/2 creature
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion");
addCard(Zone.GRAVEYARD, playerA, "Pillarfield Ox");
addCard(Zone.GRAVEYARD, playerB, "Pillarfield Ox");
// Enchant permanent
// Enchanted permanent is a colorless Forest land.
addCard(Zone.BATTLEFIELD, playerB, "Forest", 3);
// Enchantment Aura {2}{G}
addCard(Zone.HAND, playerB, "Song of the Dryads");
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Nighthowler using bestow", "Silvercoat Lion");
castSpell(2, PhaseStep.PRECOMBAT_MAIN, playerB, "Song of the Dryads", "Silvercoat Lion");
setStrictChooseMode(true);
setStopAt(2, PhaseStep.BEGIN_COMBAT);
execute();
assertAllCommandsUsed();
assertPermanentCount(playerB, "Song of the Dryads", 1);
ManaOptions options = playerA.getAvailableManaTest(currentGame);
Assert.assertEquals("Player should be able to create 1 green mana", "{G}", options.get(0).toString());
assertPermanentCount(playerA, "Nighthowler", 1);
assertPowerToughness(playerA, "Nighthowler", 2, 2);
assertType("Nighthowler", CardType.CREATURE, true);
assertType("Nighthowler", CardType.ENCHANTMENT, true);
Permanent nighthowler = getPermanent("Nighthowler");
Assert.assertFalse("The unattached Nighthowler may not have the aura subtype.", nighthowler.hasSubtype(SubType.AURA, currentGame));
}
use of mage.abilities.mana.ManaOptions in project mage by magefree.
the class ManaOptionsTest method testNykthos1.
// Nykthos, Shrine to Nyx
// {T}: Add {C}.
// {2}, {T}: Choose a color. Add an amount of mana of that color equal to your devotion to that color. (Your devotion to a color is the number of mana symbols of that color in the mana costs of permanents you control.)
@Test
public void testNykthos1() {
// Creature {G} (1/1)
addCard(Zone.BATTLEFIELD, playerA, "Sedge Scorpion", 4);
addCard(Zone.BATTLEFIELD, playerA, "Forest", 3);
// Creature {1}{W}
addCard(Zone.BATTLEFIELD, playerA, "Silvercoat Lion", 4);
// Land
addCard(Zone.BATTLEFIELD, playerA, "Nykthos, Shrine to Nyx", 1);
setStopAt(1, PhaseStep.UPKEEP);
execute();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 3, manaOptions.size());
assertManaOptions("{C}{G}{G}{G}", manaOptions);
assertManaOptions("{G}{G}{G}{G}{G}", manaOptions);
assertManaOptions("{G}{W}{W}{W}{W}", manaOptions);
}
Aggregations