Search in sources :

Example 1 with ManaOptions

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);
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Mana(mage.Mana) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) Permanent(mage.game.permanent.Permanent) TargetControlledPermanent(mage.target.common.TargetControlledPermanent) FilterControlledLandPermanent(mage.filter.common.FilterControlledLandPermanent) ManaType(mage.constants.ManaType)

Example 2 with ManaOptions

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;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Player(mage.players.Player) ValueHint(mage.abilities.hint.ValueHint)

Example 3 with ManaOptions

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;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) HybridManaCost(mage.abilities.costs.mana.HybridManaCost) HybridManaCost(mage.abilities.costs.mana.HybridManaCost) ManaCost(mage.abilities.costs.mana.ManaCost) Card(mage.cards.Card)

Example 4 with ManaOptions

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));
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Permanent(mage.game.permanent.Permanent) Test(org.junit.Test)

Example 5 with ManaOptions

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);
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) ManaOptionsTestUtils.assertManaOptions(org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions) ManaOptionsTestUtils.assertDuplicatedManaOptions(org.mage.test.utils.ManaOptionsTestUtils.assertDuplicatedManaOptions) Test(org.junit.Test)

Aggregations

ManaOptions (mage.abilities.mana.ManaOptions)99 Test (org.junit.Test)85 ManaOptionsTestUtils.assertManaOptions (org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions)75 ManaOptionsTestUtils.assertDuplicatedManaOptions (org.mage.test.utils.ManaOptionsTestUtils.assertDuplicatedManaOptions)38 Permanent (mage.game.permanent.Permanent)9 Mana (mage.Mana)8 Player (mage.players.Player)5 ActivatedManaAbilityImpl (mage.abilities.mana.ActivatedManaAbilityImpl)4 FilterCard (mage.filter.FilterCard)4 FilterPermanent (mage.filter.FilterPermanent)4 TargetPermanent (mage.target.TargetPermanent)4 AlternateManaPaymentAbility (mage.abilities.costs.mana.AlternateManaPaymentAbility)3 ManaCost (mage.abilities.costs.mana.ManaCost)3 ValueHint (mage.abilities.hint.ValueHint)3 FilterControlledPermanent (mage.filter.common.FilterControlledPermanent)3 UUID (java.util.UUID)2 ConditionalMana (mage.ConditionalMana)2 PassAbility (mage.abilities.common.PassAbility)2 PlayLandAsCommanderAbility (mage.abilities.common.PlayLandAsCommanderAbility)2 WhileSearchingPlayFromLibraryAbility (mage.abilities.common.WhileSearchingPlayFromLibraryAbility)2