mirror of
https://github.com/magefree/mage.git
synced 2025-12-28 06:22:01 -08:00
* Started reworking netmana to also handle mana sources that could only produce 2-4 colors. Not finished yet.
This commit is contained in:
parent
eba9e5925f
commit
97412e3e9e
44 changed files with 250 additions and 131 deletions
|
|
@ -61,9 +61,9 @@ public class ConditionalManaEffect extends ManaEffect {
|
|||
|
||||
public ConditionalManaEffect(ConditionalManaEffect effect) {
|
||||
super(effect);
|
||||
this.effect = (BasicManaEffect) effect.effect.copy();
|
||||
this.effect = effect.effect.copy();
|
||||
if (effect.otherwiseEffect != null) {
|
||||
this.otherwiseEffect = (BasicManaEffect) effect.otherwiseEffect.copy();
|
||||
this.otherwiseEffect = effect.otherwiseEffect.copy();
|
||||
}
|
||||
this.condition = effect.condition;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,7 +62,9 @@ public class AddManaOfAnyColorTargetCanProduceEffect extends ManaEffect {
|
|||
Abilities<ManaAbility> mana = permanent.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");
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.constants.Zone;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.abilities.costs.Cost;
|
||||
|
|
@ -47,7 +48,7 @@ public class ActivateIfConditionManaAbility extends ManaAbility {
|
|||
|
||||
public ActivateIfConditionManaAbility(Zone zone, BasicManaEffect effect, Cost cost, Condition condition) {
|
||||
super(zone, effect, cost);
|
||||
this.netMana = effect.getMana();
|
||||
this.netMana.add(effect.getMana());
|
||||
this.condition = condition;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
package mage.abilities.mana;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
|
|
@ -55,12 +56,12 @@ public class ActivateOncePerTurnManaAbility extends ManaAbility {
|
|||
|
||||
public ActivateOncePerTurnManaAbility(Zone zone, BasicManaEffect effect, Cost cost) {
|
||||
super(zone, effect, cost);
|
||||
this.netMana = effect.getMana();
|
||||
this.netMana.add(effect.getMana());
|
||||
}
|
||||
|
||||
public ActivateOncePerTurnManaAbility(Zone zone, AddManaOfAnyColorEffect effect, Cost cost) {
|
||||
super(zone, effect, cost);
|
||||
this.netMana.setAny(effect.getAmount());
|
||||
this.netMana.add(new Mana(0,0,0,0,0,0,effect.getAmount()));
|
||||
}
|
||||
|
||||
public ActivateOncePerTurnManaAbility(ActivateOncePerTurnManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.AddManaOfAnyColorEffect;
|
||||
|
|
@ -39,7 +40,7 @@ public class AnyColorManaAbility extends ManaAbility {
|
|||
|
||||
public AnyColorManaAbility(Cost cost) {
|
||||
super(Zone.BATTLEFIELD, new AddManaOfAnyColorEffect(), cost);
|
||||
this.netMana.setAny(1);
|
||||
this.netMana.add(new Mana(0,0,0,0,0,0,1));
|
||||
}
|
||||
|
||||
public AnyColorManaAbility(final AnyColorManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
|||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -39,7 +40,7 @@ public class BlackManaAbility extends BasicManaAbility {
|
|||
|
||||
public BlackManaAbility() {
|
||||
super(new BasicManaEffect(Mana.BlackMana));
|
||||
this.netMana.setBlack(1);
|
||||
this.netMana.add(new Mana(ColoredManaSymbol.B));
|
||||
}
|
||||
|
||||
public BlackManaAbility(BlackManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
|||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -39,7 +40,7 @@ public class BlueManaAbility extends BasicManaAbility {
|
|||
|
||||
public BlueManaAbility() {
|
||||
super(new BasicManaEffect(Mana.BlueMana));
|
||||
this.netMana.setBlue(1);
|
||||
this.netMana.add(new Mana(ColoredManaSymbol.U));
|
||||
}
|
||||
|
||||
public BlueManaAbility(BlueManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class ColorlessManaAbility extends BasicManaAbility {
|
|||
|
||||
public ColorlessManaAbility() {
|
||||
super(new BasicManaEffect(Mana.ColorlessMana));
|
||||
this.netMana.setColorless(1);
|
||||
this.netMana.add(new Mana(0,0,0,0,0,1,0));
|
||||
}
|
||||
|
||||
public ColorlessManaAbility(ColorlessManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.AddConditionalManaOfAnyColorEffect;
|
||||
|
|
@ -62,7 +63,7 @@ public class ConditionalAnyColorManaAbility extends ManaAbility {
|
|||
for (int i = 0; i < choices; i++) {
|
||||
this.addChoice(new ChoiceColor());
|
||||
}
|
||||
this.netMana.setAny(amount);
|
||||
this.netMana.add(new Mana(0,0,0,0,0,0,amount));
|
||||
}
|
||||
|
||||
public ConditionalAnyColorManaAbility(final ConditionalAnyColorManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
import mage.abilities.effects.common.AddConditionalColorlessManaEffect;
|
||||
|
|
@ -24,8 +25,8 @@ public class ConditionalColorlessManaAbility extends ManaAbility {
|
|||
}
|
||||
|
||||
public ConditionalColorlessManaAbility(Cost cost, int amount, ConditionalManaBuilder manaBuilder) {
|
||||
super(Zone.BATTLEFIELD, new AddConditionalColorlessManaEffect(amount, manaBuilder), cost);
|
||||
this.netMana.setColorless(amount);
|
||||
super(Zone.BATTLEFIELD, new AddConditionalColorlessManaEffect(amount, manaBuilder), cost);
|
||||
this.netMana.add(new Mana(0,0,0,0,0,amount,0));
|
||||
}
|
||||
|
||||
public ConditionalColorlessManaAbility(final ConditionalColorlessManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.decorator.ConditionalManaEffect;
|
||||
|
|
@ -59,7 +61,9 @@ public class ConditionalManaAbility extends ManaAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mana getNetMana(Game game) {
|
||||
return conditionalManaEffect.getMana(game, this);
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> newNetMana = new ArrayList<>();
|
||||
newNetMana.add(conditionalManaEffect.getMana(game, this));
|
||||
return newNetMana;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@
|
|||
*/
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import mage.Mana;
|
||||
import mage.abilities.costs.Cost;
|
||||
import mage.abilities.costs.common.TapSourceCost;
|
||||
|
|
@ -84,10 +86,11 @@ public class DynamicManaAbility extends ManaAbility {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Mana getNetMana(Game game) {
|
||||
if (game == null) {
|
||||
return new Mana();
|
||||
}
|
||||
return new Mana(manaEffect.computeMana(true, game, this));
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
List<Mana> newNetMana = new ArrayList<>();
|
||||
if (game != null) {
|
||||
newNetMana.add(manaEffect.computeMana(true, game, this));
|
||||
}
|
||||
return newNetMana;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
|||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -39,7 +40,7 @@ public class GreenManaAbility extends BasicManaAbility {
|
|||
|
||||
public GreenManaAbility() {
|
||||
super(new BasicManaEffect(Mana.GreenMana));
|
||||
this.netMana.setGreen(1);
|
||||
this.netMana.add(new Mana(ColoredManaSymbol.G));
|
||||
}
|
||||
|
||||
public GreenManaAbility(GreenManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@
|
|||
|
||||
package mage.abilities.mana;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.Mana;
|
||||
import mage.abilities.ActivatedAbilityImpl;
|
||||
|
|
@ -43,7 +45,7 @@ import mage.game.Game;
|
|||
*/
|
||||
public abstract class ManaAbility extends ActivatedAbilityImpl {
|
||||
|
||||
protected Mana netMana = new Mana();
|
||||
protected List<Mana> netMana = new ArrayList<>();
|
||||
|
||||
public ManaAbility(Zone zone, ManaEffect effect, Cost cost) {
|
||||
super(AbilityType.MANA, zone);
|
||||
|
|
@ -58,7 +60,7 @@ public abstract class ManaAbility extends ActivatedAbilityImpl {
|
|||
|
||||
public ManaAbility(ManaAbility ability) {
|
||||
super(ability);
|
||||
this.netMana = ability.netMana.copy();
|
||||
this.netMana.addAll(ability.netMana);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -70,7 +72,14 @@ public abstract class ManaAbility extends ActivatedAbilityImpl {
|
|||
return costs.canPay(this, sourceId, controllerId, game);
|
||||
}
|
||||
|
||||
public Mana getNetMana(Game game) {
|
||||
/**
|
||||
* Used to check the possible mana production to determine
|
||||
* which spells and/or abilities can be used. (player.getPlayable()).
|
||||
*
|
||||
* @param game
|
||||
* @return
|
||||
*/
|
||||
public List<Mana> getNetMana(Game game) {
|
||||
return netMana;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,18 +59,35 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
if (!abilities.isEmpty()) {
|
||||
if (abilities.size() == 1) {
|
||||
//if there is only one mana option available add it to all the existing options
|
||||
addMana(abilities.get(0).getNetMana(game));
|
||||
List<Mana> netManas = abilities.get(0).getNetMana(game);
|
||||
if (netManas.size() == 1) {
|
||||
addMana(netManas.get(0));
|
||||
} else {
|
||||
List<Mana> copy = copy();
|
||||
this.clear();
|
||||
for (Mana netMana: netManas) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(netMana);
|
||||
this.add(newMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (abilities.size() > 1) {
|
||||
//perform a union of all existing options and the new options
|
||||
List<Mana> copy = copy();
|
||||
this.clear();
|
||||
for (ManaAbility ability: abilities) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(ability.getNetMana(game));
|
||||
this.add(newMana);
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(netMana);
|
||||
this.add(newMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,11 +102,38 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
if (abilities.size() == 1) {
|
||||
//if there is only one mana option available add it to all the existing options
|
||||
ManaAbility ability = abilities.get(0);
|
||||
List<Mana> netManas = abilities.get(0).getNetMana(game);
|
||||
if (ability.getManaCosts().isEmpty()) {
|
||||
addMana(ability.getNetMana(game));
|
||||
if (netManas.size() == 1) {
|
||||
addMana(netManas.get(0));
|
||||
} else {
|
||||
List<Mana> copy = copy();
|
||||
this.clear();
|
||||
for (Mana netMana: netManas) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(netMana);
|
||||
this.add(newMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
addMana(ability.getManaCosts().getMana(), ability.getNetMana(game));
|
||||
else {
|
||||
if (netManas.size() == 1) {
|
||||
addMana(ability.getManaCosts().getMana(), netManas.get(0));
|
||||
} else {
|
||||
List<Mana> copy = copy();
|
||||
this.clear();
|
||||
for (Mana netMana: netManas) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(netMana);
|
||||
addMana(ability.getManaCosts().getMana(), netMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (abilities.size() > 1) {
|
||||
|
|
@ -97,23 +141,28 @@ public class ManaOptions extends ArrayList<Mana> {
|
|||
List<Mana> copy = copy();
|
||||
this.clear();
|
||||
for (ManaAbility ability: abilities) {
|
||||
List<Mana> netManas = ability.getNetMana(game);
|
||||
if (ability.getManaCosts().isEmpty()) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(ability.getNetMana(game));
|
||||
this.add(newMana);
|
||||
for (Mana netMana: netManas) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
newMana.add(netMana);
|
||||
this.add(newMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
if (mana.contains(ability.getManaCosts().getMana())) {
|
||||
newMana.subtract(ability.getManaCosts().getMana());
|
||||
newMana.add(ability.getNetMana(game));
|
||||
for (Mana netMana: netManas) {
|
||||
for (Mana mana: copy) {
|
||||
Mana newMana = new Mana();
|
||||
newMana.add(mana);
|
||||
if (mana.contains(ability.getManaCosts().getMana())) {
|
||||
newMana.subtract(ability.getManaCosts().getMana());
|
||||
newMana.add(netMana);
|
||||
}
|
||||
this.add(newMana);
|
||||
}
|
||||
this.add(newMana);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
|||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -39,7 +40,7 @@ public class RedManaAbility extends BasicManaAbility {
|
|||
|
||||
public RedManaAbility() {
|
||||
super(new BasicManaEffect(Mana.RedMana));
|
||||
this.netMana.setRed(1);
|
||||
this.netMana.add(new Mana(ColoredManaSymbol.R));
|
||||
}
|
||||
|
||||
public RedManaAbility(RedManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public class SimpleManaAbility extends ManaAbility {
|
|||
|
||||
public SimpleManaAbility(Zone zone, Mana mana, Cost cost) {
|
||||
super(zone, new BasicManaEffect(mana), cost);
|
||||
this.netMana = mana.copy();
|
||||
this.netMana.add(mana.copy());
|
||||
}
|
||||
|
||||
public SimpleManaAbility(final SimpleManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ package mage.abilities.mana;
|
|||
|
||||
import mage.Mana;
|
||||
import mage.abilities.effects.common.BasicManaEffect;
|
||||
import mage.constants.ColoredManaSymbol;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -39,7 +40,7 @@ public class WhiteManaAbility extends BasicManaAbility {
|
|||
|
||||
public WhiteManaAbility() {
|
||||
super(new BasicManaEffect(Mana.WhiteMana));
|
||||
this.netMana.setWhite(1);
|
||||
this.netMana.add(new Mana(ColoredManaSymbol.W));
|
||||
}
|
||||
|
||||
public WhiteManaAbility(WhiteManaAbility ability) {
|
||||
|
|
|
|||
|
|
@ -290,7 +290,9 @@ public abstract class CardImpl extends MageObjectImpl implements Card {
|
|||
public List<Mana> getMana() {
|
||||
List<Mana> mana = new ArrayList<>();
|
||||
for (ManaAbility ability : this.abilities.getManaAbilities(Zone.BATTLEFIELD)) {
|
||||
mana.add(ability.getNetMana(null));
|
||||
for (Mana netMana: ability.getNetMana(null)) {
|
||||
mana.add(netMana);
|
||||
}
|
||||
}
|
||||
return mana;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue