Cleanup xCount

This commit is contained in:
tool4EvEr
2021-05-19 20:03:17 +02:00
parent ac939de42f
commit f8adbcc252
2 changed files with 38 additions and 40 deletions

View File

@@ -1795,7 +1795,7 @@ public class AbilityUtils {
return doXMath(calculateAmount(c,sq[adamant ? 2 : 3], ctb), expr, c, ctb); return doXMath(calculateAmount(c,sq[adamant ? 2 : 3], ctb), expr, c, ctb);
} }
if (l[0].startsWith("LastStateBattlefield")) { if (sq[0].startsWith("LastStateBattlefield")) {
final String[] k = l[0].split(" "); final String[] k = l[0].split(" ");
CardCollectionView list = null; CardCollectionView list = null;
if (sa.getLastStateBattlefield() != null) { if (sa.getLastStateBattlefield() != null) {
@@ -1811,7 +1811,7 @@ public class AbilityUtils {
} }
} }
if (l[0].startsWith("LastStateGraveyard")) { if (sq[0].startsWith("LastStateGraveyard")) {
final String[] k = l[0].split(" "); final String[] k = l[0].split(" ");
CardCollectionView list = null; CardCollectionView list = null;
if (sa.getLastStateGraveyard() != null) { if (sa.getLastStateGraveyard() != null) {
@@ -1953,7 +1953,7 @@ public class AbilityUtils {
if (sq[0].startsWith("AltCost")) { if (sq[0].startsWith("AltCost")) {
return doXMath(calculateAmount(c, sq[c.isOptionalCostPaid(OptionalCost.AltCost) ? 1 : 2], ctb), expr, c, ctb); return doXMath(calculateAmount(c, sq[c.isOptionalCostPaid(OptionalCost.AltCost) ? 1 : 2], ctb), expr, c, ctb);
} }
if (l[0].equals("ColorsColorIdentity")) { if (sq[0].equals("ColorsColorIdentity")) {
return doXMath(c.getController().getCommanderColorID().countColors(), expr, c, ctb); return doXMath(c.getController().getCommanderColorID().countColors(), expr, c, ctb);
} }
@@ -2098,11 +2098,11 @@ public class AbilityUtils {
return doXMath(ce == null ? 0 : ce.getCMC(), expr, c, ctb); return doXMath(ce == null ? 0 : ce.getCMC(), expr, c, ctb);
} }
if (l[0].startsWith("RememberedSize")) { if (sq[0].startsWith("RememberedSize")) {
return doXMath(c.getRememberedCount(), expr, c, ctb); return doXMath(c.getRememberedCount(), expr, c, ctb);
} }
if (l[0].startsWith("RememberedNumber")) { if (sq[0].startsWith("RememberedNumber")) {
int num = 0; int num = 0;
for (final Object o : c.getRemembered()) { for (final Object o : c.getRemembered()) {
if (o instanceof Integer) { if (o instanceof Integer) {
@@ -2112,7 +2112,7 @@ public class AbilityUtils {
return doXMath(num, expr, c, ctb); return doXMath(num, expr, c, ctb);
} }
if (l[0].startsWith("RememberedWithSharedCardType")) { if (sq[0].startsWith("RememberedWithSharedCardType")) {
int maxNum = 1; int maxNum = 1;
for (final Object o : c.getRemembered()) { for (final Object o : c.getRemembered()) {
if (o instanceof Card) { if (o instanceof Card) {
@@ -2212,7 +2212,7 @@ public class AbilityUtils {
return doXMath(getCardTypesFromList(player.getCardsIn(ZoneType.listValueOf(sq[1]))), expr, c, ctb); return doXMath(getCardTypesFromList(player.getCardsIn(ZoneType.listValueOf(sq[1]))), expr, c, ctb);
} }
if (l[0].startsWith("CommanderCastFromCommandZone")) { if (sq[0].startsWith("CommanderCastFromCommandZone")) {
// only used by Opal Palace, and it does add the trigger to the card // only used by Opal Palace, and it does add the trigger to the card
return doXMath(player.getCommanderCast(c), expr, c, ctb); return doXMath(player.getCommanderCast(c), expr, c, ctb);
} }
@@ -2266,7 +2266,7 @@ public class AbilityUtils {
return doXMath(player.getMaxOpponentAssignedDamage(), expr, c, ctb); return doXMath(player.getMaxOpponentAssignedDamage(), expr, c, ctb);
} }
if (sq[0].contains("YourDamageSourcesThisTurn")) { if (sq[0].startsWith("YourDamageSourcesThisTurn")) {
Iterable<Card> allSrc = player.getAssignedDamageSources(); Iterable<Card> allSrc = player.getAssignedDamageSources();
String restriction = sq[0].split(" ")[1]; String restriction = sq[0].split(" ")[1];
return doXMath(CardLists.getValidCardCount(allSrc, restriction, player, c, ctb), expr, c, ctb); return doXMath(CardLists.getValidCardCount(allSrc, restriction, player, c, ctb), expr, c, ctb);
@@ -2276,7 +2276,7 @@ public class AbilityUtils {
return doXMath(player.getTurn(), expr, c, ctb); return doXMath(player.getTurn(), expr, c, ctb);
} }
if (sq[0].contains("OppTypesInGrave")) { if (sq[0].startsWith("OppTypesInGrave")) {
final PlayerCollection opponents = player.getOpponents(); final PlayerCollection opponents = player.getOpponents();
CardCollection oppCards = new CardCollection(); CardCollection oppCards = new CardCollection();
oppCards.addAll(opponents.getCardsIn(ZoneType.Graveyard)); oppCards.addAll(opponents.getCardsIn(ZoneType.Graveyard));
@@ -2290,7 +2290,7 @@ public class AbilityUtils {
return doXMath(cmc, expr, c, ctb); return doXMath(cmc, expr, c, ctb);
} }
if (l[0].contains("ColorsCtrl")) { if (sq[0].startsWith("ColorsCtrl")) {
final String restriction = l[0].substring(11); final String restriction = l[0].substring(11);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
final CardCollection list = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb); final CardCollection list = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb);
@@ -2302,19 +2302,19 @@ public class AbilityUtils {
} }
// Count$AttackersDeclared // Count$AttackersDeclared
if (sq[0].contains("AttackersDeclared")) { if (sq[0].startsWith("AttackersDeclared")) {
return doXMath(player.getAttackersDeclaredThisTurn(), expr, c, ctb); return doXMath(player.getAttackersDeclaredThisTurn(), expr, c, ctb);
} }
// Count$CardAttackedThisTurn <Valid> // Count$CardAttackedThisTurn <Valid>
if (sq[0].contains("CreaturesAttackedThisTurn")) { if (sq[0].startsWith("CreaturesAttackedThisTurn")) {
final String[] workingCopy = l[0].split(" ", 2); final String[] workingCopy = l[0].split(" ", 2);
final String validFilter = workingCopy[1]; final String validFilter = workingCopy[1];
return doXMath(CardLists.getValidCardCount(player.getCreaturesAttackedThisTurn(), validFilter, player, c, ctb), expr, c, ctb); return doXMath(CardLists.getValidCardCount(player.getCreaturesAttackedThisTurn(), validFilter, player, c, ctb), expr, c, ctb);
} }
// Manapool // Manapool
if (l[0].startsWith("ManaPool")) { if (sq[0].startsWith("ManaPool")) {
final String color = l[0].split(":")[1]; final String color = l[0].split(":")[1];
int v = 0; int v = 0;
if (color.equals("All")) { if (color.equals("All")) {
@@ -2339,7 +2339,7 @@ public class AbilityUtils {
} }
//SacrificedThisTurn <type> //SacrificedThisTurn <type>
if (l[0].startsWith("SacrificedThisTurn")) { if (sq[0].startsWith("SacrificedThisTurn")) {
CardCollectionView list = player.getSacrificedThisTurn(); CardCollectionView list = player.getSacrificedThisTurn();
if (l[0].contains(" ")) { if (l[0].contains(" ")) {
String[] lparts = l[0].split(" ", 2); String[] lparts = l[0].split(" ", 2);
@@ -2452,7 +2452,7 @@ public class AbilityUtils {
return doXMath(calculateAmount(c, sq[res.size() > 0 ? 1 : 2], ctb), expr, c, ctb); return doXMath(calculateAmount(c, sq[res.size() > 0 ? 1 : 2], ctb), expr, c, ctb);
} }
if (l[0].contains("CreatureType")) { if (sq[0].startsWith("CreatureType")) {
String[] sqparts = l[0].split(" ", 2); String[] sqparts = l[0].split(" ", 2);
final String[] rest = sqparts[1].split(","); final String[] rest = sqparts[1].split(",");
@@ -2472,7 +2472,7 @@ public class AbilityUtils {
} }
// Count$Chroma.<color name> // Count$Chroma.<color name>
if (sq[0].contains("Chroma")) { if (sq[0].startsWith("Chroma")) {
ZoneType sourceZone = sq[0].contains("ChromaInGrave") ? ZoneType.Graveyard : ZoneType.Battlefield; ZoneType sourceZone = sq[0].contains("ChromaInGrave") ? ZoneType.Graveyard : ZoneType.Battlefield;
final CardCollectionView cards; final CardCollectionView cards;
if (sq[0].contains("ChromaSource")) { // Runs Chroma for passed in Source card if (sq[0].contains("ChromaSource")) { // Runs Chroma for passed in Source card
@@ -2515,7 +2515,7 @@ public class AbilityUtils {
return doXMath(game.getStack().getSpellsCastThisTurn().size() - 1, expr, c, ctb); return doXMath(game.getStack().getSpellsCastThisTurn().size() - 1, expr, c, ctb);
} }
if (l[0].startsWith("RolledThisTurn")) { if (sq[0].startsWith("RolledThisTurn")) {
return game.getPhaseHandler().getPlanarDiceRolledthisTurn(); return game.getPhaseHandler().getPlanarDiceRolledthisTurn();
} }
@@ -2542,7 +2542,7 @@ public class AbilityUtils {
// Count$SumPower_valid // Count$SumPower_valid
if (l[0].contains("SumPower")) { if (sq[0].startsWith("SumPower")) {
final String[] restrictions = l[0].split("_"); final String[] restrictions = l[0].split("_");
final String[] rest = restrictions[1].split(","); final String[] rest = restrictions[1].split(",");
CardCollection filteredCards = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb); CardCollection filteredCards = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb);
@@ -2550,7 +2550,7 @@ public class AbilityUtils {
} }
// Count$SumCMC_valid // Count$SumCMC_valid
if (sq[0].contains("SumCMC")) { if (sq[0].startsWith("SumCMC")) {
ZoneType zone = ZoneType.Battlefield; ZoneType zone = ZoneType.Battlefield;
//graveyard support for Inferno Project (may need other zones or multi-zone in future) //graveyard support for Inferno Project (may need other zones or multi-zone in future)
if (sq[0].contains("Graveyard")) if (sq[0].contains("Graveyard"))
@@ -2566,7 +2566,7 @@ public class AbilityUtils {
// Count$TotalCounters.<counterType>_<valid> // Count$TotalCounters.<counterType>_<valid>
if (sq[0].contains("TotalCounters")) { if (sq[0].startsWith("TotalCounters")) {
final String[] restrictions = l[0].split("_"); final String[] restrictions = l[0].split("_");
final CounterType cType = CounterType.getType(restrictions[1]); final CounterType cType = CounterType.getType(restrictions[1]);
final String[] validFilter = restrictions[2].split(","); final String[] validFilter = restrictions[2].split(",");
@@ -2581,7 +2581,7 @@ public class AbilityUtils {
// Count$ThisTurnCast <Valid> // Count$ThisTurnCast <Valid>
// Count$LastTurnCast <Valid> // Count$LastTurnCast <Valid>
if (sq[0].contains("ThisTurnCast") || sq[0].contains("LastTurnCast")) { if (sq[0].startsWith("ThisTurnCast") || sq[0].startsWith("LastTurnCast")) {
final String[] workingCopy = l[0].split("_"); final String[] workingCopy = l[0].split("_");
final String validFilter = workingCopy[1]; final String validFilter = workingCopy[1];
@@ -2597,7 +2597,7 @@ public class AbilityUtils {
} }
// Count$ThisTurnEntered <ZoneDestination> [from <ZoneOrigin>] <Valid> // Count$ThisTurnEntered <ZoneDestination> [from <ZoneOrigin>] <Valid>
if (sq[0].contains("ThisTurnEntered")) { if (sq[0].startsWith("ThisTurnEntered")) {
final String[] workingCopy = l[0].split("_"); final String[] workingCopy = l[0].split("_");
ZoneType destination = ZoneType.smartValueOf(workingCopy[1]); ZoneType destination = ZoneType.smartValueOf(workingCopy[1]);
@@ -2613,7 +2613,7 @@ public class AbilityUtils {
} }
// Count$LastTurnEntered <ZoneDestination> [from <ZoneOrigin>] <Valid> // Count$LastTurnEntered <ZoneDestination> [from <ZoneOrigin>] <Valid>
if (sq[0].contains("LastTurnEntered")) { if (sq[0].startsWith("LastTurnEntered")) {
final String[] workingCopy = l[0].split("_"); final String[] workingCopy = l[0].split("_");
ZoneType destination = ZoneType.smartValueOf(workingCopy[1]); ZoneType destination = ZoneType.smartValueOf(workingCopy[1]);
@@ -2628,7 +2628,7 @@ public class AbilityUtils {
return doXMath(res.size(), expr, c, ctb); return doXMath(res.size(), expr, c, ctb);
} }
if (l[0].startsWith("CountersAddedThisTurn")) { if (sq[0].startsWith("CountersAddedThisTurn")) {
final String[] parts = l[0].split(" "); final String[] parts = l[0].split(" ");
CounterType cType = CounterType.getType(parts[1]); CounterType cType = CounterType.getType(parts[1]);
@@ -2636,7 +2636,7 @@ public class AbilityUtils {
} }
// count valid cards in any specified zone/s // count valid cards in any specified zone/s
if (l[0].startsWith("Valid")) { if (sq[0].startsWith("Valid")) {
String[] lparts = l[0].split(" ", 2); String[] lparts = l[0].split(" ", 2);
final CardCollectionView cardsInZones = lparts[0].length() > 5 final CardCollectionView cardsInZones = lparts[0].length() > 5
@@ -2646,7 +2646,7 @@ public class AbilityUtils {
return doXMath(CardLists.getValidCardCount(cardsInZones, lparts[1], player, c, ctb), expr, c, ctb); return doXMath(CardLists.getValidCardCount(cardsInZones, lparts[1], player, c, ctb), expr, c, ctb);
} }
if (l[0].startsWith("GreatestPower")) { if (sq[0].startsWith("GreatestPower")) {
final String[] lparts = l[0].split("_", 2); final String[] lparts = l[0].split("_", 2);
final String[] rest = lparts[1].split(","); final String[] rest = lparts[1].split(",");
final CardCollectionView cardsInZones = lparts[0].length() > 13 final CardCollectionView cardsInZones = lparts[0].length() > 13
@@ -2662,7 +2662,7 @@ public class AbilityUtils {
return highest; return highest;
} }
if (l[0].startsWith("GreatestToughness_")) { if (sq[0].startsWith("GreatestToughness_")) {
final String restriction = l[0].substring(18); final String restriction = l[0].substring(18);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb);
@@ -2675,7 +2675,7 @@ public class AbilityUtils {
return highest; return highest;
} }
if (l[0].startsWith("HighestCMC_")) { if (sq[0].startsWith("HighestCMC_")) {
final String restriction = l[0].substring(11); final String restriction = l[0].substring(11);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
CardCollection list = CardLists.getValidCards(game.getCardsInGame(), rest, player, c, ctb); CardCollection list = CardLists.getValidCards(game.getCardsInGame(), rest, player, c, ctb);
@@ -2689,7 +2689,7 @@ public class AbilityUtils {
return highest; return highest;
} }
if (l[0].startsWith("MostCardName")) { if (sq[0].startsWith("MostCardName")) {
String[] lparts = l[0].split(" ", 2); String[] lparts = l[0].split(" ", 2);
final String[] rest = lparts[1].split(","); final String[] rest = lparts[1].split(",");
@@ -2714,7 +2714,7 @@ public class AbilityUtils {
return max; return max;
} }
if (l[0].startsWith("DifferentCardNames_")) { if (sq[0].startsWith("DifferentCardNames_")) {
final List<String> crdname = Lists.newArrayList(); final List<String> crdname = Lists.newArrayList();
final String restriction = l[0].substring(19); final String restriction = l[0].substring(19);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
@@ -2729,7 +2729,7 @@ public class AbilityUtils {
return doXMath(crdname.size(), expr, c, ctb); return doXMath(crdname.size(), expr, c, ctb);
} }
if (l[0].startsWith("DifferentPower_")) { if (sq[0].startsWith("DifferentPower_")) {
final List<Integer> powers = Lists.newArrayList(); final List<Integer> powers = Lists.newArrayList();
final String restriction = l[0].substring(15); final String restriction = l[0].substring(15);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
@@ -2744,20 +2744,20 @@ public class AbilityUtils {
} }
if (l[0].startsWith("MostProminentCreatureType")) { if (sq[0].startsWith("MostProminentCreatureType")) {
String restriction = l[0].split(" ")[1]; String restriction = l[0].split(" ")[1];
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restriction, player, c, ctb); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restriction, player, c, ctb);
return doXMath(CardFactoryUtil.getMostProminentCreatureTypeSize(list), expr, c, ctb); return doXMath(CardFactoryUtil.getMostProminentCreatureTypeSize(list), expr, c, ctb);
} }
if (l[0].startsWith("SecondMostProminentColor")) { if (sq[0].startsWith("SecondMostProminentColor")) {
String restriction = l[0].split(" ")[1]; String restriction = l[0].split(" ")[1];
CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restriction, player, c, ctb); CardCollection list = CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield), restriction, player, c, ctb);
int[] colorSize = CardFactoryUtil.SortColorsFromList(list); int[] colorSize = CardFactoryUtil.SortColorsFromList(list);
return doXMath(colorSize[colorSize.length - 2], expr, c, ctb); return doXMath(colorSize[colorSize.length - 2], expr, c, ctb);
} }
if (l[0].contains("ColorsCtrl")) { if (sq[0].startsWith("ColorsCtrl")) {
final String restriction = l[0].substring(11); final String restriction = l[0].substring(11);
final String[] rest = restriction.split(","); final String[] rest = restriction.split(",");
final CardCollection list = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb); final CardCollection list = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield), rest, player, c, ctb);
@@ -2768,7 +2768,7 @@ public class AbilityUtils {
return doXMath(ColorSet.fromMask(n).countColors(), expr, c, ctb); return doXMath(ColorSet.fromMask(n).countColors(), expr, c, ctb);
} }
if (l[0].contains("CreatureType")) { if (sq[0].startsWith("CreatureType")) {
String[] sqparts = l[0].split(" ", 2); String[] sqparts = l[0].split(" ", 2);
final String[] rest = sqparts[1].split(","); final String[] rest = sqparts[1].split(",");
@@ -2789,7 +2789,7 @@ public class AbilityUtils {
CardCollectionView someCards = getCardListForXCount(c, player, sq, ctb); CardCollectionView someCards = getCardListForXCount(c, player, sq, ctb);
// 1/10 - Count$MaxCMCYouCtrl // 1/10 - Count$MaxCMCYouCtrl
if (sq[0].contains("MaxCMC")) { if (sq[0].startsWith("MaxCMC")) {
int mmc = Aggregates.max(someCards, CardPredicates.Accessors.fnGetCmc); int mmc = Aggregates.max(someCards, CardPredicates.Accessors.fnGetCmc);
return doXMath(mmc, expr, c, ctb); return doXMath(mmc, expr, c, ctb);
} }

View File

@@ -2,9 +2,7 @@ Name:Shared Animosity
ManaCost:2 R ManaCost:2 R
Types:Enchantment Types:Enchantment
T:Mode$ Attacks | ValidCard$ Creature.YouCtrl | TriggerZones$ Battlefield | Execute$ AnimosityPump | TriggerDescription$ Whenever a creature you control attacks, it gets +1/+0 until end of turn for each other attacking creature that shares a creature type with it. T:Mode$ Attacks | ValidCard$ Creature.YouCtrl | TriggerZones$ Battlefield | Execute$ AnimosityPump | TriggerDescription$ Whenever a creature you control attacks, it gets +1/+0 until end of turn for each other attacking creature that shares a creature type with it.
SVar:AnimosityPump:DB$ Pump | RememberObjects$ TriggeredAttacker | SubAbility$ AnimosityPump2 SVar:AnimosityPump:DB$ Pump | Defined$ TriggeredAttacker | NumAtt$ X
SVar:AnimosityPump2:DB$ Pump | Defined$ Remembered | NumAtt$ X | SubAbility$ DBCleanup SVar:X:Count$Valid Creature.attacking+NotTriggeredAttacker+sharesCreatureTypeWith TriggeredAttacker
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
SVar:X:Count$Valid Creature.attacking+IsNotRemembered+sharesCreatureTypeWith Remembered
AI:RemoveDeck:Random AI:RemoveDeck:Random
Oracle:Whenever a creature you control attacks, it gets +1/+0 until end of turn for each other attacking creature that shares a creature type with it. Oracle:Whenever a creature you control attacks, it gets +1/+0 until end of turn for each other attacking creature that shares a creature type with it.