diff --git a/src/ch/zhaw/catan/Command.java b/src/ch/zhaw/catan/Command.java index d8157dc..7e7b24e 100644 --- a/src/ch/zhaw/catan/Command.java +++ b/src/ch/zhaw/catan/Command.java @@ -3,7 +3,8 @@ package ch.zhaw.catan; import org.beryx.textio.TextIO; public enum Command { - NEXTPLAYER ("next Player"), QUIT("quit"), UNKNOWN ("unknown"); + NEXTPLAYER ("next player"), BUILDSETTLEMENT ("build settlement"), BUILDCITY("build city"), + BUILDROAD("build road"), TRADEWITHBANK("trade with bank"),QUIT("quit"); private String commandWord; diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index b86019b..9d78a3a 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -6,8 +6,7 @@ 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; +import static ch.zhaw.catan.Command.*; public class Parser { TextIO textIO = TextIoFactory.getTextIO(); @@ -16,8 +15,10 @@ public class Parser { public Parser() { textTerminal = textIO.getTextTerminal(); } + public Point getPoint() { - return null; + return new Point(textIO.newIntInputReader().withMinVal(0).read("x coordinate:"), + textIO.newIntInputReader().withMinVal(0).read("y coordinate:")); } public void displayGameboard(String gameboard) { @@ -25,39 +26,49 @@ public class Parser { } public HashMap gameStart(){ - return null; - //Anzahlspieler,int - //Siegespunkte,int + HashMap gameStartValues = new HashMap<>(); + gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(2).withMaxVal(4).read("Number of players:")); + gameStartValues.put("NumberOfWinPoints", textIO.newIntInputReader().withMinVal(5).withMaxVal(15).read("Winpoint needed for Victory:")); + return gameStartValues; } public void giveCoordinatesForStructures(Config.Structure structure) { textTerminal.println("Please insert coordinates for " + structure); + if(structure == Config.Structure.ROAD) { + textTerminal.println("You are building a road, please first insert the start coordinate and when prompted again the coordinate of the end of the road."); + } } public void thrownDices(int number){ - textTerminal.println("Dices are being thrown "); + textTerminal.println ("Dices have been thrown, the combined value is: " + number); + } public void playerTurn(Config.Faction faction) { - + textTerminal.println("It is" + faction + "'s turn."); } public void errorMessage(){ - + textTerminal.print("The command was not excecuted successfully!"); } 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; + case NEXTPLAYER: + return NEXTPLAYER; + case BUILDSETTLEMENT: + return BUILDSETTLEMENT; + case BUILDCITY: + return BUILDCITY; + case BUILDROAD: + return BUILDROAD; + case TRADEWITHBANK: + return TRADEWITHBANK; + case QUIT: + return QUIT; + default: + return null; } } }