mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
forloop to stream
This commit is contained in:
parent
2fc742d77d
commit
83c3dc05b2
1 changed files with 5 additions and 18 deletions
|
@ -30,6 +30,8 @@ package mage.abilities.effects;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import mage.MageObject;
|
import mage.MageObject;
|
||||||
import mage.abilities.*;
|
import mage.abilities.*;
|
||||||
import mage.abilities.keyword.SpliceOntoArcaneAbility;
|
import mage.abilities.keyword.SpliceOntoArcaneAbility;
|
||||||
|
@ -83,7 +85,6 @@ public class ContinuousEffects implements Serializable {
|
||||||
// note all effect/abilities that were only added temporary
|
// note all effect/abilities that were only added temporary
|
||||||
private final Map<ContinuousEffect, Set<Ability>> temporaryEffects = new HashMap<>();
|
private final Map<ContinuousEffect, Set<Ability>> temporaryEffects = new HashMap<>();
|
||||||
|
|
||||||
private final ContinuousEffectSorter sorter = new ContinuousEffectSorter();
|
|
||||||
|
|
||||||
public ContinuousEffects() {
|
public ContinuousEffects() {
|
||||||
applyCounters = new ApplyCountersEffect();
|
applyCounters = new ApplyCountersEffect();
|
||||||
|
@ -211,7 +212,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
|
|
||||||
updateTimestamps(layerEffects);
|
updateTimestamps(layerEffects);
|
||||||
|
|
||||||
layerEffects.sort(sorter);
|
Collections.sort(layerEffects, Comparator.comparingLong(ContinuousEffect::getOrder));
|
||||||
return layerEffects;
|
return layerEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,13 +241,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<ContinuousEffect> filterLayeredEffects(List<ContinuousEffect> effects, Layer layer) {
|
private List<ContinuousEffect> filterLayeredEffects(List<ContinuousEffect> effects, Layer layer) {
|
||||||
List<ContinuousEffect> layerEffects = new ArrayList<>();
|
return effects.stream().filter(effect->effect.hasLayer(layer)).collect(Collectors.toList());
|
||||||
for (ContinuousEffect effect : effects) {
|
|
||||||
if (effect.hasLayer(layer)) {
|
|
||||||
layerEffects.add(effect);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return layerEffects;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<RequirementEffect, HashSet<Ability>> getApplicableRequirementEffects(Permanent permanent, Game game) {
|
public HashMap<RequirementEffect, HashSet<Ability>> getApplicableRequirementEffects(Permanent permanent, Game game) {
|
||||||
|
@ -554,7 +549,7 @@ public class ContinuousEffects implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Filters out asThough effects that are not active.
|
* Filters out asThough effects that are not active.
|
||||||
*
|
*
|
||||||
* @param AsThoughEffectType type
|
* @param type type
|
||||||
* @param game
|
* @param game
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -1266,11 +1261,3 @@ public class ContinuousEffects implements Serializable {
|
||||||
return controllerFound;
|
return controllerFound;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ContinuousEffectSorter implements Comparator<ContinuousEffect>, Serializable {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int compare(ContinuousEffect one, ContinuousEffect two) {
|
|
||||||
return Long.compare(one.getOrder(), two.getOrder());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue