mirror of
https://github.com/lov3b/Schack.git
synced 2025-01-18 21:00:11 +01:00
Stream
This commit is contained in:
parent
2bd8388488
commit
dd96c3e56c
@ -6,6 +6,7 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
public abstract class Piece {
|
||||
@ -178,7 +179,13 @@ public abstract class Piece {
|
||||
ArrayList<Point> attacks = new ArrayList<>();
|
||||
|
||||
// Fråga alla pjäser vart de kan gå/ta
|
||||
for (Piece[] pieceArr : pieces) {
|
||||
Arrays.stream(pieces).forEach(array -> {
|
||||
Arrays.stream(array).filter(piece -> piece != null && piece.isWhite() != this.isWhite()).forEach(piece -> {
|
||||
attacks.addAll(piece.validAttacks(pieces));
|
||||
});
|
||||
});
|
||||
|
||||
/* for (Piece[] pieceArr : pieces) {
|
||||
for (Piece piece : pieceArr) {
|
||||
// Ifall det är tomrum skippa
|
||||
if (piece == null) {
|
||||
@ -190,7 +197,7 @@ public abstract class Piece {
|
||||
// Lägg till alla attacker för mostståndaren
|
||||
attacks.addAll(piece.validAttacks(pieces));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
// Kollar ifall kungen står i schack just nu
|
||||
for (Point attack : attacks) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user