From 3c67d62e42794dc7086498ee0825c2bcac8d6202 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Thu, 2 Dec 2021 15:15:39 +0100 Subject: [PATCH 1/3] Several new methods added in Parser class --- .idea/misc.xml | 2 +- src/ch/zhaw/catan/Command.java | 3 -- src/ch/zhaw/catan/Parser.java | 52 +++++++++++++++++++++++----------- src/ch/zhaw/catan/Siedler.java | 2 ++ 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 6bc01a8..c3dfb30 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,6 +1,6 @@ - + \ No newline at end of file diff --git a/src/ch/zhaw/catan/Command.java b/src/ch/zhaw/catan/Command.java index 6abf2b5..d8157dc 100644 --- a/src/ch/zhaw/catan/Command.java +++ b/src/ch/zhaw/catan/Command.java @@ -8,9 +8,6 @@ public enum Command { private String commandWord; - public static > T getEnumValue(TextIO textIO, Class commands) { - return textIO.newEnumInputReader(commands).read("What would you like to do?"); - } Command(String commandWord) { diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index b131458..9da799a 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -3,34 +3,54 @@ import org.beryx.textio.TextIO; import org.beryx.textio.TextIoFactory; import org.beryx.textio.TextTerminal; +import java.awt.*; + +import static ch.zhaw.catan.Command.QUIT; +import static ch.zhaw.catan.Command.UNKNOWN; + public class Parser { TextIO textIO = TextIoFactory.getTextIO(); TextTerminal textTerminal; - - public Parser() { textTerminal = textIO.getTextTerminal(); - run(); + } + public Point getPoint() { + return null; } - public void run() { - boolean running = true; - while (running) { - switch(Command.getEnumValue(textIO, Command.class)){ - case QUIT: - running = false; - break; - case UNKNOWN: - break; + public int gameStart(){ + return 2; + } + public void giveCoordinatesForStructures(Config.Structure structure) { - } + } + public void thrownDices(int number){ + + } + + public void playerTurn(Config.Faction faction) { + + } + + public void errorMessage(){ + + } + + public Command getAction() { + + switch (textIO.newEnumInputReader(Command.class).read("What would you like to do?")) { + case QUIT: + System.out.println("quit"); + return QUIT; + + case UNKNOWN: + return UNKNOWN; + default: + return null; } } - - - } diff --git a/src/ch/zhaw/catan/Siedler.java b/src/ch/zhaw/catan/Siedler.java index 8f62515..d3bd7d9 100644 --- a/src/ch/zhaw/catan/Siedler.java +++ b/src/ch/zhaw/catan/Siedler.java @@ -15,6 +15,8 @@ public class Siedler { TextIO textIO = TextIoFactory.getTextIO(); TextTerminal textTerminal = textIO.getTextTerminal(); textTerminal.println(game.getBoard().getTextView()); + Parser parser = new Parser(); + parser.getAction(); From cba5a6b22c4cb2cdc5bc48e7b483582290dcbaa8 Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Thu, 2 Dec 2021 15:20:30 +0100 Subject: [PATCH 2/3] gameStart method now returns HashMap --- src/ch/zhaw/catan/Parser.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index 9da799a..921f5c0 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -4,6 +4,7 @@ import org.beryx.textio.TextIoFactory; import org.beryx.textio.TextTerminal; import java.awt.*; +import java.util.HashMap; import static ch.zhaw.catan.Command.QUIT; import static ch.zhaw.catan.Command.UNKNOWN; @@ -19,8 +20,8 @@ public class Parser { return null; } - public int gameStart(){ - return 2; + public HashMap gameStart(){ + return null; } public void giveCoordinatesForStructures(Config.Structure structure) { From 684bf9e553b99ce4ed8d4b7be34157dc2a9071ef Mon Sep 17 00:00:00 2001 From: Leonardo Brandenberger Date: Thu, 2 Dec 2021 15:22:33 +0100 Subject: [PATCH 3/3] gameStart method now returns HashMap --- src/ch/zhaw/catan/Parser.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index 921f5c0..1e440d1 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -22,6 +22,8 @@ public class Parser { public HashMap gameStart(){ return null; + //Anzahlspieler,int + //Siegespunkte,int } public void giveCoordinatesForStructures(Config.Structure structure) {