mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
CurrentCastSpells: dont use CardCollection on them
This commit is contained in:
@@ -700,7 +700,7 @@ public class AbilityUtils {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CardCollectionView list;
|
Iterable<Card> list;
|
||||||
if (calcX[0].startsWith("Sacrificed")) {
|
if (calcX[0].startsWith("Sacrificed")) {
|
||||||
list = sa.getRootAbility().getPaidList("Sacrificed");
|
list = sa.getRootAbility().getPaidList("Sacrificed");
|
||||||
}
|
}
|
||||||
@@ -737,17 +737,11 @@ public class AbilityUtils {
|
|||||||
}
|
}
|
||||||
else if (calcX[0].startsWith("TriggerRemembered")) {
|
else if (calcX[0].startsWith("TriggerRemembered")) {
|
||||||
final SpellAbility root = sa.getRootAbility();
|
final SpellAbility root = sa.getRootAbility();
|
||||||
CardCollection result = new CardCollection();
|
list = Iterables.filter(root.getTriggerRemembered(), Card.class);
|
||||||
for (Object o : root.getTriggerRemembered()) {
|
|
||||||
if (o instanceof Card) {
|
|
||||||
result.add((Card) o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
list = result;
|
|
||||||
}
|
}
|
||||||
else if (calcX[0].startsWith("TriggerObjects")) {
|
else if (calcX[0].startsWith("TriggerObjects")) {
|
||||||
final SpellAbility root = sa.getRootAbility();
|
final SpellAbility root = sa.getRootAbility();
|
||||||
list = (CardCollection) root.getTriggeringObject(AbilityKey.fromString(calcX[0].substring(14)));
|
list = Iterables.filter((Iterable<?>) root.getTriggeringObject(AbilityKey.fromString(calcX[0].substring(14))), Card.class);
|
||||||
}
|
}
|
||||||
else if (calcX[0].startsWith("Triggered")) {
|
else if (calcX[0].startsWith("Triggered")) {
|
||||||
final SpellAbility root = sa.getRootAbility();
|
final SpellAbility root = sa.getRootAbility();
|
||||||
|
|||||||
@@ -386,13 +386,7 @@ public class CardFactoryUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (s.startsWith("Valid")) {
|
if (s.startsWith("Valid")) {
|
||||||
final CardCollection cards = new CardCollection();
|
return CardFactoryUtil.handlePaid(Iterables.filter(objects, Card.class), s, source);
|
||||||
for (Object o : objects) {
|
|
||||||
if (o instanceof Card) {
|
|
||||||
cards.add((Card) o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return CardFactoryUtil.handlePaid(cards, s, source);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int n = s.startsWith("Amount") ? objects.size() : 0;
|
int n = s.startsWith("Amount") ? objects.size() : 0;
|
||||||
@@ -1836,7 +1830,7 @@ public class CardFactoryUtil {
|
|||||||
* a {@link forge.game.card.Card} object.
|
* a {@link forge.game.card.Card} object.
|
||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public static int handlePaid(final CardCollectionView paidList, final String string, final Card source) {
|
public static int handlePaid(final Iterable<Card> paidList, final String string, final Card source) {
|
||||||
if (paidList == null) {
|
if (paidList == null) {
|
||||||
if (string.contains(".")) {
|
if (string.contains(".")) {
|
||||||
final String[] splitString = string.split("\\.", 2);
|
final String[] splitString = string.split("\\.", 2);
|
||||||
@@ -1846,11 +1840,12 @@ public class CardFactoryUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (string.startsWith("Amount")) {
|
if (string.startsWith("Amount")) {
|
||||||
|
int size = Iterables.size(paidList);
|
||||||
if (string.contains(".")) {
|
if (string.contains(".")) {
|
||||||
final String[] splitString = string.split("\\.", 2);
|
final String[] splitString = string.split("\\.", 2);
|
||||||
return doXMath(paidList.size(), splitString[1], source);
|
return doXMath(size, splitString[1], source);
|
||||||
} else {
|
} else {
|
||||||
return paidList.size();
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1875,18 +1870,18 @@ public class CardFactoryUtil {
|
|||||||
|
|
||||||
final String[] splitString = string.split("/", 2);
|
final String[] splitString = string.split("/", 2);
|
||||||
String valid = splitString[0].substring(6);
|
String valid = splitString[0].substring(6);
|
||||||
final CardCollection list = CardLists.getValidCards(paidList, valid, source.getController(), source);
|
final List<Card> list = CardLists.getValidCardsAsList(paidList, valid, source.getController(), source);
|
||||||
return doXMath(list.size(), splitString.length > 1 ? splitString[1] : null, source);
|
return doXMath(list.size(), splitString.length > 1 ? splitString[1] : null, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
String filteredString = string;
|
String filteredString = string;
|
||||||
CardCollection filteredList = new CardCollection(paidList);
|
Iterable<Card> filteredList = paidList;
|
||||||
final String[] filter = filteredString.split("_");
|
final String[] filter = filteredString.split("_");
|
||||||
|
|
||||||
if (string.startsWith("FilterControlledBy")) {
|
if (string.startsWith("FilterControlledBy")) {
|
||||||
final String pString = filter[0].substring(18);
|
final String pString = filter[0].substring(18);
|
||||||
FCollectionView<Player> controllers = AbilityUtils.getDefinedPlayers(source, pString, null);
|
FCollectionView<Player> controllers = AbilityUtils.getDefinedPlayers(source, pString, null);
|
||||||
filteredList = CardLists.filterControlledBy(filteredList, controllers);
|
filteredList = CardLists.filterControlledByAsList(filteredList, controllers);
|
||||||
filteredString = TextUtil.fastReplace(filteredString, pString, "");
|
filteredString = TextUtil.fastReplace(filteredString, pString, "");
|
||||||
filteredString = TextUtil.fastReplace(filteredString, "FilterControlledBy_", "");
|
filteredString = TextUtil.fastReplace(filteredString, "FilterControlledBy_", "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -204,6 +204,14 @@ public class CardLists {
|
|||||||
return CardLists.filter(cardList, CardPredicates.isControlledByAnyOf(player));
|
return CardLists.filter(cardList, CardPredicates.isControlledByAnyOf(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<Card> filterControlledByAsList(Iterable<Card> cardList, Player player) {
|
||||||
|
return CardLists.filterAsList(cardList, CardPredicates.isController(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<Card> filterControlledByAsList(Iterable<Card> cardList, FCollectionView<Player> player) {
|
||||||
|
return CardLists.filterAsList(cardList, CardPredicates.isControlledByAnyOf(player));
|
||||||
|
}
|
||||||
|
|
||||||
public static CardCollection getValidCards(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source, SpellAbility spellAbility) {
|
public static CardCollection getValidCards(Iterable<Card> cardList, String[] restrictions, Player sourceController, Card source, SpellAbility spellAbility) {
|
||||||
return CardLists.filter(cardList, CardPredicates.restriction(restrictions, sourceController, source, spellAbility));
|
return CardLists.filter(cardList, CardPredicates.restriction(restrictions, sourceController, source, spellAbility));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -297,7 +297,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
runParams.put(AbilityKey.CastSA, si.getSpellAbility(true));
|
runParams.put(AbilityKey.CastSA, si.getSpellAbility(true));
|
||||||
runParams.put(AbilityKey.CastSACMC, si.getSpellAbility(true).getHostCard().getCMC());
|
runParams.put(AbilityKey.CastSACMC, si.getSpellAbility(true).getHostCard().getCMC());
|
||||||
runParams.put(AbilityKey.CurrentStormCount, thisTurnCast.size());
|
runParams.put(AbilityKey.CurrentStormCount, thisTurnCast.size());
|
||||||
runParams.put(AbilityKey.CurrentCastSpells, new CardCollection(thisTurnCast));
|
runParams.put(AbilityKey.CurrentCastSpells, Lists.newArrayList(thisTurnCast));
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.SpellAbilityCast, runParams, true);
|
game.getTriggerHandler().runTrigger(TriggerType.SpellAbilityCast, runParams, true);
|
||||||
|
|
||||||
// Run SpellCast triggers
|
// Run SpellCast triggers
|
||||||
|
|||||||
Reference in New Issue
Block a user