Skip to content

Commit 0c28479

Browse files
committed
use stream().distinct().noneMatch
1 parent 0737f46 commit 0c28479

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

forge-game/src/main/java/forge/game/combat/GlobalAttackRestrictions.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,17 @@ public boolean isLegal(final Map<Card, GameEntity> attackers) {
3232
return false;
3333
}
3434

35-
for (final GameEntity defender : attackers.values()) {
35+
return attackers.values().stream().distinct().noneMatch(defender -> {
3636
final Integer max = defenderMax.get(defender);
3737
if (max == null) {
38-
continue;
38+
return false;
3939
}
4040
if (max == 0) {
4141
// there's at least one creature attacking this defender
42-
return false;
43-
}
44-
if (attackers.values().stream().filter(attDef -> attDef == defender).count() > max) {
45-
return false;
42+
return true;
4643
}
47-
}
48-
49-
return true;
44+
return attackers.values().stream().filter(attDef -> attDef == defender).count() > max;
45+
});
5046
}
5147

5248
/**

0 commit comments

Comments
 (0)