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