Fix incomplete removal due to FCollection

This commit is contained in:
TRT
2023-04-28 09:26:53 +02:00
parent 1efb90c593
commit 1035592fb7
2 changed files with 13 additions and 2 deletions

View File

@@ -27,6 +27,7 @@ import forge.ai.ComputerUtil;
import forge.ai.ComputerUtilCard; import forge.ai.ComputerUtilCard;
import forge.ai.SpellAbilityAi; import forge.ai.SpellAbilityAi;
import forge.game.Game; import forge.game.Game;
import forge.game.ability.AbilityUtils;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.card.CardCollection; import forge.game.card.CardCollection;
import forge.game.card.CardCollectionView; import forge.game.card.CardCollectionView;
@@ -68,8 +69,6 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
private boolean doTgt(Player ai, SpellAbility sa, boolean mandatory) { private boolean doTgt(Player ai, SpellAbility sa, boolean mandatory) {
final Game game = ai.getGame(); final Game game = ai.getGame();
final int amount = Integer.valueOf(sa.getParam("CounterNum"));
// remove counter with Time might use Exile Zone too // remove counter with Time might use Exile Zone too
final TargetRestrictions tgt = sa.getTargetRestrictions(); final TargetRestrictions tgt = sa.getTargetRestrictions();
// need to targetable // need to targetable
@@ -82,6 +81,8 @@ public class CountersPutOrRemoveAi extends SpellAbilityAi {
// Filter AI-specific targets if provided // Filter AI-specific targets if provided
list = ComputerUtil.filterAITgts(sa, ai, list, false); list = ComputerUtil.filterAITgts(sa, ai, list, false);
final int amount = AbilityUtils.calculateAmount(sa.getHostCard(), sa.getParamOrDefault("CounterNum", "1"), sa);
if (sa.hasParam("CounterType")) { if (sa.hasParam("CounterType")) {
// currently only Jhoira's Timebug // currently only Jhoira's Timebug
final CounterType type = CounterType.getType(sa.getParam("CounterType")); final CounterType type = CounterType.getType(sa.getParam("CounterType"));

View File

@@ -11,6 +11,7 @@ import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.Set; import java.util.Set;
import java.util.function.Predicate;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
@@ -270,6 +271,15 @@ public class FCollection<T> implements List<T>, /*Set<T>,*/ FCollectionView<T>,
return false; return false;
} }
@Override
public boolean removeIf(Predicate<? super T> filter) {
if (list.removeIf(filter)) {
set.removeIf(filter);
return true;
}
return false;
}
/** /**
* {@inheritDoc} * {@inheritDoc}
*/ */