Search in sources :

Example 41 with ManaOptions

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

the class HarvestMageTest method test_AncientTomb.

@Test
public void test_AncientTomb() {
    setStrictChooseMode(true);
    addCard(Zone.BATTLEFIELD, playerA, "Ancient Tomb", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
    addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
    addCard(Zone.HAND, playerA, "Silvercoat Lion");
    // {G}, {T}, Discard a card: Until end of turn, if you tap a land for mana, it produces one mana of a color of your choice instead of any other type and amount.
    // Creature 1/1 {G}
    addCard(Zone.HAND, playerA, "Harvest Mage", 1);
    castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Harvest Mage");
    activateAbility(3, PhaseStep.PRECOMBAT_MAIN, playerA, "{G}, {T}, Discard a card: Until end of turn");
    setChoice(playerA, "Silvercoat Lion");
    setStopAt(3, PhaseStep.POSTCOMBAT_MAIN);
    execute();
    assertAllCommandsUsed();
    assertPermanentCount(playerA, "Harvest Mage", 1);
    ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
    Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
    assertManaOptions("{Any}{Any}", manaOptions);
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) ManaOptionsTestUtils.assertManaOptions(org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions) Test(org.junit.Test)

Example 42 with ManaOptions

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

the class NonTappingManaAbilitiesTest method testAvailableManaWithSpiritGuides.

@Test
public void testAvailableManaWithSpiritGuides() {
    // Exile Simian Spirit Guide from your hand: Add {R}.
    addCard(Zone.HAND, playerA, "Simian Spirit Guide", 1);
    // Exile Simian Spirit Guide from your hand: Add {R}.
    addCard(Zone.HAND, playerA, "Elvish Spirit Guide", 1);
    setStopAt(1, PhaseStep.UPKEEP);
    execute();
    ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
    Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
    assertManaOptions("{R}{G}", manaOptions);
}
Also used : ManaOptions(mage.abilities.mana.ManaOptions) ManaOptionsTestUtils.assertManaOptions(org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions) Test(org.junit.Test)

Example 43 with ManaOptions

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

the class NonTappingManaAbilitiesTest method TestCoalGolemAndDromarsAttendant.

@Test
public void TestCoalGolemAndDromarsAttendant() {
    setStrictChooseMode(true);
    addCard(Zone.BATTLEFIELD, playerA, "Forest", 1);
    // {1}, Sacrifice Dromar's Attendant: Add {W}{U}{B}.
    addCard(Zone.BATTLEFIELD, playerA, "Dromar's Attendant", 1);
    // {3}, Sacrifice Coal Golem: Add {R}{R}{R}.
    addCard(Zone.BATTLEFIELD, playerA, "Coal Golem", 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)

Example 44 with ManaOptions

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

the class ManaReflectionTest method ManaReflectionWithGoblinClearcutterTest.

@Test
public void ManaReflectionWithGoblinClearcutterTest() {
    // If you tap a permanent for mana, it produces twice as much of that mana instead.
    addCard(Zone.BATTLEFIELD, playerA, "Mana Reflection");
    // {T}, Sacrifice a Forest: Add three mana in any combination of {R} and/or {G}.
    addCard(Zone.BATTLEFIELD, playerA, "Goblin Clearcutter");
    addCard(Zone.BATTLEFIELD, playerA, "Forest");
    setStopAt(1, PhaseStep.PRECOMBAT_MAIN);
    execute();
    ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
    assertDuplicatedManaOptions(manaOptions);
    Assert.assertEquals("mana variations don't fit", 4, manaOptions.size());
    assertManaOptions("{R}{R}{R}{R}{R}{R}{G}{G}", manaOptions);
    assertManaOptions("{R}{R}{R}{R}{G}{G}{G}{G}", manaOptions);
    assertManaOptions("{R}{R}{G}{G}{G}{G}{G}{G}", manaOptions);
    assertManaOptions("{G}{G}{G}{G}{G}{G}{G}{G}", 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)

Example 45 with ManaOptions

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

the class PlayerImpl method findActivatedAbilityFromPlayable.

protected ActivatedAbility findActivatedAbilityFromPlayable(MageObject object, ManaOptions availableMana, Ability ability, Game game) {
    // special mana to pay spell cost
    ManaOptions manaFull = availableMana.copy();
    if (ability instanceof SpellAbility) {
        for (AlternateManaPaymentAbility altAbility : CardUtil.getAbilities(object, game).stream().filter(a -> a instanceof AlternateManaPaymentAbility).map(a -> (AlternateManaPaymentAbility) a).collect(Collectors.toList())) {
            ManaOptions manaSpecial = altAbility.getManaOptions(ability, game, ability.getManaCostsToPay());
            manaFull.addMana(manaSpecial);
        }
    }
    // replace alternative abilities by real play abilities (e.g. morph/facedown static ability by play land)
    if (ability instanceof ActivatedManaAbilityImpl) {
        // mana ability
        if (((ActivatedManaAbilityImpl) ability).canActivate(this.getId(), game).canActivate()) {
            return (ActivatedManaAbilityImpl) ability;
        }
    } else if (ability instanceof AlternativeSourceCosts) {
        // alternative cost must be replaced by real play ability
        return findActivatedAbilityFromAlternativeSourceCost(object, manaFull, ability, game);
    } else if (ability instanceof ActivatedAbility) {
        // all other activated ability
        if (canPlay((ActivatedAbility) ability, manaFull, object, game)) {
            return (ActivatedAbility) ability;
        }
    }
    // non playable abilities like static
    return null;
}
Also used : MatchPlayer(mage.game.match.MatchPlayer) PermanentIdPredicate(mage.filter.predicate.permanent.PermanentIdPredicate) UserData(mage.players.net.UserData) Counters(mage.counters.Counters) mage.abilities.costs(mage.abilities.costs) Logger(org.apache.log4j.Logger) ManaCost(mage.abilities.costs.mana.ManaCost) StackObject(mage.game.stack.StackObject) mage.constants(mage.constants) mage.abilities(mage.abilities) Choice(mage.choices.Choice) FilterMana(mage.filter.FilterMana) FilterCard(mage.filter.FilterCard) ActivatedManaAbilityImpl(mage.abilities.mana.ActivatedManaAbilityImpl) StaticFilters(mage.filter.StaticFilters) GameLog(mage.util.GameLog) AlternateManaPaymentAbility(mage.abilities.costs.mana.AlternateManaPaymentAbility) RestrictionUntapNotMoreThanEffect(mage.abilities.effects.RestrictionUntapNotMoreThanEffect) ImmutableMap(com.google.common.collect.ImmutableMap) mage.abilities.keyword(mage.abilities.keyword) mage.cards(mage.cards) FilterCreatureForCombatBlock(mage.filter.common.FilterCreatureForCombatBlock) TargetDiscard(mage.target.common.TargetDiscard) StackAbility(mage.game.stack.StackAbility) CardUtil(mage.util.CardUtil) Collectors(java.util.stream.Collectors) CommandObject(mage.game.command.CommandObject) Serializable(java.io.Serializable) FilterCreatureForCombat(mage.filter.common.FilterCreatureForCombat) Permanent(mage.game.permanent.Permanent) Entry(java.util.Map.Entry) TargetAmount(mage.target.TargetAmount) WhileSearchingPlayFromLibraryAbility(mage.abilities.common.WhileSearchingPlayFromLibraryAbility) CounterType(mage.counters.CounterType) Target(mage.target.Target) mage(mage) java.util(java.util) RestrictionEffect(mage.abilities.effects.RestrictionEffect) mage.game(mage.game) LoseControlOnOtherPlayersControllerEffect(mage.abilities.effects.common.LoseControlOnOtherPlayersControllerEffect) DesignationType(mage.designations.DesignationType) mage.game.events(mage.game.events) AtTheEndOfTurnStepPostDelayedTriggeredAbility(mage.abilities.common.delayed.AtTheEndOfTurnStepPostDelayedTriggeredAbility) Predicates(mage.filter.predicate.Predicates) FilterPermanent(mage.filter.FilterPermanent) ManaOptions(mage.abilities.mana.ManaOptions) Step(mage.game.turn.Step) Designation(mage.designations.Designation) PermanentToken(mage.game.permanent.PermanentToken) TargetCard(mage.target.TargetCard) Counter(mage.counters.Counter) CombatGroup(mage.game.combat.CombatGroup) Spell(mage.game.stack.Spell) MageDrawAction(mage.actions.MageDrawAction) RandomUtil(mage.util.RandomUtil) TargetCardInLibrary(mage.target.common.TargetCardInLibrary) ManaCosts(mage.abilities.costs.mana.ManaCosts) PassAbility(mage.abilities.common.PassAbility) SquirrelToken(mage.game.permanent.token.SquirrelToken) Deck(mage.cards.decks.Deck) PlayLandAsCommanderAbility(mage.abilities.common.PlayLandAsCommanderAbility) ManaCostsImpl(mage.abilities.costs.mana.ManaCostsImpl) ChoiceImpl(mage.choices.ChoiceImpl) FilterControlledPermanent(mage.filter.common.FilterControlledPermanent) ActivationStatus(mage.abilities.ActivatedAbility.ActivationStatus) PermanentCard(mage.game.permanent.PermanentCard) TargetPermanent(mage.target.TargetPermanent) ManaOptions(mage.abilities.mana.ManaOptions) AlternateManaPaymentAbility(mage.abilities.costs.mana.AlternateManaPaymentAbility) ActivatedManaAbilityImpl(mage.abilities.mana.ActivatedManaAbilityImpl)

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