mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 04:38:00 +00:00
*Added ManaSpent & ManaNotSpent restrictions to Triggers. Triggers with ManaSpent$ Green for instance will only go off if Green mana was spent to cast the host card.
*New AI SVar; "ManaNeededToAvoidNegativeEffect". This is a comma-separated list of colors the AI will try to use to pay for the cost, but only if it actually has a source for that color mana. *Added Plaxmanta.
This commit is contained in:
@@ -488,6 +488,9 @@ public class ComputerUtil {
|
||||
ArrayList<String> colors;
|
||||
|
||||
cost = ((ManaPool) manapool).subtractMana(sa, cost);
|
||||
if(card.getSVar("ManaNeededToAvoidNegativeEffect") != "") {
|
||||
cost.setManaNeededToAvoidNegativeEffect(card.getSVar("ManaNeededToAvoidNegativeEffect").split(","));
|
||||
}
|
||||
|
||||
CardList manaSources = getAvailableMana();
|
||||
|
||||
@@ -732,6 +735,8 @@ public class ComputerUtil {
|
||||
static public ArrayList<Ability_Mana> sortForNeeded(ManaCost cost, ArrayList<Ability_Mana> manaAbilities, Player player) {
|
||||
|
||||
ArrayList<String> colors;
|
||||
|
||||
ArrayList<String> colorsNeededToAvoidNegativeEffect = cost.getManaNeededToAvoidNegativeEffect();
|
||||
|
||||
ArrayList<Ability_Mana> res = new ArrayList<Ability_Mana>();
|
||||
|
||||
@@ -746,6 +751,12 @@ public class ComputerUtil {
|
||||
res.add(am);
|
||||
break;
|
||||
}
|
||||
for(String col : colorsNeededToAvoidNegativeEffect) {
|
||||
if(col.equalsIgnoreCase(colors.get(j))
|
||||
|| col.substring(0,1).equalsIgnoreCase(colors.get(j))) {
|
||||
res.add(am);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -759,6 +770,12 @@ public class ComputerUtil {
|
||||
res.add(am);
|
||||
break;
|
||||
}
|
||||
for(String col : colorsNeededToAvoidNegativeEffect) {
|
||||
if(col.equalsIgnoreCase(colors.get(j))
|
||||
|| col.substring(0,1).equalsIgnoreCase(colors.get(j))) {
|
||||
res.add(am);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@ public class ManaCost {
|
||||
private ArrayList<Object> manaPart;
|
||||
private HashMap<String, Integer> sunburstMap = new HashMap<String, Integer>();
|
||||
private int xcounter = 0;
|
||||
private ArrayList<String> manaNeededToAvoidNegativeEffect = new ArrayList<String>();
|
||||
private ArrayList<String> manaPaidToAvoidNegativeEffect = new ArrayList<String>();
|
||||
|
||||
//manaCost can be like "0", "3", "G", "GW", "10", "3 GW", "10 GW"
|
||||
//or "split hybrid mana" like "2/G 2/G", "2/B 2/B 2/B"
|
||||
@@ -63,11 +65,11 @@ public class ManaCost {
|
||||
public String getColorsPaid() {
|
||||
String s = "";
|
||||
for (String key: sunburstMap.keySet()) {
|
||||
if(key.equals("black")) s+= "B";
|
||||
if(key.equals("blue")) s+= "U";
|
||||
if(key.equals("green")) s+= "G";
|
||||
if(key.equals("red")) s+= "R";
|
||||
if(key.equals("white")) s+= "W";
|
||||
if(key.equalsIgnoreCase("black") || key.equalsIgnoreCase("B")) s+= "B";
|
||||
if(key.equalsIgnoreCase("blue") || key.equalsIgnoreCase("U")) s+= "U";
|
||||
if(key.equalsIgnoreCase("green") || key.equalsIgnoreCase("G")) s+= "G";
|
||||
if(key.equalsIgnoreCase("red") || key.equalsIgnoreCase("R")) s+= "R";
|
||||
if(key.equalsIgnoreCase("white") || key.equalsIgnoreCase("W")) s+= "W";
|
||||
}
|
||||
return s;
|
||||
}
|
||||
@@ -146,6 +148,14 @@ public class ManaCost {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isNeeded(String mana) {
|
||||
if(manaNeededToAvoidNegativeEffect.size() != 0) {
|
||||
for(String s : manaNeededToAvoidNegativeEffect) {
|
||||
if ((s.equalsIgnoreCase(mana) || s.substring(0,1).equalsIgnoreCase(mana))
|
||||
&& !manaPaidToAvoidNegativeEffect.contains(mana)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mana.length() > 1)
|
||||
mana = Input_PayManaCostUtil.getShortColorString(mana);
|
||||
Mana_Part m;
|
||||
@@ -203,6 +213,9 @@ public class ManaCost {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean payMana(String color) {
|
||||
if(manaNeededToAvoidNegativeEffect.contains(color) && !manaPaidToAvoidNegativeEffect.contains(color)) {
|
||||
manaPaidToAvoidNegativeEffect.add(color);
|
||||
}
|
||||
color = Input_PayManaCostUtil.getShortColorString(color);
|
||||
return addMana(color);
|
||||
}
|
||||
@@ -488,4 +501,14 @@ public class ManaCost {
|
||||
manaPart.remove(manaPart.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public void setManaNeededToAvoidNegativeEffect(String[] manaCol) {
|
||||
for(String s : manaCol) {
|
||||
manaNeededToAvoidNegativeEffect.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<String> getManaNeededToAvoidNegativeEffect() {
|
||||
return manaNeededToAvoidNegativeEffect;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -431,6 +431,17 @@ public abstract class Trigger {
|
||||
}
|
||||
}
|
||||
|
||||
if(mapParams.containsKey("ManaSpent")) {
|
||||
if(!hostCard.getColorsPaid().contains(mapParams.get("ManaSpent"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(mapParams.containsKey("ManaNotSpent")) {
|
||||
if(hostCard.getColorsPaid().contains(mapParams.get("ManaNotSpent"))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user