mirror of
https://github.com/correl/mage.git
synced 2025-01-11 19:13:02 +00:00
* Witchbane Orb - Fixed problem of concurrent modification.
This commit is contained in:
parent
1d438060fc
commit
44e15fb705
1 changed files with 10 additions and 5 deletions
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.cards.w;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
|
||||
|
@ -50,7 +51,7 @@ import mage.players.Player;
|
|||
public class WitchbaneOrb extends CardImpl {
|
||||
|
||||
public WitchbaneOrb(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{4}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{4}");
|
||||
|
||||
// When Witchbane Orb enters the battlefield, destroy all Curses attached to you.
|
||||
this.addAbility(new EntersBattlefieldTriggeredAbility(new WitchbaneOrbEffect()));
|
||||
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue