From d3ebcc756678679e4c374901c252d649818fa07c Mon Sep 17 00:00:00 2001 From: Andrin Fassbind Date: Fri, 10 Dec 2021 11:34:23 +0100 Subject: [PATCH] updated javaodoc SiedlerGame --- src/ch/zhaw/catan/SiedlerBoard.java | 1 - src/ch/zhaw/catan/SiedlerBoardTextView.java | 5 ++- src/ch/zhaw/catan/SiedlerGame.java | 36 ++++++++++++++++----- 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/ch/zhaw/catan/SiedlerBoard.java b/src/ch/zhaw/catan/SiedlerBoard.java index adf84fb..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; 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 7e14467..c4e277c 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();