mirror of
https://github.com/magefree/mage.git
synced 2025-12-26 21:42:07 -08:00
[KHM] Implemented Skemfar Shadowsage
This commit is contained in:
parent
599cc2673c
commit
d515496b6e
4 changed files with 135 additions and 27 deletions
|
|
@ -0,0 +1,75 @@
|
|||
package mage.abilities.dynamicvalue.common;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.abilities.hint.Hint;
|
||||
import mage.abilities.hint.ValueHint;
|
||||
import mage.constants.SubType;
|
||||
import mage.constants.SubTypeSet;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public enum GreatestSharedCreatureTypeCount implements DynamicValue {
|
||||
instance;
|
||||
|
||||
private static final Hint hint = new ValueHint(
|
||||
"Greatest number of creatures you control that share a creature type", instance
|
||||
);
|
||||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
List<Permanent> permanentList = game.getBattlefield().getActivePermanents(
|
||||
StaticFilters.FILTER_CONTROLLED_CREATURE,
|
||||
sourceAbility.getControllerId(), sourceAbility.getSourceId(), game
|
||||
);
|
||||
permanentList.removeIf(Objects::isNull);
|
||||
int changelings = permanentList
|
||||
.stream()
|
||||
.filter(Objects::nonNull)
|
||||
.filter(MageObject::isAllCreatureTypes)
|
||||
.mapToInt(x -> 1)
|
||||
.sum();
|
||||
permanentList.removeIf(MageObject::isAllCreatureTypes);
|
||||
Map<SubType, Integer> typeMap = new HashMap<>();
|
||||
permanentList
|
||||
.stream()
|
||||
.map(permanent -> permanent.getSubtype(game))
|
||||
.flatMap(Collection::stream)
|
||||
.filter(subType -> subType.getSubTypeSet() == SubTypeSet.CreatureType)
|
||||
.forEach(subType -> typeMap.compute(subType, (s, i) -> i == null ? 1 : Integer.sum(i, 1)));
|
||||
return changelings
|
||||
+ typeMap
|
||||
.values()
|
||||
.stream()
|
||||
.mapToInt(x -> x)
|
||||
.max()
|
||||
.getAsInt();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GreatestSharedCreatureTypeCount copy() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "X";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage() {
|
||||
return "greatest number of creatures you control that have a creature type in common";
|
||||
}
|
||||
|
||||
public static Hint getHint() {
|
||||
return hint;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue