remove board from constructor
This commit is contained in:
@@ -5,14 +5,13 @@ package chess;
|
|||||||
|
|
||||||
import chess.controller.CommandExecutor;
|
import chess.controller.CommandExecutor;
|
||||||
import chess.controller.commands.NewGameCommand;
|
import chess.controller.commands.NewGameCommand;
|
||||||
import chess.model.ChessBoard;
|
|
||||||
import chess.model.Game;
|
import chess.model.Game;
|
||||||
import chess.simulator.PromoteTest;
|
import chess.simulator.PromoteTest;
|
||||||
import chess.view.consolerender.Console;
|
import chess.view.consolerender.Console;
|
||||||
|
|
||||||
public class ConsoleMain {
|
public class ConsoleMain {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Game game = new Game(new ChessBoard());
|
Game game = new Game();
|
||||||
CommandExecutor commandExecutor = new CommandExecutor(game);
|
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
PromoteTest promoteTest = new PromoteTest(commandExecutor);
|
PromoteTest promoteTest = new PromoteTest(commandExecutor);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import chess.ai.DumbAI;
|
|||||||
import chess.controller.CommandExecutor;
|
import chess.controller.CommandExecutor;
|
||||||
import chess.controller.commands.NewGameCommand;
|
import chess.controller.commands.NewGameCommand;
|
||||||
import chess.controller.event.GameAdaptator;
|
import chess.controller.event.GameAdaptator;
|
||||||
import chess.model.ChessBoard;
|
|
||||||
import chess.model.Color;
|
import chess.model.Color;
|
||||||
import chess.model.Game;
|
import chess.model.Game;
|
||||||
import chess.pgn.PgnExport;
|
import chess.pgn.PgnExport;
|
||||||
@@ -12,7 +11,7 @@ import chess.view.simplerender.Window;
|
|||||||
|
|
||||||
public class SwingMain {
|
public class SwingMain {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Game game = new Game(new ChessBoard());
|
Game game = new Game();
|
||||||
CommandExecutor commandExecutor = new CommandExecutor(game);
|
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
Window window = new Window(commandExecutor, false);
|
Window window = new Window(commandExecutor, false);
|
||||||
|
|||||||
@@ -20,8 +20,8 @@ public class Game {
|
|||||||
Draw, Check, CheckMate, OnGoing, Pat;
|
Draw, Check, CheckMate, OnGoing, Pat;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Game(ChessBoard board) {
|
public Game() {
|
||||||
this.board = board;
|
this.board = new ChessBoard();
|
||||||
this.movesHistory = new Stack<>();
|
this.movesHistory = new Stack<>();
|
||||||
this.traitsPos = new HashMap<>();
|
this.traitsPos = new HashMap<>();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import chess.controller.commands.MoveCommand;
|
|||||||
import chess.controller.commands.NewGameCommand;
|
import chess.controller.commands.NewGameCommand;
|
||||||
import chess.controller.commands.PromoteCommand;
|
import chess.controller.commands.PromoteCommand;
|
||||||
import chess.controller.event.EmptyGameDispatcher;
|
import chess.controller.event.EmptyGameDispatcher;
|
||||||
import chess.model.ChessBoard;
|
|
||||||
import chess.model.Color;
|
import chess.model.Color;
|
||||||
import chess.model.Coordinate;
|
import chess.model.Coordinate;
|
||||||
import chess.model.Game;
|
import chess.model.Game;
|
||||||
@@ -22,7 +21,7 @@ import chess.model.pieces.Pawn;
|
|||||||
public class PgnExport {
|
public class PgnExport {
|
||||||
|
|
||||||
// public static void main(String[] args) {
|
// public static void main(String[] args) {
|
||||||
// final Game game = new Game(new ChessBoard());
|
// final Game game = new Game();
|
||||||
// final CommandExecutor commandExecutor = new CommandExecutor(game);
|
// final CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
// DumbAI ai1 = new DumbAI(commandExecutor, Color.White);
|
// DumbAI ai1 = new DumbAI(commandExecutor, Color.White);
|
||||||
@@ -190,8 +189,7 @@ public class PgnExport {
|
|||||||
|
|
||||||
public static String exportGame(Game game) {
|
public static String exportGame(Game game) {
|
||||||
|
|
||||||
ChessBoard board = new ChessBoard();
|
Game virtualGame = new Game();
|
||||||
Game virtualGame = new Game(board);
|
|
||||||
|
|
||||||
CommandExecutor executor = new CommandExecutor(virtualGame, new EmptyGameDispatcher());
|
CommandExecutor executor = new CommandExecutor(virtualGame, new EmptyGameDispatcher());
|
||||||
executor.executeCommand(new NewGameCommand());
|
executor.executeCommand(new NewGameCommand());
|
||||||
|
|||||||
@@ -3,24 +3,20 @@
|
|||||||
*/
|
*/
|
||||||
package chess;
|
package chess;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import chess.ai.DumbAI;
|
import chess.ai.DumbAI;
|
||||||
import chess.controller.Command;
|
import chess.controller.Command;
|
||||||
import chess.controller.CommandExecutor;
|
import chess.controller.CommandExecutor;
|
||||||
import chess.controller.commands.NewGameCommand;
|
import chess.controller.commands.NewGameCommand;
|
||||||
import chess.controller.commands.UndoCommand;
|
import chess.controller.commands.UndoCommand;
|
||||||
import chess.controller.event.GameAdaptator;
|
import chess.controller.event.GameAdaptator;
|
||||||
import chess.model.*;
|
import chess.model.Color;
|
||||||
import chess.model.pieces.*;
|
import chess.model.Game;
|
||||||
import chess.simulator.Simulator;
|
|
||||||
import chess.view.simplerender.Window;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
class AppTest {
|
class AppTest {
|
||||||
@Test void functionalRollback(){
|
@Test void functionalRollback(){
|
||||||
Game game = new Game(new ChessBoard());
|
Game game = new Game();
|
||||||
CommandExecutor commandExecutor = new CommandExecutor(game);
|
CommandExecutor commandExecutor = new CommandExecutor(game);
|
||||||
|
|
||||||
DumbAI ai = new DumbAI(commandExecutor, Color.Black);
|
DumbAI ai = new DumbAI(commandExecutor, Color.Black);
|
||||||
@@ -38,9 +34,9 @@ class AppTest {
|
|||||||
result = commandExecutor.executeCommand(new UndoCommand());
|
result = commandExecutor.executeCommand(new UndoCommand());
|
||||||
} while (result != Command.CommandResult.NotAllowed);
|
} while (result != Command.CommandResult.NotAllowed);
|
||||||
|
|
||||||
Game initialGame = new Game(new ChessBoard());
|
Game initialGame = new Game();
|
||||||
CommandExecutor initialCommandExecutor = new CommandExecutor(initialGame);
|
CommandExecutor initialCommandExecutor = new CommandExecutor(initialGame);
|
||||||
commandExecutor.executeCommand(new NewGameCommand());
|
initialCommandExecutor.executeCommand(new NewGameCommand());
|
||||||
|
|
||||||
assert(game.getBoard().equals(initialGame.getBoard()));
|
assert(game.getBoard().equals(initialGame.getBoard()));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user