From 7c35968dfdcbc04348bcf594cfdc49e67eda68a3 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Fri, 15 Nov 2024 21:19:15 +0800 Subject: [PATCH] try to fix ConcurrentModificationException on FCollection -> addAll cause: tapped.addAll(tappedForMana) on AiCardMemory --- .../src/main/java/forge/ai/AiCardMemory.java | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/forge-ai/src/main/java/forge/ai/AiCardMemory.java b/forge-ai/src/main/java/forge/ai/AiCardMemory.java index 5bcfacb2ab3..c9963033c90 100644 --- a/forge-ai/src/main/java/forge/ai/AiCardMemory.java +++ b/forge-ai/src/main/java/forge/ai/AiCardMemory.java @@ -18,8 +18,8 @@ package forge.ai; -import java.util.HashSet; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import forge.game.card.Card; import forge.game.player.Player; @@ -79,21 +79,21 @@ public class AiCardMemory { private final Set memRevealedCards; public AiCardMemory() { - this.memMandatoryAttackers = new HashSet<>(); - this.memHeldManaSources = new HashSet<>(); - this.memHeldManaSourcesForCombat = new HashSet<>(); - this.memHeldManaSourcesForEnemyCombat = new HashSet<>(); - this.memAttachedThisTurn = new HashSet<>(); - this.memAnimatedThisTurn = new HashSet<>(); - this.memBouncedThisTurn = new HashSet<>(); - this.memActivatedThisTurn = new HashSet<>(); - this.memTrickAttackers = new HashSet<>(); - this.memChosenFogEffect = new HashSet<>(); - this.memMarkedToAvoidReentry = new HashSet<>(); - this.memHeldManaSourcesForNextSpell = new HashSet<>(); - this.memPaysTapCost = new HashSet<>(); - this.memPaysSacCost = new HashSet<>(); - this.memRevealedCards = new HashSet<>(); + this.memMandatoryAttackers = ConcurrentHashMap.newKeySet(); + this.memHeldManaSources = ConcurrentHashMap.newKeySet(); + this.memHeldManaSourcesForCombat = ConcurrentHashMap.newKeySet(); + this.memHeldManaSourcesForEnemyCombat = ConcurrentHashMap.newKeySet(); + this.memAttachedThisTurn = ConcurrentHashMap.newKeySet(); + this.memAnimatedThisTurn = ConcurrentHashMap.newKeySet(); + this.memBouncedThisTurn = ConcurrentHashMap.newKeySet(); + this.memActivatedThisTurn = ConcurrentHashMap.newKeySet(); + this.memTrickAttackers = ConcurrentHashMap.newKeySet(); + this.memChosenFogEffect = ConcurrentHashMap.newKeySet(); + this.memMarkedToAvoidReentry = ConcurrentHashMap.newKeySet(); + this.memHeldManaSourcesForNextSpell = ConcurrentHashMap.newKeySet(); + this.memPaysTapCost = ConcurrentHashMap.newKeySet(); + this.memPaysSacCost = ConcurrentHashMap.newKeySet(); + this.memRevealedCards = ConcurrentHashMap.newKeySet(); } private Set getMemorySet(MemorySet set) {