From 060310aebc8195a6a8f1d8b0d7a5d47218e9b1b9 Mon Sep 17 00:00:00 2001 From: schrom01 Date: Fri, 3 Dec 2021 08:12:21 +0100 Subject: [PATCH] change in Main Method --- src/ch/zhaw/catan/Parser.java | 4 ++++ src/ch/zhaw/catan/Siedler.java | 20 ++++++++++---------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index 933532d..0632d9d 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -32,6 +32,10 @@ public class Parser { } } + public void displayWinnertext(Config.Faction winner){ + textTerminal.println(winner.name() + "won the game!"); + } + public HashMap gameStart(){ HashMap gameStartValues = new HashMap<>(); gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(2).withMaxVal(4).read("Number of players:")); diff --git a/src/ch/zhaw/catan/Siedler.java b/src/ch/zhaw/catan/Siedler.java index 5279482..df3fc8d 100644 --- a/src/ch/zhaw/catan/Siedler.java +++ b/src/ch/zhaw/catan/Siedler.java @@ -29,9 +29,15 @@ public class Siedler { parser.displayPlayerResourceStock(game.getCurruntPlayerResource()); switch (parser.getAction()) { case NEXTPLAYER: - game.switchToNextPlayer(); - diceThrown = false; - break; + Config.Faction winner = game.getWinner(); + if(winner == null) { + game.switchToNextPlayer(); + diceThrown = false; + break; + } else { + parser.displayWinnertext(winner); + running = false; + } case BUILDSETTLEMENT: parser.giveCoordinatesForStructures(Config.Structure.SETTLEMENT); game.buildSettlement(parser.getPoint()); @@ -53,18 +59,12 @@ public class Siedler { break; case QUIT: running = false; - //todo clone windows + //todo close window break; default: parser.errorMessage(); } } - - - - - - } private static void throwDice(SiedlerGame game, Parser parser) {