mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Fixed a bug that could cause endless loop of applying replacement/prevention effects (e.g. prevent effect of Hedron-Field Purists) locking the UI.
This commit is contained in:
parent
a1208f1a73
commit
b4894f5564
3 changed files with 12 additions and 4 deletions
|
@ -52,6 +52,7 @@ import mage.cards.CardsImpl;
|
|||
import mage.constants.AsThoughEffectType;
|
||||
import mage.constants.CostModificationType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.EffectType;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.SpellAbilityType;
|
||||
|
@ -717,7 +718,12 @@ public class ContinuousEffects implements Serializable {
|
|||
boolean onlyOne = false;
|
||||
if (rEffects.size() == 1) {
|
||||
ReplacementEffect effect = rEffects.keySet().iterator().next();
|
||||
HashSet<Ability> abilities = replacementEffects.getAbility(effect.getId());
|
||||
HashSet<Ability> abilities;
|
||||
if (effect.getEffectType().equals(EffectType.REPLACEMENT)) {
|
||||
abilities = replacementEffects.getAbility(effect.getId());
|
||||
} else {
|
||||
abilities = preventionEffects.getAbility(effect.getId());
|
||||
}
|
||||
if (abilities == null || abilities.size() == 1) {
|
||||
onlyOne = true;
|
||||
}
|
||||
|
@ -788,6 +794,7 @@ public class ContinuousEffects implements Serializable {
|
|||
}
|
||||
}
|
||||
// Must be called here for some effects to be able to work correctly
|
||||
// TODO: add info which effects that need
|
||||
game.applyEffects();
|
||||
} while (true);
|
||||
return caught;
|
||||
|
|
|
@ -119,7 +119,7 @@ public class GainAbilitySourceEffect extends ContinuousEffectImpl implements Sou
|
|||
permanent = game.getPermanent(source.getSourceId());
|
||||
}
|
||||
if (permanent != null) {
|
||||
permanent.addAbility(ability, source.getSourceId(), game);
|
||||
permanent.addAbility(ability, source.getSourceId(), game, false);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -424,11 +424,12 @@ public class GameState implements Serializable, Copyable<GameState> {
|
|||
}
|
||||
|
||||
public void addEffect(ContinuousEffect effect, UUID sourceId, Ability source) {
|
||||
if (sourceId == null)
|
||||
if (sourceId == null) {
|
||||
effects.addEffect(effect, source);
|
||||
else
|
||||
} else {
|
||||
effects.addEffect(effect, sourceId, source);
|
||||
}
|
||||
}
|
||||
|
||||
// public void addMessage(String message) {
|
||||
// this.messages.add(message);
|
||||
|
|
Loading…
Reference in a new issue