mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
AbilityUtils: if filtering a ListByType check for other Compare like LT, LE, GT, GE too
it does optimize the calculating
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
package forge.game.ability;
|
package forge.game.ability;
|
||||||
|
|
||||||
import com.google.common.collect.Iterables;
|
import com.google.common.collect.Iterables;
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
@@ -783,12 +784,15 @@ public class AbilityUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String valid = type;
|
String valid = type;
|
||||||
int eqIndex = valid.indexOf("EQ");
|
|
||||||
if (eqIndex >= 0) {
|
for (String t : Lists.newArrayList("LT", "LE", "EQ", "GE", "GT", "NE")) {
|
||||||
char reference = valid.charAt(eqIndex + 2); // take whatever goes after EQ
|
int index = valid.indexOf(t);
|
||||||
if (Character.isLetter(reference)) {
|
if (index >= 0) {
|
||||||
String varName = valid.split(",")[0].split("EQ")[1].split("\\+")[0];
|
char reference = valid.charAt(index + 2); // take whatever goes after EQ
|
||||||
valid = valid.replace("EQ" + varName, "EQ" + Integer.toString(calculateAmount(source, varName, sa)));
|
if (Character.isLetter(reference)) {
|
||||||
|
String varName = valid.split(",")[0].split(t)[1].split("\\+")[0];
|
||||||
|
valid = valid.replace(t + varName, t + Integer.toString(calculateAmount(source, varName, sa)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sa.hasParam("AbilityCount")) { // replace specific string other than "EQ" cases
|
if (sa.hasParam("AbilityCount")) { // replace specific string other than "EQ" cases
|
||||||
|
|||||||
Reference in New Issue
Block a user