Search in sources :

Example 21 with ManaOptions

use of mage.abilities.mana.ManaOptions in project mage by magefree.

the class AssistEffect method getManaOptions.

@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
    ManaOptions options = new ManaOptions();
    if (unpaid.getMana().getGeneric() == 0) {
        // nothing to pay
        return options;
    }
    // AI can't use assist (can't ask another player to help), maybe in teammode it can be enabled, but tests must works all the time
    // Outcome.AIDontUseIt
    Player controller = game.getPlayer(source.getControllerId());
    if (controller != null && controller.isComputer()) {
        return options;
    }
    // search opponents who can help with generic pay
    int opponentCanPayMax = 0;
    for (UUID opponentId : game.getOpponents(source.getControllerId())) {
        Player opponent = game.getPlayer(opponentId);
        if (opponent != null) {
            // basic and pool, but no coditional mana
            ManaOptions availableMana = opponent.getManaAvailable(game);
            // availableMana.addMana(opponent.getManaPool().getMana());
            for (Mana mana : availableMana) {
                if (mana.count() > 0) {
                    opponentCanPayMax = Math.max(opponentCanPayMax, mana.count());
                }
            }
        }
    }
    if (opponentCanPayMax > 0) {
        options.addMana(Mana.GenericMana(Math.min(unpaid.getMana().getGeneric(), opponentCanPayMax)));
    }
    return options;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) TargetPlayer(mage.target.TargetPlayer) Player(mage.players.Player) FilterPlayer(mage.filter.FilterPlayer) Mana(mage.Mana) UUID(java.util.UUID)

Example 22 with ManaOptions

use of mage.abilities.mana.ManaOptions in project mage by magefree.

the class DelveEffect method getManaOptions.

@Override
public ManaOptions getManaOptions(Ability source, Game game, ManaCost unpaid) {
    ManaOptions options = new ManaOptions();
    Player controller = game.getPlayer(source.getControllerId());
    int graveCount = cardsInGraveyard.calculate(game, source, null);
    if (controller != null && graveCount > 0) {
        options.addMana(Mana.GenericMana(Math.min(unpaid.getMana().getGeneric(), graveCount)));
    }
    return options;
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) Player(mage.players.Player) ValueHint(mage.abilities.hint.ValueHint)

Example 23 with ManaOptions

use of mage.abilities.mana.ManaOptions in project mage by magefree.

the class HarvesterDruidTest method testOneInstance.

@Test
public void testOneInstance() {
    addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // {T}: Add one mana of any color that a land you control could produce.
    addCard(Zone.BATTLEFIELD, playerA, "Harvester Druid", 1);
    setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
    execute();
    ManaOptions options = playerA.getAvailableManaTest(currentGame);
    assertDuplicatedManaOptions(options);
    Assert.assertEquals(2, options.size());
    assertManaOptions("{U}{R}{R}", options);
    assertManaOptions("{U}{U}{R}", options);
}
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)

Example 24 with ManaOptions

use of mage.abilities.mana.ManaOptions in project mage by magefree.

the class HarvesterDruidTest method testTwoInstances.

@Test
public void testTwoInstances() {
    addCard(Zone.BATTLEFIELD, playerA, "Island", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    // {T}: Add one mana of any color that a land you control could produce.
    addCard(Zone.BATTLEFIELD, playerA, "Harvester Druid", 2);
    setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
    execute();
    ManaOptions options = playerA.getAvailableManaTest(currentGame);
    assertDuplicatedManaOptions(options);
    Assert.assertEquals(3, options.size());
    assertManaOptions("{U}{R}{R}{R}", options);
    assertManaOptions("{U}{U}{R}{R}", options);
    assertManaOptions("{U}{U}{U}{R}", options);
}
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)

Example 25 with ManaOptions

use of mage.abilities.mana.ManaOptions in project mage by magefree.

the class NonTappingManaAbilitiesTest method TestCoalGolemAndDromarsAttendantOrder2.

/**
 * The order the mana abilities are checked during available mana
 * calculation does matter. Because Coal Golem can not be used as long as
 * Dromar's Attendant is not used yet to produce the 3 mana.
 */
@Test
public void TestCoalGolemAndDromarsAttendantOrder2() {
    setStrictChooseMode(true);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
    // {3}, Sacrifice Coal Golem: Add {R}{R}{R}.
    addCard(Zone.BATTLEFIELD, playerA, "Coal Golem", 1);
    // {1}, Sacrifice Dromar's Attendant: Add {W}{U}{B}.
    addCard(Zone.BATTLEFIELD, playerA, "Dromar's Attendant", 1);
    setStopAt(1, PhaseStep.BEGIN_COMBAT);
    execute();
    assertAllCommandsUsed();
    ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
    Assert.assertEquals("mana variations don't fit", 3, manaOptions.size());
    assertManaOptions("{G}", manaOptions);
    assertManaOptions("{W}{U}{B}", manaOptions);
    assertManaOptions("{R}{R}{R}", manaOptions);
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) ManaOptionsTestUtils.assertManaOptions(org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions) 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