mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Some fixes to prevent concurrent modification errors on public server.
This commit is contained in:
parent
fb819f1f51
commit
e1541ece20
3 changed files with 16 additions and 9 deletions
|
@ -51,6 +51,7 @@ import mage.target.Target;
|
|||
import mage.target.common.TargetControlledPermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
import mage.util.CardUtil;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -66,10 +67,12 @@ public class AwakenAbility extends SpellAbility {
|
|||
public AwakenAbility(Card card, int awakenValue, String awakenCosts) {
|
||||
super(new ManaCostsImpl<>(awakenCosts), card.getName() + " with awaken", Zone.HAND, SpellAbilityType.BASE_ALTERNATE);
|
||||
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices());
|
||||
this.getWatchers().addAll(card.getSpellAbility().getWatchers());
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||
for (Watcher watcher : card.getSpellAbility().getWatchers()) {
|
||||
this.getWatchers().add(watcher.copy());
|
||||
}
|
||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||
this.timing = card.getSpellAbility().getTiming();
|
||||
this.addTarget(new TargetControlledPermanent(new FilterControlledLandPermanent(filterMessage)));
|
||||
|
|
|
@ -34,6 +34,7 @@ import mage.constants.SpellAbilityType;
|
|||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterLandCard;
|
||||
import mage.target.common.TargetCardInHand;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -45,10 +46,12 @@ public class RetraceAbility extends SpellAbility {
|
|||
super(card.getManaCost(), card.getName() + " with retrace", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE);
|
||||
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
||||
this.addCost(new DiscardTargetCost(new TargetCardInHand(new FilterLandCard())));
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices());
|
||||
this.getWatchers().addAll(card.getSpellAbility().getWatchers());
|
||||
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||
for (Watcher watcher : card.getSpellAbility().getWatchers()) {
|
||||
this.getWatchers().add(watcher.copy());
|
||||
}
|
||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||
this.timing = card.getSpellAbility().getTiming();
|
||||
|
||||
|
|
|
@ -742,7 +742,8 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
// TODO: add sources for triggers - the same way as in addEffect: sources
|
||||
this.triggers.add((TriggeredAbility) ability, sourceId, attachedTo);
|
||||
}
|
||||
for (Watcher watcher : ability.getWatchers()) {
|
||||
List<Watcher> watcherList = new ArrayList<>(ability.getWatchers()); // Workaround to prevent ConcurrentModificationException, not clear to me why this is happening now
|
||||
for (Watcher watcher : watcherList) {
|
||||
// TODO: Check that watcher for commanderAbility (where attachedTo = null) also work correctly
|
||||
watcher.setControllerId(attachedTo == null ? ability.getControllerId() : attachedTo.getOwnerId());
|
||||
watcher.setSourceId(attachedTo == null ? ability.getSourceId() : attachedTo.getId());
|
||||
|
|
Loading…
Reference in a new issue