updated javaodoc SiedlerGame

updated constructor SiedlerGame
This commit is contained in:
Andrin Fassbind 2021-12-10 13:39:19 +01:00
parent faca966394
commit 0ea44905e2
6 changed files with 20 additions and 14 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_X" default="true" project-jdk-name="openjdk-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -8,10 +8,8 @@ package ch.zhaw.catan;
public enum Command { public enum Command {
NEXT_PLAYER("next player"), BUILD_SETTLEMENT("build settlement"), BUILD_CITY("build city"), NEXT_PLAYER("next player"), BUILD_SETTLEMENT("build settlement"), BUILD_CITY("build city"),
BUILD_ROAD("build road"), TRADE_WITH_BANK("trade with bank"), QUIT("quit"); BUILD_ROAD("build road"), TRADE_WITH_BANK("trade with bank"), QUIT("quit");
private final String commandWord; private final String commandWord;
Command(String commandWord) { Command(String commandWord) {
this.commandWord = commandWord; this.commandWord = commandWord;
} }

View File

@ -11,6 +11,11 @@ import java.util.List;
*/ */
public class Player { public class Player {
/**
* faction: The faction of the player
* resources: The resources the player owns
* structureToUse: The structures a player can build.
*/
private final Config.Faction faction; private final Config.Faction faction;
private final HashMap<Config.Resource, Integer> resources; private final HashMap<Config.Resource, Integer> resources;
private final HashMap<Config.Structure, Integer> structureToUse; private final HashMap<Config.Structure, Integer> structureToUse;

View File

@ -5,12 +5,11 @@ import ch.zhaw.hexboard.HexBoardTextView;
/** /**
* This Class extends the Class HexBoardTextView * This Class extends the Class HexBoardTextView
*
*/ */
public class SiedlerBoardTextView extends HexBoardTextView<Land, Settlement, Road, String> { public class SiedlerBoardTextView extends HexBoardTextView<Land, Settlement, Road, String> {
public SiedlerBoardTextView(SiedlerBoard board) { public SiedlerBoardTextView(SiedlerBoard board) {
super(board); super(board);
} }
} }

View File

@ -32,9 +32,6 @@ public class SiedlerGame {
* or players is not between two and four * or players is not between two and four
*/ */
public SiedlerGame(int winPoints, int numberOfPlayers) { public SiedlerGame(int winPoints, int numberOfPlayers) {
if (winPoints < 3 || numberOfPlayers < Config.MIN_NUMBER_OF_PLAYERS || numberOfPlayers > 4) {
throw new IllegalArgumentException();
}
bank = new Bank(); bank = new Bank();
board = new SiedlerBoard(); board = new SiedlerBoard();
board.createFixGameField(); board.createFixGameField();
@ -75,8 +72,8 @@ public class SiedlerGame {
/** /**
* This methode is used to add resources to the player. * This methode is used to add resources to the player.
* *
* @param player the active Player * @param player the active Player
* @param resource the resource to add * @param resource the resource to add
* @param numberToAdd the quantity of resources to add * @param numberToAdd the quantity of resources to add
* @return true if resource has been added else false * @return true if resource has been added else false
*/ */
@ -91,8 +88,8 @@ public class SiedlerGame {
/** /**
* This methode is used to subtract resources from Player * This methode is used to subtract resources from Player
* *
* @param player the active player * @param player the active player
* @param resource the resource to subtract * @param resource the resource to subtract
* @param numberToSubtract the quantity of resource to subtract * @param numberToSubtract the quantity of resource to subtract
* @return true if resource has been subtracted * @return true if resource has been subtracted
*/ */
@ -154,6 +151,11 @@ public class SiedlerGame {
return allPlayers.get(activePlayer).getSpecificResource(resource); 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<Config.Resource, Integer> getCurrentPlayerResource() { public HashMap<Config.Resource, Integer> getCurrentPlayerResource() {
return allPlayers.get(activePlayer).getResources(); return allPlayers.get(activePlayer).getResources();
} }

View File

@ -311,6 +311,8 @@ public class SiedlerGameTest {
game.placeInitialRoad(secondRoad.first, secondRoad.second); game.placeInitialRoad(secondRoad.first, secondRoad.second);
} }
System.out.println(game.getBoard().getTextView());
return game; return game;
} }