No static :)
This commit is contained in:
parent
7dc1378bbc
commit
2db80d8b31
|
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
|
||||
|
||||
public class AutoPlayer {
|
||||
private PieceCreation pc = new PieceCreation();
|
||||
private KingCheck kingCheck = new KingCheck();
|
||||
public int MAX_DEPTH;
|
||||
public AutoPlayer() {}
|
||||
|
|
@ -175,7 +176,7 @@ public class AutoPlayer {
|
|||
ArrayList<Piece> newRow = new ArrayList<>();
|
||||
for (Piece p : row) {
|
||||
if (p != null) {
|
||||
newRow.add(PieceCreation.createPiece(p.getX(), p.getY(), p.getType(), p.isWhite()));
|
||||
newRow.add(pc.createPiece(p.getX(), p.getY(), p.getType(), p.isWhite()));
|
||||
} else {
|
||||
newRow.add(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import java.util.LinkedList;
|
|||
import javax.swing.JOptionPane;
|
||||
|
||||
public class Board {
|
||||
private PieceCreation pc = new PieceCreation();
|
||||
private KingCheck kingCheck = new KingCheck();
|
||||
private SoundEffect soundEffect = new SoundEffect();
|
||||
private int width = 8;
|
||||
|
|
@ -59,7 +60,7 @@ public class Board {
|
|||
}
|
||||
|
||||
public void setPiece(int x, int y, PieceType type, boolean isWhite) {
|
||||
Piece piece = PieceCreation.createPiece(x,y,type,isWhite);
|
||||
Piece piece = pc.createPiece(x,y,type,isWhite);
|
||||
board.get(y).set(x, piece);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ public class BoardHistory {
|
|||
public int turnNumber;
|
||||
public boolean turnColor;
|
||||
public Move lastMove;
|
||||
private PieceCreation pc = new PieceCreation();
|
||||
public BoardHistory(ArrayList<ArrayList<Piece>> board, int turnNumber, boolean turnColor, Move lastMove) {
|
||||
this.board = deepCopyBoard(board);
|
||||
this.turnNumber = turnNumber;
|
||||
|
|
@ -21,7 +22,7 @@ public class BoardHistory {
|
|||
ArrayList<Piece> newRow = new ArrayList<>();
|
||||
for (Piece p : row) {
|
||||
if (p != null) {
|
||||
newRow.add(PieceCreation.createPiece(p.getX(), p.getY(), p.getType(), p.isWhite()));
|
||||
newRow.add(pc.createPiece(p.getX(), p.getY(), p.getType(), p.isWhite()));
|
||||
} else {
|
||||
newRow.add(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class FileBoard {
|
|||
public ArrayList<ArrayList<Piece>> board = new ArrayList<>();
|
||||
public int turnNumber;
|
||||
public boolean turnColor;
|
||||
private PieceCreation pc = new PieceCreation();
|
||||
public FileBoard(ArrayList<ArrayList<Piece>> board,int turnNumber, boolean turnColor) {
|
||||
this.board = board;
|
||||
this.turnColor = turnColor;
|
||||
|
|
@ -70,7 +71,7 @@ public class FileBoard {
|
|||
color = pieceChar.charAt(0);
|
||||
type = pieceChar.charAt(1);
|
||||
col = color == 'W';
|
||||
Piece piece = PieceCreation.createPiece(x,y,PieceType.fromSummary(type),col);
|
||||
Piece piece = pc.createPiece(x,y,PieceType.fromSummary(type),col);
|
||||
boardF.get(y).set(x, piece);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ public class KingCheck {
|
|||
private boolean opponentWasInCheck = false;
|
||||
private SoundEffect soundEffect = new SoundEffect();
|
||||
private boolean soundShouldPlay = true;
|
||||
private PieceCreation pc = new PieceCreation();
|
||||
public ArrayList<ArrayList<Boolean>> getLegalMoves(Piece piece, ArrayList<ArrayList<Piece>> board, Move lastMove) {
|
||||
ArrayList<ArrayList<Boolean>> rawMoves = piece.getPossibleMoves(board,lastMove);
|
||||
|
||||
|
|
@ -88,7 +89,7 @@ public class KingCheck {
|
|||
ArrayList<Piece> newRow = new ArrayList<>();
|
||||
for (Piece p : row) {
|
||||
if (p != null) {
|
||||
newRow.add(PieceCreation.createPiece(p.getX(), p.getY(), p.getType(), p.isWhite()));
|
||||
newRow.add(pc.createPiece(p.getX(), p.getY(), p.getType(), p.isWhite()));
|
||||
} else {
|
||||
newRow.add(null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,7 @@
|
|||
package backend;
|
||||
|
||||
public class PieceCreation {
|
||||
|
||||
public static Piece createPiece(int x, int y, PieceType type, boolean isWhite) {
|
||||
public Piece createPiece(int x, int y, PieceType type, boolean isWhite) {
|
||||
switch (type) {
|
||||
case Pawn: return new Pawn(x, y, isWhite);
|
||||
case Rook: return new Rook(x, y, isWhite);
|
||||
|
|
|
|||
Loading…
Reference in New Issue