mirror of
https://github.com/correl/mage.git
synced 2025-04-12 01:01:04 -09: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
Mage.Server.Plugins/Mage.Player.AI/src/main/java/mage/player/ai
Mage.Sets/src/mage/sets
bornofthegods
championsofkamigawa
conflux
darksteel
dragonsmaze
fifthdawn
judgment
mirage
newphyrexia
ninthedition
planechase
revisededition
riseoftheeldrazi
scarsofmirrodin
shadowmoor
shardsofalara
tempest
theros
urzassaga
Mage/src/mage
abilities
decorator
effects/common
mana
ActivateIfConditionManaAbility.javaActivateOncePerTurnManaAbility.javaAnyColorManaAbility.javaBlackManaAbility.javaBlueManaAbility.javaColorlessManaAbility.javaConditionalAnyColorManaAbility.javaConditionalColorlessManaAbility.javaConditionalManaAbility.javaDynamicManaAbility.javaGreenManaAbility.javaManaAbility.javaManaOptions.javaRedManaAbility.javaSimpleManaAbility.javaWhiteManaAbility.java
cards
|
@ -883,10 +883,12 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
for (Mana mana: unplayable.keySet()) {
|
||||
for (Card card: lands) {
|
||||
for (ManaAbility ability: card.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
|
||||
if (ability.getNetMana(game).enough(mana)) {
|
||||
this.playLand(card, game);
|
||||
lands.remove(card);
|
||||
return;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (netMana.enough(mana)) {
|
||||
this.playLand(card, game);
|
||||
lands.remove(card);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -895,10 +897,12 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
for (Mana mana: unplayable.keySet()) {
|
||||
for (Card card: lands) {
|
||||
for (ManaAbility ability: card.getAbilities().getManaAbilities(Zone.BATTLEFIELD)) {
|
||||
if (mana.contains(ability.getNetMana(game))) {
|
||||
this.playLand(card, game);
|
||||
lands.remove(card);
|
||||
return;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (mana.contains(netMana)) {
|
||||
this.playLand(card, game);
|
||||
lands.remove(card);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1018,9 +1022,11 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// pay all colored costs first
|
||||
for (ManaAbility ability: perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (cost instanceof ColoredManaCost) {
|
||||
if (cost.testPay(ability.getNetMana(game))) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (cost.testPay(netMana)) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1028,9 +1034,11 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// then pay hybrid
|
||||
for (ManaAbility ability: perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (cost instanceof HybridManaCost) {
|
||||
if (cost.testPay(ability.getNetMana(game))) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (cost.testPay(netMana)) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1038,9 +1046,11 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// then pay mono hybrid
|
||||
for (ManaAbility ability: perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (cost instanceof MonoHybridManaCost) {
|
||||
if (cost.testPay(ability.getNetMana(game))) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (cost.testPay(netMana)) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1048,9 +1058,11 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
// finally pay generic
|
||||
for (ManaAbility ability: perm.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (cost instanceof GenericManaCost) {
|
||||
if (cost.testPay(ability.getNetMana(game))) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (cost.testPay(netMana)) {
|
||||
if (activateAbility(ability, game)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1080,14 +1092,17 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
private List<Permanent> getSortedProducers(ManaCosts<ManaCost> unpaid, Game game) {
|
||||
List<Permanent> unsorted = this.getAvailableManaProducers(game);
|
||||
unsorted.addAll(this.getAvailableManaProducersWithCost(game));
|
||||
Map<Permanent, Integer> scored = new HashMap<Permanent, Integer>();
|
||||
Map<Permanent, Integer> scored = new HashMap<>();
|
||||
for (Permanent permanent: unsorted) {
|
||||
int score = 0;
|
||||
for (ManaCost cost: unpaid) {
|
||||
Abilities:
|
||||
for (ManaAbility ability: permanent.getAbilities().getAvailableManaAbilities(Zone.BATTLEFIELD, game)) {
|
||||
if (cost.testPay(ability.getNetMana(game))) {
|
||||
score++;
|
||||
break;
|
||||
for (Mana netMana: ability.getNetMana(game)) {
|
||||
if (cost.testPay(netMana)) {
|
||||
score++;
|
||||
break Abilities;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1107,14 +1122,14 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
}
|
||||
|
||||
private List<Permanent> sortByValue(Map<Permanent, Integer> map) {
|
||||
List<Entry<Permanent, Integer>> list = new LinkedList<Entry<Permanent, Integer>>(map.entrySet());
|
||||
List<Entry<Permanent, Integer>> list = new LinkedList<>(map.entrySet());
|
||||
Collections.sort(list, new Comparator<Entry<Permanent, Integer>>() {
|
||||
@Override
|
||||
public int compare(Entry<Permanent, Integer> o1, Entry<Permanent, Integer> o2) {
|
||||
return (o1.getValue().compareTo(o2.getValue()));
|
||||
}
|
||||
});
|
||||
List<Permanent> result = new ArrayList<Permanent>();
|
||||
List<Permanent> result = new ArrayList<>();
|
||||
for (Entry<Permanent, Integer> entry : list) {
|
||||
result.add(entry.getKey());
|
||||
}
|
||||
|
@ -1937,7 +1952,7 @@ public class ComputerPlayer extends PlayerImpl implements Player {
|
|||
|
||||
protected void logState(Game game) {
|
||||
if (log.isTraceEnabled()) {
|
||||
logList(new StringBuilder("Computer player ").append(name).append(" hand: ").toString(), new ArrayList(hand.getCards(game)));
|
||||
logList("Computer player " + name + " hand: ", new ArrayList(hand.getCards(game)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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 ) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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")) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
Reference in a new issue