mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 04:52:07 -08:00
* Kormus Bell - Fixed a bug with order land type changing effects are applied (fixes #3470).
This commit is contained in:
parent
4e8026fe59
commit
b9dff66fcb
8 changed files with 136 additions and 34 deletions
|
|
@ -1,5 +1,6 @@
|
|||
package mage.abilities.decorator;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
@ -10,6 +11,7 @@ import mage.abilities.condition.FixedCondition;
|
|||
import mage.abilities.condition.LockedInCondition;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.constants.DependencyType;
|
||||
import mage.constants.Duration;
|
||||
import mage.constants.Layer;
|
||||
import mage.constants.SubLayer;
|
||||
|
|
@ -137,6 +139,14 @@ public class ConditionalContinuousEffect extends ContinuousEffectImpl {
|
|||
return new ConditionalContinuousEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumSet<DependencyType> getDependencyTypes() {
|
||||
if (effect != null) {
|
||||
return effect.getDependencyTypes();
|
||||
}
|
||||
return super.getDependencyTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
|
||||
if (effect != null) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.abilities.effects;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
|
@ -74,12 +75,14 @@ public interface ContinuousEffect extends Effect {
|
|||
|
||||
Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer);
|
||||
|
||||
Set<DependencyType> getDependencyTypes();
|
||||
EnumSet<DependencyType> getDependencyTypes();
|
||||
|
||||
void addDependencyType(DependencyType dependencyType);
|
||||
|
||||
void setDependedToType(DependencyType dependencyType);
|
||||
|
||||
void addDependedToType(DependencyType dependencyType);
|
||||
|
||||
@Override
|
||||
void newId();
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.MageSingleton;
|
||||
|
|
@ -66,7 +65,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
protected List<MageObjectReference> affectedObjectList = new ArrayList<>();
|
||||
protected boolean temporary = false;
|
||||
protected EnumSet<DependencyType> dependencyTypes; // this effect has the dependencyTypes defined here
|
||||
protected DependencyType dependendToType; // this effect is dependent to this type
|
||||
protected EnumSet<DependencyType> dependendToTypes; // this effect is dependent to this types
|
||||
/*
|
||||
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.
|
||||
|
|
@ -86,7 +85,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;
|
||||
this.dependendToTypes = EnumSet.noneOf(DependencyType.class);
|
||||
}
|
||||
|
||||
public ContinuousEffectImpl(Duration duration, Layer layer, SubLayer sublayer, Outcome outcome) {
|
||||
|
|
@ -109,7 +108,7 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
this.startingTurn = effect.startingTurn;
|
||||
this.startingControllerId = effect.startingControllerId;
|
||||
this.dependencyTypes = effect.dependencyTypes;
|
||||
this.dependendToType = effect.dependendToType;
|
||||
this.dependendToTypes = effect.dependendToTypes;
|
||||
this.characterDefining = effect.characterDefining;
|
||||
}
|
||||
|
||||
|
|
@ -271,14 +270,28 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
|
||||
@Override
|
||||
public Set<UUID> isDependentTo(List<ContinuousEffect> allEffectsInLayer) {
|
||||
if (dependendToType != null) {
|
||||
Set<UUID> dependentToEffects = new HashSet<UUID>();
|
||||
if (dependendToTypes != null) {
|
||||
for (ContinuousEffect effect : allEffectsInLayer) {
|
||||
if (!effect.getId().equals(this.getId())) {
|
||||
for (DependencyType dependencyType : effect.getDependencyTypes()) {
|
||||
if (dependendToTypes.contains(dependencyType)) {
|
||||
dependentToEffects.add(effect.getId());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return dependentToEffects;
|
||||
/*
|
||||
return allEffectsInLayer.stream()
|
||||
.filter(effect -> effect.getDependencyTypes().contains(dependendToType))
|
||||
.filter(effect -> effect.getDependencyTypes().contains(dependendToTypes))
|
||||
.map(Effect::getId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
}
|
||||
return new HashSet<>();
|
||||
return new HashSet<>();*/
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -293,7 +306,13 @@ public abstract class ContinuousEffectImpl extends EffectImpl implements Continu
|
|||
|
||||
@Override
|
||||
public void setDependedToType(DependencyType dependencyType) {
|
||||
dependendToType = dependencyType;
|
||||
dependendToTypes.clear();
|
||||
dependendToTypes.add(dependencyType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addDependedToType(DependencyType dependencyType) {
|
||||
dependendToTypes.add(dependencyType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue