* Witchbane Orb - Fixed problem of concurrent modification.
*/
package mage.cards.w;
+import java.util.ArrayList;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
@@ -83,14 +84,18 @@ class WitchbaneOrbEffect extends OneShotEffect {
@Override
public boolean apply(Game game, Ability source) {
- Player player = game.getPlayer(source.getControllerId());
- if (player != null) {
- for (UUID attachmentId: player.getAttachments()) {
+ Player controller = game.getPlayer(source.getControllerId());
+ if (controller != null) {
+ ArrayList<Permanent> toDestroy = new ArrayList<>();
+ for (UUID attachmentId : controller.getAttachments()) {
Permanent attachment = game.getPermanent(attachmentId);
if (attachment != null && attachment.getSubtype(game).contains("Curse")) {
- attachment.destroy(source.getSourceId(), game, false);
+ toDestroy.add(attachment);
}
}
+ for (Permanent curse : toDestroy) {
+ curse.destroy(source.getSourceId(), game, false);
+ }
return true;
}
return false;
