remove board from constructor

This commit is contained in:
2025-04-16 19:29:31 +02:00
parent bee5e613bb
commit 17ef882d44
5 changed files with 13 additions and 21 deletions

View File

@@ -5,14 +5,13 @@ package chess;
import chess.controller.CommandExecutor;
import chess.controller.commands.NewGameCommand;
import chess.model.ChessBoard;
import chess.model.Game;
import chess.simulator.PromoteTest;
import chess.view.consolerender.Console;
public class ConsoleMain {
public static void main(String[] args) {
Game game = new Game(new ChessBoard());
Game game = new Game();
CommandExecutor commandExecutor = new CommandExecutor(game);
PromoteTest promoteTest = new PromoteTest(commandExecutor);

View File

@@ -4,7 +4,6 @@ import chess.ai.DumbAI;
import chess.controller.CommandExecutor;
import chess.controller.commands.NewGameCommand;
import chess.controller.event.GameAdaptator;
import chess.model.ChessBoard;
import chess.model.Color;
import chess.model.Game;
import chess.pgn.PgnExport;
@@ -12,7 +11,7 @@ import chess.view.simplerender.Window;
public class SwingMain {
public static void main(String[] args) {
Game game = new Game(new ChessBoard());
Game game = new Game();
CommandExecutor commandExecutor = new CommandExecutor(game);
Window window = new Window(commandExecutor, false);

View File

@@ -20,8 +20,8 @@ public class Game {
Draw, Check, CheckMate, OnGoing, Pat;
}
public Game(ChessBoard board) {
this.board = board;
public Game() {
this.board = new ChessBoard();
this.movesHistory = new Stack<>();
this.traitsPos = new HashMap<>();
}

View File

@@ -11,7 +11,6 @@ import chess.controller.commands.MoveCommand;
import chess.controller.commands.NewGameCommand;
import chess.controller.commands.PromoteCommand;
import chess.controller.event.EmptyGameDispatcher;
import chess.model.ChessBoard;
import chess.model.Color;
import chess.model.Coordinate;
import chess.model.Game;
@@ -22,7 +21,7 @@ import chess.model.pieces.Pawn;
public class PgnExport {
// public static void main(String[] args) {
// final Game game = new Game(new ChessBoard());
// final Game game = new Game();
// final CommandExecutor commandExecutor = new CommandExecutor(game);
// DumbAI ai1 = new DumbAI(commandExecutor, Color.White);
@@ -190,8 +189,7 @@ public class PgnExport {
public static String exportGame(Game game) {
ChessBoard board = new ChessBoard();
Game virtualGame = new Game(board);
Game virtualGame = new Game();
CommandExecutor executor = new CommandExecutor(virtualGame, new EmptyGameDispatcher());
executor.executeCommand(new NewGameCommand());