mirror of
https://github.com/correl/mage.git
synced 2025-03-17 01:06:26 -09: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.common.TargetControlledPermanent;
|
||||||
import mage.target.targetpointer.FixedTarget;
|
import mage.target.targetpointer.FixedTarget;
|
||||||
import mage.util.CardUtil;
|
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) {
|
public AwakenAbility(Card card, int awakenValue, String awakenCosts) {
|
||||||
super(new ManaCostsImpl<>(awakenCosts), card.getName() + " with awaken", Zone.HAND, SpellAbilityType.BASE_ALTERNATE);
|
super(new ManaCostsImpl<>(awakenCosts), card.getName() + " with awaken", Zone.HAND, SpellAbilityType.BASE_ALTERNATE);
|
||||||
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
||||||
this.getEffects().addAll(card.getSpellAbility().getEffects());
|
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||||
this.getTargets().addAll(card.getSpellAbility().getTargets());
|
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||||
this.getChoices().addAll(card.getSpellAbility().getChoices());
|
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||||
this.getWatchers().addAll(card.getSpellAbility().getWatchers());
|
for (Watcher watcher : card.getSpellAbility().getWatchers()) {
|
||||||
|
this.getWatchers().add(watcher.copy());
|
||||||
|
}
|
||||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||||
this.timing = card.getSpellAbility().getTiming();
|
this.timing = card.getSpellAbility().getTiming();
|
||||||
this.addTarget(new TargetControlledPermanent(new FilterControlledLandPermanent(filterMessage)));
|
this.addTarget(new TargetControlledPermanent(new FilterControlledLandPermanent(filterMessage)));
|
||||||
|
|
|
@ -34,6 +34,7 @@ import mage.constants.SpellAbilityType;
|
||||||
import mage.constants.Zone;
|
import mage.constants.Zone;
|
||||||
import mage.filter.common.FilterLandCard;
|
import mage.filter.common.FilterLandCard;
|
||||||
import mage.target.common.TargetCardInHand;
|
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);
|
super(card.getManaCost(), card.getName() + " with retrace", Zone.GRAVEYARD, SpellAbilityType.BASE_ALTERNATE);
|
||||||
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
this.getCosts().addAll(card.getSpellAbility().getCosts().copy());
|
||||||
this.addCost(new DiscardTargetCost(new TargetCardInHand(new FilterLandCard())));
|
this.addCost(new DiscardTargetCost(new TargetCardInHand(new FilterLandCard())));
|
||||||
this.getEffects().addAll(card.getSpellAbility().getEffects());
|
this.getEffects().addAll(card.getSpellAbility().getEffects().copy());
|
||||||
this.getTargets().addAll(card.getSpellAbility().getTargets());
|
this.getTargets().addAll(card.getSpellAbility().getTargets().copy());
|
||||||
this.getChoices().addAll(card.getSpellAbility().getChoices());
|
this.getChoices().addAll(card.getSpellAbility().getChoices().copy());
|
||||||
this.getWatchers().addAll(card.getSpellAbility().getWatchers());
|
for (Watcher watcher : card.getSpellAbility().getWatchers()) {
|
||||||
|
this.getWatchers().add(watcher.copy());
|
||||||
|
}
|
||||||
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
this.spellAbilityType = SpellAbilityType.BASE_ALTERNATE;
|
||||||
this.timing = card.getSpellAbility().getTiming();
|
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
|
// TODO: add sources for triggers - the same way as in addEffect: sources
|
||||||
this.triggers.add((TriggeredAbility) ability, sourceId, attachedTo);
|
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
|
// TODO: Check that watcher for commanderAbility (where attachedTo = null) also work correctly
|
||||||
watcher.setControllerId(attachedTo == null ? ability.getControllerId() : attachedTo.getOwnerId());
|
watcher.setControllerId(attachedTo == null ? ability.getControllerId() : attachedTo.getOwnerId());
|
||||||
watcher.setSourceId(attachedTo == null ? ability.getSourceId() : attachedTo.getId());
|
watcher.setSourceId(attachedTo == null ? ability.getSourceId() : attachedTo.getId());
|
||||||
|
|
Loading…
Add table
Reference in a new issue