* Added a check that continuous PT setting effects are only applied, if the object has still the ability (fixes #3167).

I added the effect now only to the layer the bug is caused by. Probably it's correct to check this for every layer. But I don't know how much resources the check addional needs. So if we got other tests that fail for this reason caused by other layers, we could add the check and test if all other tests still work correctly.
This commit is contained in:
LevelX2 2017-04-22 00:23:37 +02:00
parent da6b5cae53
commit a93dc4e3da
2 changed files with 10 additions and 2 deletions

View file

@ -78,6 +78,7 @@ public class SeekerOfInsight extends CardImpl {
} }
class CastNonCreatureSpellCondition implements Condition { class CastNonCreatureSpellCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName()); SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName());
@ -97,5 +98,5 @@ class CastNonCreatureSpellCondition implements Condition {
@Override @Override
public String toString() { public String toString() {
return "you've cast a noncreature spell this turn"; return "you've cast a noncreature spell this turn";
} }
} }

View file

@ -962,7 +962,9 @@ public class ContinuousEffects implements Serializable {
for (ContinuousEffect effect : layer) { for (ContinuousEffect effect : layer) {
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId()); HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
for (Ability ability : abilities) { for (Ability ability : abilities) {
effect.apply(Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, ability, game); if (abilityActive(ability, game)) {
effect.apply(Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, ability, game);
}
} }
} }
for (ContinuousEffect effect : layer) { for (ContinuousEffect effect : layer) {
@ -1002,6 +1004,11 @@ public class ContinuousEffects implements Serializable {
} }
} }
private boolean abilityActive(Ability ability, Game game) {
MageObject object = game.getObject(ability.getSourceId());
return object != null && object.hasAbility(ability.getId(), game);
}
private void applyLayer(List<ContinuousEffect> activeLayerEffects, Layer currentLayer, Game game) { private void applyLayer(List<ContinuousEffect> activeLayerEffects, Layer currentLayer, Game game) {
List<ContinuousEffect> layer = filterLayeredEffects(activeLayerEffects, currentLayer); List<ContinuousEffect> layer = filterLayeredEffects(activeLayerEffects, currentLayer);
if (!layer.isEmpty()) { if (!layer.isEmpty()) {