updated javaodoc SiedlerGame

This commit is contained in:
Andrin Fassbind 2021-12-10 11:34:23 +01:00
parent 20d73bd5e0
commit d3ebcc7566
3 changed files with 32 additions and 10 deletions

View File

@ -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;

View File

@ -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<Land, Settlement, Road, String> {
public SiedlerBoardTextView(SiedlerBoard board) {

View File

@ -10,10 +10,8 @@ import java.util.Random;
/**
* This class performs all actions related to modifying the game state.
* <p>
* 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<Config.Resource> resourceArrayList = new ArrayList<>();
HashMap<Config.Resource, Integer> 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<Settlement> settlements = board.getCorners();