Merge remote-tracking branch 'origin/main' into main
This commit is contained in:
commit
f4adf68b9f
|
@ -1,5 +0,0 @@
|
|||
<component name="ProjectCodeStyleConfiguration">
|
||||
<state>
|
||||
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||
</state>
|
||||
</component>
|
31
README.md
31
README.md
|
@ -6,17 +6,18 @@ strategic game where you have to choose wisely where to build your structures,
|
|||
to be able to dominate your friends.
|
||||
|
||||
#Rules
|
||||
1. The min. Player amount is 2 and the max. Player amount is 4.
|
||||
2. Each Player can build two roads and two settlements free of cost at the beginning of
|
||||
1. The minimum Player amount is 2 and the maximum Player amount is 4.
|
||||
2. The minimum amount if win points is 3.
|
||||
3. Each Player can build two roads and two settlements free of cost at the beginning of
|
||||
the game. After the placement, each player gets resources from the field around the second settlement.
|
||||
3. Every Player is being sorted into a faction. There cannot be two players in the
|
||||
4. Every Player is being sorted into a faction. There cannot be two players in the
|
||||
same faction.
|
||||
4. A player cannot build two settlements or cities right next one another.
|
||||
5. A player cannot build two settlements or cities right next one another.
|
||||
There have to be at least two roads between them.
|
||||
5. The cost for each structure is set and is nonnegotiable.
|
||||
6. The player with the longest road (most roads connecting to one another)
|
||||
6. The cost for each structure is set and is nonnegotiable.
|
||||
7. The player with the longest road (most roads connecting to one another), which is longer then 4
|
||||
will be awarded two additional points.
|
||||
7. If a player rolls a 7 on a dice throw, then the resources of every player that has
|
||||
8. If a player rolls a 7 on a dice throw, then the resources of every player that has
|
||||
more than 7 resources will be halved. The resources that are being taken are chosen
|
||||
at random.
|
||||
|
||||
|
@ -35,6 +36,8 @@ number that the player rolled with the dice.
|
|||
|
||||
Now as for the commands a player has to put in while it's their turn:
|
||||
#Build Settlement
|
||||
``build settlement`` Builds a settlement
|
||||
|
||||
When it's the players turn, they can build a new settlement by giving the command
|
||||
build settlement. With that they will be asked where they want to build said settlement
|
||||
and to enter the coordinates, then the program will check if those coordinates are available or not. Then the
|
||||
|
@ -43,6 +46,8 @@ insufficient resources the settlement will not be built and an error message wil
|
|||
appear. The turn of the current player will continue until the player ends it.
|
||||
|
||||
#Build City
|
||||
``build city`` Builds a city
|
||||
|
||||
During the players turn they can build a city on the same coordinates that they
|
||||
have already built a settlement on. To do that they have to enter the command
|
||||
build city. Then they have to add the coordinates that they want the city to be
|
||||
|
@ -53,6 +58,8 @@ the program will subtract them of the players resources, otherwise the city won'
|
|||
be build and the player continues their turn until they end it.
|
||||
|
||||
#Build Road
|
||||
``build road`` Builds a road
|
||||
|
||||
During the current players turn, the player can build a new road by giving the
|
||||
command build road. Then the player will be asked to give the coordinates for where
|
||||
they want to build the new road after entering the coordinates the program will
|
||||
|
@ -64,6 +71,8 @@ have enough resources the road will not be built and the player will receive
|
|||
an error message. The player continues their turn until they end it.
|
||||
|
||||
#Trade with Bank
|
||||
``trade with bank`` Let's the player trade resources with the bank
|
||||
|
||||
The current player can trade resources with the bank by entering the command
|
||||
trade with bank. The player then can enter what and how many resources they want
|
||||
then they have to enter what resources they will give in return. The trade course
|
||||
|
@ -72,14 +81,22 @@ trade for one of their choosing from the bank. If they do not have enough resour
|
|||
to give the trade will not be completed and the player may continue their turn.
|
||||
|
||||
#Next Player
|
||||
``next player`` Ends a players turn
|
||||
|
||||
When the current player has done all the building and trading they wanted and now
|
||||
want to end their turn they can end it by entering the command next player. By entering
|
||||
this command the player relinquishes their turn and the next player may start their
|
||||
turn.
|
||||
|
||||
#Quit
|
||||
``quit`` Let's a player quit the game
|
||||
|
||||
If a player wants to quit the game they can enter the command quit while it's their
|
||||
turn to quit the game.
|
||||
|
||||
#Coordinates
|
||||
|
||||
|
||||
#Class Diagram
|
||||
|
||||
![alt text](doc/Klassendiagramm%20Siedler.png)
|
Binary file not shown.
After Width: | Height: | Size: 1.3 MiB |
|
@ -2,39 +2,19 @@ package ch.zhaw.catan;
|
|||
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Bank Class that stores Resources when not being owned by a player,
|
||||
* and the needed functions to take and give resources to it.
|
||||
*
|
||||
* @author Leonardo Brandenberger
|
||||
*/
|
||||
|
||||
public class Bank {
|
||||
private final HashMap<Config.Resource, Integer> resources = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Construct a Bank Object and stores Config Values in own HashMap.
|
||||
*/
|
||||
public Bank() {
|
||||
resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Stores a desired resource in desired quantity in the bank.
|
||||
*
|
||||
* @param resource the resource type that gets added to the bank
|
||||
* @param numberOfResources the quantity of resources of the chosen type get added
|
||||
*/
|
||||
public void storeResourceToBank(Config.Resource resource, int numberOfResources) {
|
||||
resources.put(resource, resources.get(resource) + numberOfResources);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a Resource is available in the quantity desired. and then deducts it from the bank inventory.
|
||||
*
|
||||
* @param resource the resource type that has to be deducted
|
||||
* @param numberOfResources the quantity of the resource that gets deducted from the inventory
|
||||
* @return true if resources available and deducted false if not enough resources are in the bank
|
||||
*/
|
||||
public boolean getResourceFromBank(Config.Resource resource, int numberOfResources) {
|
||||
if (resources.get(resource) >= numberOfResources) {
|
||||
Integer newResourceNumber = resources.get(resource) - numberOfResources;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package ch.zhaw.catan;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.awt.*;
|
||||
|
||||
/**
|
||||
* Sub Class of Structure and Super Class of City
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -1,19 +1,17 @@
|
|||
package ch.zhaw.catan;
|
||||
|
||||
import java.awt.Point;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
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();
|
||||
|
|
Loading…
Reference in New Issue