CountersPutEffect: support "EachType" in "CounterTypes"

This commit is contained in:
Northmoc
2022-04-23 00:10:02 -04:00
parent 4d82e40534
commit 54a72999d1

View File

@@ -285,8 +285,25 @@ public class CountersPutEffect extends SpellAbilityEffect {
types = types.replace("ChosenFromList", ""); types = types.replace("ChosenFromList", "");
} }
for (String type : types.split(",")) { for (String type : types.split(",")) {
if (type.contains("EachType")) {
CardCollectionView counterCards =
CardLists.getValidCards(game.getCardsIn(ZoneType.Battlefield),
type.split("_")[1], card.getController(), card, sa);
List <CounterType> counterTypes = Lists.newArrayList();
for (Card c : counterCards) {
for (final Map.Entry<CounterType, Integer> map : c.getCounters().entrySet()) {
if (!counterTypes.contains(map.getKey())) {
counterTypes.add(map.getKey());
}
}
}
for (CounterType ct : counterTypes) {
resolvePerType(sa, placer, ct, counterAmount, table, false);
}
} else {
typesToAdd.add(CounterType.getType(type)); typesToAdd.add(CounterType.getType(type));
} }
}
for (CounterType ct : typesToAdd) { for (CounterType ct : typesToAdd) {
if (obj instanceof Player) { if (obj instanceof Player) {
((Player) obj).addCounter(ct, counterAmount, placer, table); ((Player) obj).addCounter(ct, counterAmount, placer, table);