forked from External/mage
* Manor Gargoyle - Fixed that the lose of defender ability did not stop it having indestructibility.
This commit is contained in:
parent
f9d88cfb24
commit
436c82d25a
5 changed files with 117 additions and 28 deletions
|
|
@ -29,6 +29,7 @@ package mage.abilities.effects;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
@ -71,7 +72,8 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
protected boolean affectedObjectsSet = false;
|
||||
protected List<MageObjectReference> affectedObjectList = new ArrayList<>();
|
||||
protected boolean temporary = false;
|
||||
protected EnumSet<DependencyType> dependencyTypes;
|
||||
protected EnumSet<DependencyType> dependencyTypes; // this effect has the dependencyTypes defined here
|
||||
protected DependencyType dependendToType; // this effect is dependent to this type
|
||||
/*
|
||||
A Characteristic Defining Ability (CDA) is an ability that defines a characteristic of a card or token.
|
||||
There are 3 specific rules that distinguish a CDA from other abilities.
|
||||
|
|
@ -91,6 +93,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
this.order = 0;
|
||||
this.effectType = EffectType.CONTINUOUS;
|
||||
this.dependencyTypes = EnumSet.noneOf(DependencyType.class);
|
||||
this.dependendToType = null;
|
||||
}
|
||||
|
||||
public ContinuousEffectImpl(Duration duration, Layer layer, SubLayer sublayer, Outcome outcome) {
|
||||
|
|
@ -188,12 +191,10 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
case PTChangingEffects_7:
|
||||
this.affectedObjectsSet = true;
|
||||
}
|
||||
} else {
|
||||
if (hasLayer(Layer.CopyEffects_1) || hasLayer(Layer.ControlChangingEffects_2) || hasLayer(Layer.TextChangingEffects_3)
|
||||
|| hasLayer(Layer.TypeChangingEffects_4) || hasLayer(Layer.ColorChangingEffects_5) || hasLayer(Layer.AbilityAddingRemovingEffects_6)
|
||||
|| hasLayer(Layer.PTChangingEffects_7)) {
|
||||
this.affectedObjectsSet = true;
|
||||
}
|
||||
} else if (hasLayer(Layer.CopyEffects_1) || hasLayer(Layer.ControlChangingEffects_2) || hasLayer(Layer.TextChangingEffects_3)
|
||||
|| hasLayer(Layer.TypeChangingEffects_4) || hasLayer(Layer.ColorChangingEffects_5) || hasLayer(Layer.AbilityAddingRemovingEffects_6)
|
||||
|| hasLayer(Layer.PTChangingEffects_7)) {
|
||||
this.affectedObjectsSet = true;
|
||||
}
|
||||
}
|
||||
startingTurn = game.getTurnNum();
|
||||
|
|
@ -275,6 +276,19 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
|
||||
@Override
|
||||
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
|
||||
if (dependendToType != null) {
|
||||
// the dependent classes needs to be an enclosed class for dependent check of continuous effects
|
||||
Set<UUID> dependentTo = null;
|
||||
for (ContinuousEffect effect : allEffectsInLayer) {
|
||||
if (effect.getDependencyTypes().contains(dependendToType)) {
|
||||
if (dependentTo == null) {
|
||||
dependentTo = new HashSet<>();
|
||||
}
|
||||
dependentTo.add(effect.getId());
|
||||
}
|
||||
}
|
||||
return dependentTo;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -283,4 +297,14 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
return dependencyTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDependencyType(DependencyType dependencyType) {
|
||||
dependencyTypes.add(dependencyType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDependedToType(DependencyType dependencyType) {
|
||||
dependendToType = dependencyType;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue