Improved package structure
- Renamed the piece package into board - Moved Board, Move and Position into the board package
This commit is contained in:
parent
3edcae660b
commit
cf41840c5a
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>Bishop.java</strong><br>
|
@ -1,22 +1,15 @@
|
||||
package dev.kske.chess;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import dev.kske.chess.board.Piece.Color;
|
||||
import dev.kske.chess.board.Piece.Type;
|
||||
import dev.kske.chess.event.GameEvent;
|
||||
import dev.kske.chess.event.GameEvent.GameEventType;
|
||||
import dev.kske.chess.event.GameEventListener;
|
||||
import dev.kske.chess.piece.Bishop;
|
||||
import dev.kske.chess.piece.King;
|
||||
import dev.kske.chess.piece.Knight;
|
||||
import dev.kske.chess.piece.Pawn;
|
||||
import dev.kske.chess.piece.Piece;
|
||||
import dev.kske.chess.piece.Piece.Color;
|
||||
import dev.kske.chess.piece.Piece.Type;
|
||||
import dev.kske.chess.piece.Queen;
|
||||
import dev.kske.chess.piece.Rook;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
@ -146,30 +139,6 @@ public class Board {
|
||||
gameEventListeners.forEach(listener -> listener.onGameEvent(evt));
|
||||
}
|
||||
|
||||
public Piece get(Position pos) {
|
||||
return boardArr[pos.x][pos.y];
|
||||
}
|
||||
|
||||
public void set(Position pos, Piece piece) {
|
||||
boardArr[pos.x][pos.y] = piece;
|
||||
}
|
||||
|
||||
public Piece getPos(Move move) {
|
||||
return get(move.pos);
|
||||
}
|
||||
|
||||
public Piece getDest(Move move) {
|
||||
return get(move.dest);
|
||||
}
|
||||
|
||||
public void setPos(Move move, Piece piece) {
|
||||
set(move.pos, piece);
|
||||
}
|
||||
|
||||
public void setDest(Move move, Piece piece) {
|
||||
set(move.dest, piece);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialized the board array with the default chess pieces and positions.
|
||||
*/
|
||||
@ -216,6 +185,30 @@ public class Board {
|
||||
boardArr[i][j] = null;
|
||||
}
|
||||
|
||||
public Piece get(Position pos) {
|
||||
return boardArr[pos.x][pos.y];
|
||||
}
|
||||
|
||||
public void set(Position pos, Piece piece) {
|
||||
boardArr[pos.x][pos.y] = piece;
|
||||
}
|
||||
|
||||
public Piece getPos(Move move) {
|
||||
return get(move.pos);
|
||||
}
|
||||
|
||||
public Piece getDest(Move move) {
|
||||
return get(move.dest);
|
||||
}
|
||||
|
||||
public void setPos(Move move, Piece piece) {
|
||||
set(move.pos, piece);
|
||||
}
|
||||
|
||||
public void setDest(Move move, Piece piece) {
|
||||
set(move.dest, piece);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return The board array
|
||||
*/
|
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>King.java</strong><br>
|
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>Knight.java</strong><br>
|
@ -1,4 +1,4 @@
|
||||
package dev.kske.chess;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>Pawn.java</strong><br>
|
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>Piece.java</strong><br>
|
@ -1,4 +1,4 @@
|
||||
package dev.kske.chess;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>Queen.java</strong><br>
|
@ -1,12 +1,8 @@
|
||||
package dev.kske.chess.piece;
|
||||
package dev.kske.chess.board;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
* File: <strong>Rook.java</strong><br>
|
@ -2,8 +2,8 @@ package dev.kske.chess.event;
|
||||
|
||||
import java.util.EventObject;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.piece.Piece.Color;
|
||||
import dev.kske.chess.board.Board;
|
||||
import dev.kske.chess.board.Piece.Color;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
|
@ -13,9 +13,9 @@ import java.util.List;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.Move;
|
||||
import dev.kske.chess.Position;
|
||||
import dev.kske.chess.board.Board;
|
||||
import dev.kske.chess.board.Move;
|
||||
import dev.kske.chess.board.Position;
|
||||
import dev.kske.chess.event.GameEvent;
|
||||
import dev.kske.chess.event.GameEventListener;
|
||||
|
||||
|
@ -7,7 +7,7 @@ import javax.swing.JButton;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
|
||||
import dev.kske.chess.Board;
|
||||
import dev.kske.chess.board.Board;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -9,7 +9,7 @@ import java.util.Map;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
|
||||
import dev.kske.chess.piece.Piece;
|
||||
import dev.kske.chess.board.Piece;
|
||||
|
||||
/**
|
||||
* Project: <strong>Chess</strong><br>
|
||||
|
Reference in New Issue
Block a user