- * 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;
@@ -34,9 +32,6 @@ public class SiedlerGame {
* or players is not between two and four
*/
public SiedlerGame(int winPoints, int numberOfPlayers) {
- if (winPoints < 3 || numberOfPlayers < Config.MIN_NUMBER_OF_PLAYERS || numberOfPlayers > 4) {
- throw new IllegalArgumentException();
- }
bank = new Bank();
board = new SiedlerBoard();
board.createFixGameField();
@@ -74,7 +69,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 +85,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);
@@ -114,7 +123,7 @@ public class SiedlerGame {
}
/**
- * Returns the game board.
+ * Returns the game board. Used for test
*
* @return the game board
*/
@@ -122,6 +131,13 @@ public class SiedlerGame {
return board;
}
+ /**
+ * Returns the String used to show the Board
+ *
+ * @return String of the Board.
+ */
+ public String getBoardTextView(){return board.toString();}
+
/**
* Returns the {@link Config.Faction} of the current player.
*
@@ -142,6 +158,11 @@ public class SiedlerGame {
return allPlayers.get(activePlayer).getSpecificResource(resource);
}
+ /**
+ * Returns the resources of the current player.
+ *
+ * @return a hashmap with all resources the player has. Key: Resource name Value: number of resources
+ */
public HashMap