Additional fixes for getNetMana from #6132, added TODO task for next mana improves;

This commit is contained in:
Oleg Agafonov 2020-01-01 02:27:54 +04:00
parent 13cb86d69f
commit f5ef16c8cf
4 changed files with 98 additions and 23 deletions

View file

@ -1,8 +1,5 @@
package mage.cards.v;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.ConditionalMana;
import mage.MageInt;
import mage.MageObject;
@ -23,8 +20,11 @@ import mage.constants.Zone;
import mage.game.Game;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/**
*
* @author jeffwadsworth
*/
public final class VedalkenEngineer extends CardImpl {
@ -91,11 +91,7 @@ class VedalkenEngineerEffect extends ManaEffect {
super();
this.amount = amount;
this.manaBuilder = manaBuilder;
netMana.add(Mana.GreenMana(amount));
netMana.add(Mana.BlueMana(amount));
netMana.add(Mana.BlackMana(amount));
netMana.add(Mana.WhiteMana(amount));
netMana.add(Mana.RedMana(amount));
netMana.add(Mana.AnyMana(amount));
staticText = "Add " + amount + " mana of any one color. " + manaBuilder.getRule();
}

View file

@ -1,13 +1,18 @@
package org.mage.test.cards.mana;
import mage.abilities.keyword.FlyingAbility;
import mage.abilities.mana.ManaOptions;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import mage.counters.CounterType;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.assertDuplicatedManaOptions;
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
/**
* @author LevelX2
*/
@ -286,4 +291,74 @@ public class ConditionalManaTest extends CardTestPlayerBase {
assertCounterCount(playerA, "Empowered Autogenerator", CounterType.CHARGE, 2);
assertLife(playerB, 20 - 3);
}
@Test
public void DictateOfKarametra_ManualPay() {
// Whenever you tap a land for mana, add one mana of any type that land produced.
addCard(Zone.BATTLEFIELD, playerA, "Dictate of Karametra");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
//
addCard(Zone.HAND, playerA, "Precision Bolt", 1); // {2}{R}
// manual mana pay to activate extra mana
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
checkManaPool("mana", 1, PhaseStep.PRECOMBAT_MAIN, playerA, "R", 4);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Precision Bolt", playerB);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertLife(playerB, 20 - 3);
}
// TODO: add support TriggeredManaAbility for available mana calculations
// AI can't see extra mana added by AddManaOfAnyTypeProducedEffect and same
// (maybe it was removed by https://github.com/magefree/mage/pull/5943 to fix multiple TAPPED_FOR_MANA calls or never works before)
// As idea: getPlayable -> getManaAvailable -> available.addMana -- search all TriggeredManaAbility
// and process all available net mana by special call like TriggeredManaAbility->getNetManaForEvent(ManaEvent xxx)
@Test
@Ignore
public void TriggeredManaAbilityMustGivesExtraManaOptions() {
// TriggeredManaAbility must give extra mana options (2 red instead 1)
// Whenever you tap a land for mana, add one mana of any type that land produced.
addCard(Zone.BATTLEFIELD, playerA, "Dictate of Karametra");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 1);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 1, manaOptions.size());
assertManaOptions("{R}{R}", manaOptions);
}
@Test
@Ignore
public void DictateOfKarametra_AutoPay() {
// Whenever you tap a land for mana, add one mana of any type that land produced.
addCard(Zone.BATTLEFIELD, playerA, "Dictate of Karametra");
addCard(Zone.BATTLEFIELD, playerA, "Mountain", 2);
//
addCard(Zone.HAND, playerA, "Precision Bolt", 1); // {2}{R}
// computer must see available mana (4 red mana instead 2)
//activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
//activateManaAbility(1, PhaseStep.PRECOMBAT_MAIN, playerA, "{T}: Add {R}");
showAvaileableAbilities("abils", 1, PhaseStep.PRECOMBAT_MAIN, playerA);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Precision Bolt", playerB);
setStrictChooseMode(true);
setStopAt(1, PhaseStep.POSTCOMBAT_MAIN);
execute();
assertAllCommandsUsed();
assertLife(playerB, 20 - 3);
}
}

View file

@ -7,11 +7,11 @@ import mage.constants.Zone;
import org.junit.Assert;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
import static org.mage.test.utils.ManaOptionsTestUtils.assertDuplicatedManaOptions;
import static org.mage.test.utils.ManaOptionsTestUtils.assertManaOptions;
/**
*
* @author escplan9, JayDi85
*/
public class NagaVitalistTest extends CardTestPlayerBase {
@ -51,12 +51,9 @@ public class NagaVitalistTest extends CardTestPlayerBase {
ManaOptions manaOptions = playerA.getAvailableManaTest(currentGame);
assertDuplicatedManaOptions(manaOptions);
Assert.assertEquals("mana variations don't fit", 5, manaOptions.size());
assertManaOptions("{B}{B}", manaOptions);
assertManaOptions("{W}{W}", manaOptions);
assertManaOptions("{U}{U}", manaOptions);
assertManaOptions("{R}{R}", manaOptions);
assertManaOptions("{G}{G}", manaOptions);
Assert.assertEquals("mana variations don't fit", 2, manaOptions.size());
assertManaOptions("{B}", manaOptions);
assertManaOptions("{Any}{Any}", manaOptions);
}
public void nagaVitalist_GiftOfParadisesLandCanGiveAnyColorToNaga_Setup(int giftCastTurn, int nagaManaTapTurn, String nagaManaTapColor) {

View file

@ -1,4 +1,3 @@
package mage.abilities.effects.mana;
import mage.Mana;
@ -10,10 +9,10 @@ import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
import java.util.ArrayList;
import java.util.List;
/**
*
* @author LevelX2
*/
public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
@ -36,6 +35,16 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
return null;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
ArrayList<Mana> netMana = new ArrayList<>();
Mana types = (Mana) this.getValue("mana"); // TODO: will not work until TriggeredManaAbility fix (see TriggeredManaAbilityMustGivesExtraManaOptions test)
if (types != null) {
netMana.add(types.copy());
}
return netMana;
}
@Override
public Mana produceMana(Game game, Ability source) {
Permanent permanent = game.getPermanent(getTargetPointer().getFirst(game, source));
@ -45,6 +54,9 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
return null;
}
Mana types = (Mana) this.getValue("mana");
if (types == null) {
return null;
}
Choice choice = new ChoiceColor(true);
choice.getChoices().clear();
choice.setMessage("Pick the type of mana to produce");
@ -102,11 +114,6 @@ public class AddManaOfAnyTypeProducedEffect extends ManaEffect {
return null;
}
@Override
public List<Mana> getNetMana(Game game, Ability source) {
return null;
}
@Override
public AddManaOfAnyTypeProducedEffect copy() {
return new AddManaOfAnyTypeProducedEffect(this);