diff --git a/src/ch/zhaw/catan/Bank.java b/src/ch/zhaw/catan/Bank.java index 39e7319..f82f19b 100644 --- a/src/ch/zhaw/catan/Bank.java +++ b/src/ch/zhaw/catan/Bank.java @@ -1,11 +1,10 @@ package ch.zhaw.catan; import java.util.HashMap; -import java.util.List; public class Bank { - private HashMap resources = new HashMap<>(); + private final HashMap resources = new HashMap<>(); public Bank(){ resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK); diff --git a/src/ch/zhaw/catan/City.java b/src/ch/zhaw/catan/City.java index a976267..5e68330 100644 --- a/src/ch/zhaw/catan/City.java +++ b/src/ch/zhaw/catan/City.java @@ -1,6 +1,6 @@ package ch.zhaw.catan; -import java.awt.*; +import java.awt.Point; public class City extends Settlement { diff --git a/src/ch/zhaw/catan/Command.java b/src/ch/zhaw/catan/Command.java index 7e7b24e..9a96ed3 100644 --- a/src/ch/zhaw/catan/Command.java +++ b/src/ch/zhaw/catan/Command.java @@ -1,12 +1,11 @@ package ch.zhaw.catan; -import org.beryx.textio.TextIO; - +//TODO:JavaDoc public enum Command { NEXTPLAYER ("next player"), BUILDSETTLEMENT ("build settlement"), BUILDCITY("build city"), BUILDROAD("build road"), TRADEWITHBANK("trade with bank"),QUIT("quit"); - private String commandWord; + private final String commandWord; diff --git a/src/ch/zhaw/catan/Dummy.java b/src/ch/zhaw/catan/Dummy.java deleted file mode 100644 index bf94f5f..0000000 --- a/src/ch/zhaw/catan/Dummy.java +++ /dev/null @@ -1,58 +0,0 @@ -package ch.zhaw.catan; - -import ch.zhaw.catan.Config.Land; -import ch.zhaw.hexboard.Label; -import java.awt.Point; -import java.util.HashMap; -import java.util.Map; -import org.beryx.textio.TextIO; -import org.beryx.textio.TextIoFactory; -import org.beryx.textio.TextTerminal; - -public class Dummy { - - public enum Actions { - SHOW, QUIT - } - - private void run() { - TextIO textIO = TextIoFactory.getTextIO(); - TextTerminal textTerminal = textIO.getTextTerminal(); - SiedlerBoard board = new SiedlerBoard(); - board.addField(new Point(2, 2), Land.FOREST); - board.setCorner(new Point(3, 3), new Settlement(Config.Faction.RED,new Point(3, 3))); - board.setEdge(new Point(2, 0), new Point(3, 1), new Road(Config.Faction.BLUE,new Point(2, 0),new Point(2, 0))); - board.addFieldAnnotation(new Point(2, 2), new Point(3, 1), "AA"); - - Map lowerFieldLabel = new HashMap<>(); - lowerFieldLabel.put(new Point(2, 2), new Label('0', '9')); - SiedlerBoardTextView view = new SiedlerBoardTextView(board); - - for (Map.Entry e : lowerFieldLabel.entrySet()) { - view.setLowerFieldLabel(e.getKey(), e.getValue()); - } - - boolean running = true; - while (running) { - switch (getEnumValue(textIO, Actions.class)) { - case SHOW: - textTerminal.println(view.toString()); - break; - case QUIT: - running = false; - break; - default: - throw new IllegalStateException("Internal error found - Command not implemented."); - } - } - textIO.dispose(); - } - - public static > T getEnumValue(TextIO textIO, Class commands) { - return textIO.newEnumInputReader(commands).read("What would you like to do?"); - } - - public static void main(String[] args) { - new Dummy().run(); - } -} diff --git a/src/ch/zhaw/catan/Parser.java b/src/ch/zhaw/catan/Parser.java index 2f1bc69..b572dd2 100644 --- a/src/ch/zhaw/catan/Parser.java +++ b/src/ch/zhaw/catan/Parser.java @@ -76,7 +76,7 @@ public class Parser { */ public HashMap gameStart() { HashMap gameStartValues = new HashMap<>(); - gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(2).withMaxVal(4).read("Number of players:")); + gameStartValues.put("NumberOfPlayers", textIO.newIntInputReader().withMinVal(Config.MIN_NUMBER_OF_PLAYERS).withMaxVal(4).read("Number of players:")); gameStartValues.put("NumberOfWinPoints", textIO.newIntInputReader().withMinVal(5).withMaxVal(15).read("Winpoints needed for Victory:")); return gameStartValues; } diff --git a/src/ch/zhaw/catan/Player.java b/src/ch/zhaw/catan/Player.java index fc378a0..5b3b5cf 100644 --- a/src/ch/zhaw/catan/Player.java +++ b/src/ch/zhaw/catan/Player.java @@ -1,6 +1,7 @@ package ch.zhaw.catan; -import java.util.*; +import java.util.HashMap; +import java.util.List; /** * New Class PLayer diff --git a/src/ch/zhaw/catan/Road.java b/src/ch/zhaw/catan/Road.java index 1bc37a5..e43a6a7 100644 --- a/src/ch/zhaw/catan/Road.java +++ b/src/ch/zhaw/catan/Road.java @@ -1,10 +1,10 @@ package ch.zhaw.catan; -import java.awt.*; +import java.awt.Point; public class Road extends Structure { - private Point start,end; + private final Point start,end; public Road(Config.Faction faction,Point start,Point end) {