mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
- Fixed some bugs related to reflected mana.
- The AI can now use reflected mana sources.
This commit is contained in:
@@ -2657,7 +2657,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
AbilityManaPart am = a.getManaPart();
|
AbilityManaPart am = a.getManaPart();
|
||||||
if ((am.isBasic() || am.isReflectedMana()) && !res.contains(a)) {
|
if (am.isBasic() && !res.contains(a)) {
|
||||||
res.add(a);
|
res.add(a);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -5973,7 +5973,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
*/
|
*/
|
||||||
public final boolean isReflectedLand() {
|
public final boolean isReflectedLand() {
|
||||||
for (final SpellAbility a : this.getCharacteristics().getManaAbility()) {
|
for (final SpellAbility a : this.getCharacteristics().getManaAbility()) {
|
||||||
if (a.getManaPart().isReflectedMana()) {
|
if (a.getApi().equals(ApiType.ManaReflected)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import forge.card.CardCharacteristics;
|
|||||||
import forge.card.EditionInfo;
|
import forge.card.EditionInfo;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.spellability.AbilityManaPart;
|
import forge.card.spellability.AbilityManaPart;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
@@ -501,6 +502,10 @@ public final class CardUtil {
|
|||||||
// so we basically need to have a recursive list that send the parents
|
// so we basically need to have a recursive list that send the parents
|
||||||
// so we don't infinite recurse.
|
// so we don't infinite recurse.
|
||||||
final Card card = abMana.getSourceCard();
|
final Card card = abMana.getSourceCard();
|
||||||
|
|
||||||
|
if (!abMana.getApi().equals(ApiType.ManaReflected)) {
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
|
||||||
if (!parents.contains(card)) {
|
if (!parents.contains(card)) {
|
||||||
parents.add(card);
|
parents.add(card);
|
||||||
@@ -577,7 +582,7 @@ public final class CardUtil {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ab.getManaPart().isReflectedMana()) {
|
if (ab.getApi().equals(ApiType.ManaReflected)) {
|
||||||
if (!parents.contains(ab.getSourceCard())) {
|
if (!parents.contains(ab.getSourceCard())) {
|
||||||
// Recursion!
|
// Recursion!
|
||||||
reflectAbilities.add(ab);
|
reflectAbilities.add(ab);
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ public class ManaReflectedEffect extends SpellEffect {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// AI doesn't really have anything here yet
|
// AI doesn't really have anything here yet
|
||||||
baseMana = MagicColor.toShortString(colors.iterator().next());
|
baseMana = sa.getManaPart().getExpressChoice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,9 +46,6 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
private String manaRestrictions = "";
|
private String manaRestrictions = "";
|
||||||
private transient ArrayList<Mana> lastProduced = new ArrayList<Mana>();
|
private transient ArrayList<Mana> lastProduced = new ArrayList<Mana>();
|
||||||
|
|
||||||
/** The reflected. */
|
|
||||||
private boolean reflected = false;
|
|
||||||
|
|
||||||
/** The canceled. */
|
/** The canceled. */
|
||||||
private boolean canceled = false;
|
private boolean canceled = false;
|
||||||
|
|
||||||
@@ -220,18 +217,6 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
return this.getOrigProduced();
|
return this.getOrigProduced();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* setReflectedMana.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param bReflect
|
|
||||||
* a boolean.
|
|
||||||
*/
|
|
||||||
public final void setReflectedMana(final boolean bReflect) {
|
|
||||||
this.reflected = bReflect;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* setAnyChoice.
|
* setAnyChoice.
|
||||||
@@ -286,17 +271,6 @@ public class AbilityManaPart implements java.io.Serializable {
|
|||||||
return this.getSourceCard().isSnow();
|
return this.getSourceCard().isSnow();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* isReflectedMana.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @return a boolean.
|
|
||||||
*/
|
|
||||||
public final boolean isReflectedMana() {
|
|
||||||
return this.reflected;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* isAnyMana.
|
* isAnyMana.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import forge.CardUtil;
|
|||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.mana.ManaCostBeingPaid;
|
import forge.card.mana.ManaCostBeingPaid;
|
||||||
import forge.card.mana.ManaPool;
|
import forge.card.mana.ManaPool;
|
||||||
import forge.card.spellability.AbilityManaPart;
|
import forge.card.spellability.AbilityManaPart;
|
||||||
@@ -68,7 +69,7 @@ public abstract class InputPayManaBase extends Input {
|
|||||||
if (m.isAnyMana()) {
|
if (m.isAnyMana()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (m.isReflectedMana()) {
|
if (am.getApi().equals(ApiType.ManaReflected)) {
|
||||||
final Iterable<String> reflectableColors = CardUtil.getReflectableManaColors(am, am, new HashSet<String>(), new ArrayList<Card>());
|
final Iterable<String> reflectableColors = CardUtil.getReflectableManaColors(am, am, new HashSet<String>(), new ArrayList<Card>());
|
||||||
for (final String color : reflectableColors) {
|
for (final String color : reflectableColors) {
|
||||||
if (mana.contains(MagicColor.toShortString(color))) {
|
if (mana.contains(MagicColor.toShortString(color))) {
|
||||||
@@ -227,7 +228,7 @@ public abstract class InputPayManaBase extends Input {
|
|||||||
|
|
||||||
for (final SpellAbility am : abilities) {
|
for (final SpellAbility am : abilities) {
|
||||||
AbilityManaPart m = am.getManaPart();
|
AbilityManaPart m = am.getManaPart();
|
||||||
if (m.isReflectedMana()) {
|
if (am.getApi().equals(ApiType.ManaReflected)) {
|
||||||
final Iterable<String> reflectableColors = CardUtil.getReflectableManaColors(am, am, new HashSet<String>(), new ArrayList<Card>());
|
final Iterable<String> reflectableColors = CardUtil.getReflectableManaColors(am, am, new HashSet<String>(), new ArrayList<Card>());
|
||||||
for (final String color : reflectableColors) {
|
for (final String color : reflectableColors) {
|
||||||
if (manaCost.isColor(color)) {
|
if (manaCost.isColor(color)) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import forge.CardPredicates.Presets;
|
|||||||
import forge.card.SpellManaCost;
|
import forge.card.SpellManaCost;
|
||||||
import forge.card.ability.AbilityFactory;
|
import forge.card.ability.AbilityFactory;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.cost.CostDamage;
|
import forge.card.cost.CostDamage;
|
||||||
@@ -1532,6 +1533,9 @@ public final class GameActionUtil {
|
|||||||
baseMana = "Any";
|
baseMana = "Any";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (sa.getApi().equals(ApiType.ManaReflected)) {
|
||||||
|
baseMana = abMana.getExpressChoice();
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
baseMana = abMana.mana();
|
baseMana = abMana.mana();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package forge.game.ai;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -10,10 +11,13 @@ import com.google.common.base.Predicate;
|
|||||||
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
import forge.CardLists;
|
import forge.CardLists;
|
||||||
|
import forge.CardUtil;
|
||||||
|
import forge.Constant;
|
||||||
import forge.Singletons;
|
import forge.Singletons;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.SpellManaCost;
|
import forge.card.SpellManaCost;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
|
import forge.card.ability.ApiType;
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
import forge.card.cardfactory.CardFactoryUtil;
|
||||||
import forge.card.cost.Cost;
|
import forge.card.cost.Cost;
|
||||||
import forge.card.cost.CostPayment;
|
import forge.card.cost.CostPayment;
|
||||||
@@ -128,7 +132,13 @@ public class ComputerUtilMana {
|
|||||||
m.setExpressChoice(colorChoice);
|
m.setExpressChoice(colorChoice);
|
||||||
colorChoice = ComputerUtilMana.getComboManaChoice(ai, ma, sa, cost);
|
colorChoice = ComputerUtilMana.getComboManaChoice(ai, ma, sa, cost);
|
||||||
m.setExpressChoice(colorChoice);
|
m.setExpressChoice(colorChoice);
|
||||||
}
|
} else if (ma.getApi().equals(ApiType.ManaReflected)) {
|
||||||
|
if (CardUtil.getReflectableManaColors(ma, ma, new HashSet<String>(), new ArrayList<Card>()).contains(MagicColor.toLongString(costParts[nPart]))) {
|
||||||
|
m.setExpressChoice(costParts[nPart]);
|
||||||
|
} else {
|
||||||
|
m.setExpressChoice("0");
|
||||||
|
}
|
||||||
|
}
|
||||||
// check if ability produces any color
|
// check if ability produces any color
|
||||||
else if (m.isAnyMana()) {
|
else if (m.isAnyMana()) {
|
||||||
String colorChoice = costParts[nPart];
|
String colorChoice = costParts[nPart];
|
||||||
@@ -602,19 +612,24 @@ public class ComputerUtilMana {
|
|||||||
colorlessSources.add(m);
|
colorlessSources.add(m);
|
||||||
|
|
||||||
// find possible colors
|
// find possible colors
|
||||||
if (m.getManaPart().canProduce("W")) {
|
if (m.getManaPart().canProduce("W")
|
||||||
|
|| CardUtil.getReflectableManaColors(m, m, new HashSet<String>(), new ArrayList<Card>()).contains(Constant.Color.WHITE)) {
|
||||||
whiteSources.add(m);
|
whiteSources.add(m);
|
||||||
}
|
}
|
||||||
if (m.getManaPart().canProduce("U")) {
|
if (m.getManaPart().canProduce("U")
|
||||||
|
|| CardUtil.getReflectableManaColors(m, m, new HashSet<String>(), new ArrayList<Card>()).contains(Constant.Color.BLUE)) {
|
||||||
blueSources.add(m);
|
blueSources.add(m);
|
||||||
}
|
}
|
||||||
if (m.getManaPart().canProduce("B")) {
|
if (m.getManaPart().canProduce("B")
|
||||||
|
|| CardUtil.getReflectableManaColors(m, m, new HashSet<String>(), new ArrayList<Card>()).contains(Constant.Color.BLACK)) {
|
||||||
blackSources.add(m);
|
blackSources.add(m);
|
||||||
}
|
}
|
||||||
if (m.getManaPart().canProduce("R")) {
|
if (m.getManaPart().canProduce("R")
|
||||||
|
|| CardUtil.getReflectableManaColors(m, m, new HashSet<String>(), new ArrayList<Card>()).contains(Constant.Color.RED)) {
|
||||||
redSources.add(m);
|
redSources.add(m);
|
||||||
}
|
}
|
||||||
if (m.getManaPart().canProduce("G")) {
|
if (m.getManaPart().canProduce("G")
|
||||||
|
|| CardUtil.getReflectableManaColors(m, m, new HashSet<String>(), new ArrayList<Card>()).contains(Constant.Color.GREEN)) {
|
||||||
greenSources.add(m);
|
greenSources.add(m);
|
||||||
}
|
}
|
||||||
if (m.getManaPart().isSnow()) {
|
if (m.getManaPart().isSnow()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user