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();
|
||||
if ((am.isBasic() || am.isReflectedMana()) && !res.contains(a)) {
|
||||
if (am.isBasic() && !res.contains(a)) {
|
||||
res.add(a);
|
||||
}
|
||||
|
||||
@@ -5973,7 +5973,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
*/
|
||||
public final boolean isReflectedLand() {
|
||||
for (final SpellAbility a : this.getCharacteristics().getManaAbility()) {
|
||||
if (a.getManaPart().isReflectedMana()) {
|
||||
if (a.getApi().equals(ApiType.ManaReflected)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import forge.card.CardCharacteristics;
|
||||
import forge.card.EditionInfo;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.spellability.AbilityManaPart;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
@@ -502,6 +503,10 @@ public final class CardUtil {
|
||||
// so we don't infinite recurse.
|
||||
final Card card = abMana.getSourceCard();
|
||||
|
||||
if (!abMana.getApi().equals(ApiType.ManaReflected)) {
|
||||
return colors;
|
||||
}
|
||||
|
||||
if (!parents.contains(card)) {
|
||||
parents.add(card);
|
||||
}
|
||||
@@ -577,7 +582,7 @@ public final class CardUtil {
|
||||
break;
|
||||
}
|
||||
|
||||
if (ab.getManaPart().isReflectedMana()) {
|
||||
if (ab.getApi().equals(ApiType.ManaReflected)) {
|
||||
if (!parents.contains(ab.getSourceCard())) {
|
||||
// Recursion!
|
||||
reflectAbilities.add(ab);
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ManaReflectedEffect extends SpellEffect {
|
||||
}
|
||||
} else {
|
||||
// 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 transient ArrayList<Mana> lastProduced = new ArrayList<Mana>();
|
||||
|
||||
/** The reflected. */
|
||||
private boolean reflected = false;
|
||||
|
||||
/** The canceled. */
|
||||
private boolean canceled = false;
|
||||
|
||||
@@ -220,18 +217,6 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
return this.getOrigProduced();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setReflectedMana.
|
||||
* </p>
|
||||
*
|
||||
* @param bReflect
|
||||
* a boolean.
|
||||
*/
|
||||
public final void setReflectedMana(final boolean bReflect) {
|
||||
this.reflected = bReflect;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* setAnyChoice.
|
||||
@@ -286,17 +271,6 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
return this.getSourceCard().isSnow();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isReflectedMana.
|
||||
* </p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean isReflectedMana() {
|
||||
return this.reflected;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* isAnyMana.
|
||||
|
||||
@@ -11,6 +11,7 @@ import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.mana.ManaPool;
|
||||
import forge.card.spellability.AbilityManaPart;
|
||||
@@ -68,7 +69,7 @@ public abstract class InputPayManaBase extends Input {
|
||||
if (m.isAnyMana()) {
|
||||
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>());
|
||||
for (final String color : reflectableColors) {
|
||||
if (mana.contains(MagicColor.toShortString(color))) {
|
||||
@@ -227,7 +228,7 @@ public abstract class InputPayManaBase extends Input {
|
||||
|
||||
for (final SpellAbility am : abilities) {
|
||||
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>());
|
||||
for (final String color : reflectableColors) {
|
||||
if (manaCost.isColor(color)) {
|
||||
|
||||
@@ -36,6 +36,7 @@ import forge.CardPredicates.Presets;
|
||||
import forge.card.SpellManaCost;
|
||||
import forge.card.ability.AbilityFactory;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostDamage;
|
||||
@@ -1532,6 +1533,9 @@ public final class GameActionUtil {
|
||||
baseMana = "Any";
|
||||
}
|
||||
}
|
||||
else if (sa.getApi().equals(ApiType.ManaReflected)) {
|
||||
baseMana = abMana.getExpressChoice();
|
||||
}
|
||||
else {
|
||||
baseMana = abMana.mana();
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package forge.game.ai;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -10,10 +11,13 @@ import com.google.common.base.Predicate;
|
||||
|
||||
import forge.Card;
|
||||
import forge.CardLists;
|
||||
import forge.CardUtil;
|
||||
import forge.Constant;
|
||||
import forge.Singletons;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.SpellManaCost;
|
||||
import forge.card.ability.AbilityUtils;
|
||||
import forge.card.ability.ApiType;
|
||||
import forge.card.cardfactory.CardFactoryUtil;
|
||||
import forge.card.cost.Cost;
|
||||
import forge.card.cost.CostPayment;
|
||||
@@ -128,6 +132,12 @@ public class ComputerUtilMana {
|
||||
m.setExpressChoice(colorChoice);
|
||||
colorChoice = ComputerUtilMana.getComboManaChoice(ai, ma, sa, cost);
|
||||
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
|
||||
else if (m.isAnyMana()) {
|
||||
@@ -602,19 +612,24 @@ public class ComputerUtilMana {
|
||||
colorlessSources.add(m);
|
||||
|
||||
// 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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
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);
|
||||
}
|
||||
if (m.getManaPart().isSnow()) {
|
||||
|
||||
Reference in New Issue
Block a user