From 2730491a5f8cd1408b7be74ec51c456c78219dbd Mon Sep 17 00:00:00 2001 From: Nick Stolbov Date: Mon, 31 Jan 2022 23:35:17 +0100 Subject: [PATCH] Added resetGame for resetting whole game --- src/main/java/Game/Chess.java | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/main/java/Game/Chess.java b/src/main/java/Game/Chess.java index 52c88cb..19d2a24 100644 --- a/src/main/java/Game/Chess.java +++ b/src/main/java/Game/Chess.java @@ -21,11 +21,7 @@ public class Chess extends Game { } private void init() { - chessBoard = new ChessBoard(); - currentTeam = ChessFigure.Team.WHITE; - destroyedWhiteFigures = new ArrayList<>(); - destroyedBlackFigures = new ArrayList<>(); - outputBuffer.addAll(chessBoard.getOutputBoard()); + resetGame(); } @Override @@ -33,6 +29,19 @@ public class Chess extends Game { } + private ArrayList getHeader() { + ArrayList header = new ArrayList<>(); + + header.add("Welcome to the good old game Chess!"); + header.add("First select one cell like: 'e7', than confirm it with an enter."); + header.add("After that, select a second cell and also confirm it with an enter."); + header.add("The Goal is to defeat the other teams King(K)."); + header.add(""); + header.add("It's your Turn " + currentTeam.name().toLowerCase() + "."); + + return header; + } + //int[0] = x, int[1] = y; public int[] convertInput(String input) { int[] temp = new int[2]; @@ -149,6 +158,17 @@ public class Chess extends Game { return result; } + public void resetGame() { + chessBoard = new ChessBoard(); + firstTurn = null; + currentTeam = ChessFigure.Team.WHITE; + destroyedWhiteFigures = new ArrayList<>(); + destroyedBlackFigures = new ArrayList<>(); + outputBuffer.clear(); + outputBuffer.addAll(getHeader()); + outputBuffer.addAll(chessBoard.getOutputBoard()); + } + public ChessBoard getChessBoard() { return this.chessBoard; }