diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java index ce3ea15..0619c57 100644 --- a/src/ch/zhaw/catan/SiedlerBoard.java +++ b/src/ch/zhaw/catan/SiedlerBoard.java @@ -2,7 +2,6 @@ package ch.zhaw.catan; import ch.zhaw.hexboard.HexBoard; import ch.zhaw.hexboard.Label; - import java.awt.Point; import java.util.ArrayList; import java.util.Collections; @@ -25,7 +24,7 @@ public class SiedlerBoard extends HexBoard fields = new HashMap<>(); private Config.Faction longestRoadFaction = null; - private int longestRoadLenth = 0; + private int longestRoadLength = 0; /** * Method to create the predefined game field from Config. @@ -47,6 +46,15 @@ public class SiedlerBoard extends HexBoard longestRoadLenth && players.get(factionA) > 4) { + if (players.get(factionA) > longestRoadLength && players.get(factionA) > 4) { longestRoadFaction = factionA; - longestRoadLenth = players.get(factionA); + longestRoadLength = players.get(factionA); } } return longestRoadFaction; } - //todo javadoc - public int getLongestRoadLenth() { - return longestRoadLenth; - } - /** * This method is recursive and adds all roads which belongs to a specific players and stringing together to a HashSet. * The length of the HashSet represents the length of the longest Road the player has. diff --git a/src/ch/zhaw/catan/SiedlerBoardTextView.java b/src/ch/zhaw/catan/SiedlerBoardTextView.java index 157e4f9..bece675 100644 --- a/src/ch/zhaw/catan/SiedlerBoardTextView.java +++ b/src/ch/zhaw/catan/SiedlerBoardTextView.java @@ -3,7 +3,10 @@ package ch.zhaw.catan; import ch.zhaw.catan.Config.Land; import ch.zhaw.hexboard.HexBoardTextView; -//TODO Java Docs +/** + * This Class extends the Class HexBoardTextView + * + */ public class SiedlerBoardTextView extends HexBoardTextView { public SiedlerBoardTextView(SiedlerBoard board) { diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java index 8e0feff..b32b241 100644 --- a/src/ch/zhaw/catan/SiedlerGame.java +++ b/src/ch/zhaw/catan/SiedlerGame.java @@ -10,10 +10,8 @@ import java.util.Random; /** * This class performs all actions related to modifying the game state. - *

- * TODO: (your documentation) * - * @author TODO + * @author Andrin Fassbind, Leonardo Brandenberger, Roman Schenk, Stefan Amador */ public class SiedlerGame { static final int FOUR_TO_ONE_TRADE_OFFER = 4; @@ -74,7 +72,14 @@ public class SiedlerGame { } } - //TODO JavaDoc + /** + * This methode is used to add resources to the player. + * + * @param player the active Player + * @param resource the resource to add + * @param numberToAdd the quantity of resources to add + * @return true if resource has been added else false + */ private boolean addResourcesToPlayer(Player player, Config.Resource resource, int numberToAdd) { if (bank.getResourceFromBank(resource, numberToAdd)) { player.addResource(resource, numberToAdd); @@ -83,7 +88,14 @@ public class SiedlerGame { return false; } - //TODO JavaDoc + /** + * This methode is used to subtract resources from Player + * + * @param player the active player + * @param resource the resource to subtract + * @param numberToSubtract the quantity of resource to subtract + * @return true if resource has been subtracted + */ private boolean subtractResourceFromPlayer(Player player, Config.Resource resource, int numberToSubtract) { if (player.subtractResource(resource, numberToSubtract)) { bank.storeResourceToBank(resource, numberToSubtract); @@ -234,7 +246,11 @@ public class SiedlerGame { return null; } - //TODO JavaDoc + /** + * This method handles the case if a 7 has been diced. + * + * @param player the active player who rolls the dice. + */ public void handleDiceThrow7(Player player) { ArrayList resourceArrayList = new ArrayList<>(); HashMap resources = player.getResources(); @@ -376,7 +392,7 @@ public class SiedlerGame { if (!board.hasEdge(roadStart, roadEnd)) { return false; } - //2. Check if edge is empty //TODO Check if always inverted is allowed + //2. Check if edge is empty if (board.getEdge(roadStart, roadEnd) != null) { return false; } @@ -482,7 +498,11 @@ public class SiedlerGame { return null; } - //Todo Java Doc + /** + * This methode counts the winpoints of the current player. + * + * @return the winpoints as an integer + */ public int getCurrentPlayerWinPoints() { int winPoints = 0; List settlements = board.getCorners(); diff --git a/test/ch/zhaw/catan/SiedlerBoardTest.java b/test/ch/zhaw/catan/SiedlerBoardTest.java index f083917..8452824 100644 --- a/test/ch/zhaw/catan/SiedlerBoardTest.java +++ b/test/ch/zhaw/catan/SiedlerBoardTest.java @@ -41,7 +41,7 @@ public class SiedlerBoardTest { System.out.println(board.getTextView()); assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); - assertEquals(6, board.getLongestRoadLenth()); + assertEquals(6, board.getLongestRoadLength()); } @Test @@ -50,7 +50,7 @@ public class SiedlerBoardTest { System.out.println(board.getTextView()); assertEquals(Config.Faction.BLUE, board.getLongestRoadFaction(factionList)); - assertEquals(5, board.getLongestRoadLenth()); + assertEquals(5, board.getLongestRoadLength()); } }