* Started reworking netmana to also handle mana sources that could only produce 2-4 colors. Not finished yet.

This commit is contained in:
LevelX2 2014-11-17 17:37:02 +01:00
parent eba9e5925f
commit 97412e3e9e
44 changed files with 250 additions and 131 deletions

View file

@ -27,6 +27,8 @@
*/
package mage.sets.bornofthegods;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
@ -127,11 +129,12 @@ class AstralCornucopiaManaAbility extends ManaAbility {
}
@Override
public Mana getNetMana(Game game) {
if (game == null) {
return new Mana();
}
return new Mana(((AstralCornucopiaManaEffect)this.getEffects().get(0)).computeMana(game, this));
public List<Mana> getNetMana(Game game) {
List<Mana> newNetMana = new ArrayList<>();
if (game != null) {
newNetMana.add(new Mana(((AstralCornucopiaManaEffect)this.getEffects().get(0)).computeMana(game, this)));
}
return newNetMana;
}
}

View file

@ -127,7 +127,9 @@ class HeartbeatOfSpringEffect extends ManaEffect {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
for (ManaAbility ability : mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");

View file

@ -97,7 +97,9 @@ class ExoticOrchardEffect extends ManaEffect {
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(true);
@ -131,16 +133,22 @@ class ExoticOrchardEffect extends ManaEffect {
} else {
player.choose(outcome, choice, game);
}
if (choice.getChoice().equals("Black")) {
player.getManaPool().addMana(Mana.BlackMana, game, source);
} else if (choice.getChoice().equals("Blue")) {
player.getManaPool().addMana(Mana.BlueMana, game, source);
} else if (choice.getChoice().equals("Red")) {
player.getManaPool().addMana(Mana.RedMana, game, source);
} else if (choice.getChoice().equals("Green")) {
player.getManaPool().addMana(Mana.GreenMana, game, source);
} else if (choice.getChoice().equals("White")) {
player.getManaPool().addMana(Mana.WhiteMana, game, source);
switch (choice.getChoice()) {
case "Black":
player.getManaPool().addMana(Mana.BlackMana, game, source);
break;
case "Blue":
player.getManaPool().addMana(Mana.BlueMana, game, source);
break;
case "Red":
player.getManaPool().addMana(Mana.RedMana, game, source);
break;
case "Green":
player.getManaPool().addMana(Mana.GreenMana, game, source);
break;
case "White":
player.getManaPool().addMana(Mana.WhiteMana, game, source);
break;
}
}
return true;

View file

@ -55,6 +55,8 @@ public class KnotvineMystic extends CardImpl{
this.subtype.add("Druid");
this.power = new MageInt(2);
this.toughness = new MageInt(2);
// {1}, {T}: Add {R}{G}{W} to your mana pool.
Ability ability = new KnotvineMysticManaAbility();
ability.addManaCost(new GenericManaCost(1));
this.addAbility(ability);
@ -75,9 +77,7 @@ class KnotvineMysticManaAbility extends BasicManaAbility {
public KnotvineMysticManaAbility() {
super(new BasicManaEffect(new Mana(1, 1, 0, 1, 0, 0, 0)));
this.netMana.setGreen(1);
this.netMana.setRed(1);
this.netMana.setWhite(1);
this.netMana.add(new Mana(1, 1, 0, 1, 0, 0, 0));
}
public KnotvineMysticManaAbility(final KnotvineMysticManaAbility ability) {

View file

@ -64,7 +64,7 @@ class UrGolemsEyeAbility extends BasicManaAbility {
public UrGolemsEyeAbility() {
super(new BasicManaEffect(new Mana(0, 0, 0, 0, 0, 2, 0)));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0, 0, 0, 0, 0, 2, 0));
}
public UrGolemsEyeAbility(final UrGolemsEyeAbility ability) {

View file

@ -133,7 +133,9 @@ class ZhurTaaAncientEffect extends ManaEffect {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
for (ManaAbility ability : mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");

View file

@ -104,7 +104,9 @@ class SylvokExplorerEffect extends ManaEffect {
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(true);

View file

@ -131,7 +131,9 @@ class MirarisWakeManaEffect extends ManaEffect {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
for (ManaAbility ability: mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");

View file

@ -76,7 +76,7 @@ class LionsEyeDiamondAbility extends ManaAbility {
public LionsEyeDiamondAbility(Zone zone, Mana mana, Cost cost) {
super(zone, new BasicManaEffect(mana), cost);
this.netMana = mana.copy();
this.netMana.add(mana.copy());
}
public LionsEyeDiamondAbility(final LionsEyeDiamondAbility ability) {

View file

@ -137,7 +137,9 @@ class VorinclexEffect extends ManaEffect {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
for (ManaAbility ability: mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");

View file

@ -97,7 +97,9 @@ class FellwarStoneEffect extends ManaEffect {
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(true);

View file

@ -115,7 +115,7 @@ class VedalkenEngineerAbility extends ManaAbility {
public VedalkenEngineerAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) {
super(Zone.BATTLEFIELD, new VedalkenEngineerEffect(amount, manaBuilder), cost);
this.addChoice(new ChoiceColor());
this.netMana.setAny(amount);
this.netMana.add(new Mana(0,0,0,0,0,0, amount));
}
public VedalkenEngineerAbility(final VedalkenEngineerAbility ability) {

View file

@ -62,7 +62,7 @@ class SolRingAbility extends BasicManaAbility {
public SolRingAbility() {
super(new BasicManaEffect(Mana.ColorlessMana(2)));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0,0,0,0,0,2,0));
}
public SolRingAbility(final SolRingAbility ability) {

View file

@ -73,7 +73,7 @@ public class DreamstoneHedron extends CardImpl {
public DreamstoneHedronFirstManaAbility() {
super(new BasicManaEffect(new Mana(0, 0, 0, 0, 0, 3, 0)));
this.netMana.setColorless(3);
this.netMana.add(new Mana(0,0,0,0,0,3,0));
}
public DreamstoneHedronFirstManaAbility(final DreamstoneHedronFirstManaAbility ability) {

View file

@ -70,7 +70,7 @@ class EldraziTempleManaAbility extends BasicManaAbility {
EldraziTempleManaAbility ( ) {
super(new BasicManaEffect(new EldraziConditionalMana()));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0,0,0,0,0,2,0));
}
EldraziTempleManaAbility ( EldraziTempleManaAbility ability ) {

View file

@ -148,7 +148,7 @@ class GrandArchitectManaAbility extends ManaAbility {
GrandArchitectManaAbility ( ) {
super(Zone.BATTLEFIELD, new BasicManaEffect(new GrandArchitectConditionalMana()), new TapTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, true)));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0,0,0,0,0,2,0));
}
GrandArchitectManaAbility ( GrandArchitectManaAbility ability ) {

View file

@ -88,7 +88,7 @@ class MyrReservoirManaAbility extends BasicManaAbility {
MyrReservoirManaAbility() {
super(new BasicManaEffect(new MyrConditionalMana()));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0,0,0,0,0,2,0));
}
MyrReservoirManaAbility(MyrReservoirManaAbility ability) {

View file

@ -67,7 +67,7 @@ class PalladiumMyrAbility extends BasicManaAbility {
public PalladiumMyrAbility() {
super(new BasicManaEffect(Mana.ColorlessMana(2)));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0,0,0,0,0,2,0));
}
public PalladiumMyrAbility(final PalladiumMyrAbility ability) {

View file

@ -80,7 +80,7 @@ public class PrismaticOmen extends CardImpl {
class BecomesBasicLandTypeAllEffect extends ContinuousEffectImpl {
protected ArrayList<String> landTypes = new ArrayList();
protected ArrayList<String> landTypes = new ArrayList<>();
public BecomesBasicLandTypeAllEffect(String... landNames) {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -112,7 +112,9 @@ class BecomesBasicLandTypeAllEffect extends ContinuousEffectImpl {
Mana mana = new Mana();
for (Ability ability : land.getAbilities()){
if (ability instanceof BasicManaAbility) {
mana.add(((BasicManaAbility)ability ).getNetMana(game));
for (Mana netMana: ((BasicManaAbility)ability ).getNetMana(game)) {
mana.add(netMana);
}
}
}
if (mana.getGreen() == 0 && landTypes.contains("Forest")) {

View file

@ -135,7 +135,9 @@ class HeartbeatOfSpringEffect extends ManaEffect {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
Mana types = new Mana();
for (ManaAbility ability: mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
Choice choice = new ChoiceImpl(true);
choice.setMessage("Pick a mana color");

View file

@ -93,7 +93,9 @@ class ReflectingPoolEffect extends ManaEffect {
for (Permanent land : lands) {
Abilities<ManaAbility> mana = land.getAbilities().getManaAbilities(Zone.BATTLEFIELD);
for (ManaAbility ability : mana) {
types.add(ability.getNetMana(game));
for (Mana netMana: ability.getNetMana(game)) {
types.add(netMana);
}
}
}
Choice choice = new ChoiceImpl(false);

View file

@ -27,7 +27,7 @@
*/
package mage.sets.theros;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.Mana;
import mage.abilities.Ability;
@ -91,18 +91,12 @@ class NykthosShrineToNyxManaAbility extends ManaAbility {
}
@Override
public Mana getNetMana(Game game) {
if (game == null) {
return new Mana();
}
// TODO: Give back at least the highest amount (https://github.com/magefree/mage/issues/585)
int amount = 0;
for (String colorChoice :ChoiceColor.colorChoices) {
Mana newMana = ((NykthosDynamicManaEffect)this.getEffects().get(0)).computeMana(colorChoice, game, this);
if (newMana.count() > amount) {
netMana = newMana;
amount = newMana.count();
}
public List<Mana> getNetMana(Game game) {
netMana.clear();
if (game != null) {
for (String colorChoice :ChoiceColor.colorChoices) {
netMana.add(((NykthosDynamicManaEffect)this.getEffects().get(0)).computeMana(colorChoice, game, this));
}
}
return netMana;
}

View file

@ -95,7 +95,7 @@ public class NyleasPresence extends CardImpl {
class NyleasPresenceLandTypeEffect extends ContinuousEffectImpl {
protected ArrayList<String> landTypes = new ArrayList();
protected ArrayList<String> landTypes = new ArrayList<>();
public NyleasPresenceLandTypeEffect(String... landNames) {
super(Duration.WhileOnBattlefield, Outcome.Detriment);
@ -129,7 +129,9 @@ class NyleasPresenceLandTypeEffect extends ContinuousEffectImpl {
Mana mana = new Mana();
for (Ability ability : land.getAbilities()){
if (ability instanceof BasicManaAbility) {
mana.add(((BasicManaAbility)ability ).getNetMana(game));
for (Mana netMana: ((BasicManaAbility)ability ).getNetMana(game)) {
mana.add(netMana);
}
}
}
if (mana.getGreen() == 0 && landTypes.contains("Forest")) {

View file

@ -64,7 +64,7 @@ class WornPowerstoneAbility extends BasicManaAbility {
public WornPowerstoneAbility() {
super(new BasicManaEffect(Mana.ColorlessMana(2)));
this.netMana.setColorless(2);
this.netMana.add(new Mana(0,0,0,0,0,2,0));
}
public WornPowerstoneAbility(final WornPowerstoneAbility ability) {