* 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 {
@Override
public boolean apply(Game game, Ability source) {
SpellsCastWatcher watcher = (SpellsCastWatcher) game.getState().getWatchers().get(SpellsCastWatcher.class.getName());

View file

@ -962,9 +962,11 @@ public class ContinuousEffects implements Serializable {
for (ContinuousEffect effect : layer) {
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
for (Ability ability : abilities) {
if (abilityActive(ability, game)) {
effect.apply(Layer.PTChangingEffects_7, SubLayer.CharacteristicDefining_7a, ability, game);
}
}
}
for (ContinuousEffect effect : layer) {
HashSet<Ability> abilities = layeredEffects.getAbility(effect.getId());
for (Ability ability : abilities) {
@ -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) {
List<ContinuousEffect> layer = filterLayeredEffects(activeLayerEffects, currentLayer);
if (!layer.isEmpty()) {