-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGame.java
More file actions
62 lines (55 loc) · 2.03 KB
/
Game.java
File metadata and controls
62 lines (55 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class Game {
public static final Tile[][] board = new Tile [8][8];
private static List<Piece> allPieces = new ArrayList<>();
public static void createBoard(){
for(int i=0;i<8;i++){
for(int j=0;j<8;j++){
char current_column = convertColumns.get(j);
board[i][j] = new Tile(i+1,current_column);
}
}
}
public static void place(Piece piece, Tile tile){
tile.setPiece(piece);
piece.setTile(tile);
allPieces.add(piece);
}
public static void createAndPlacePieces(){
Game.place(new Rook("black"),board[7][0]);
Game.place(new Knight("black"),board[7][1]);
Game.place(new Bishop("black"),board[7][2]);
Game.place(new Queen("black"),board[7][3]);
Game.place(new King("black"),board[7][4]);
Game.place(new Bishop("black"),board[7][5]);
Game.place(new Knight("black"),board[7][6]);
Game.place(new Rook("black"),board[7][7]);
Game.place(new Rook("white"),board[0][0]);
Game.place(new Knight("white"),board[0][1]);
Game.place(new Bishop("white"),board[0][2]);
Game.place(new Queen("white"),board[0][3]);
Game.place(new King("white"),board[0][4]);
Game.place(new Bishop("white"),board[0][5]);
Game.place(new Knight("white"),board[0][6]);
Game.place(new Rook("white"),board[0][7]);
for(int j=0;j<8;j++){
board[6][j].setPiece(new Pawn("black"));
}
for(int j=0;j<8;j++){
board[1][j].setPiece(new Pawn("white"));
}
for(int j=0;j<8;j++){
board[6][j].getPiece().setTile(board[6][j]);
}
for(int j=0;j<8;j++){
board[1][j].getPiece().setTile(board[1][j]);
}
}
static HashMap<Integer, Character> convertColumns = new HashMap<>(Map.of(
0,'A',1,'B',2,'C',3,'D',
4,'E',5,'F',6,'G',7,'H'
));
}