From 2eebbbd4cec3b894507595de81e34f6ab3e22553 Mon Sep 17 00:00:00 2001 From: Dion Aliu Date: Thu, 3 Feb 2022 14:57:57 +0100 Subject: [PATCH] Added resetGame for resetting whole game --- src/main/java/Game/Chess.java | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/main/java/Game/Chess.java b/src/main/java/Game/Chess.java index 52c88cb..5c4e7e4 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,16 @@ public class Chess extends Game { return result; } + public void resetGame() { + chessBoard = new ChessBoard(); + 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; }