diff --git a/.gitignore b/.gitignore
index ed8c940..a425ad5 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
+<<<<<<< HEAD
+/out/
+=======
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
@@ -73,4 +76,5 @@ fabric.properties
.idea/httpRequests
# Android studio 3.1+ serialized cache file
-.idea/caches/build_file_checksums.ser
\ No newline at end of file
+.idea/caches/build_file_checksums.ser
+>>>>>>> origin/main
diff --git a/.idea/misc.xml b/.idea/misc.xml
index c3dfb30..1029788 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java
index e4d392f..e25bd00 100644
--- a/src/ch/zhaw/catan/SiedlerGame.java
+++ b/src/ch/zhaw/catan/SiedlerGame.java
@@ -152,10 +152,12 @@ public class SiedlerGame {
return false;
}
board.setCorner(position, new Settlement(allPlayers.get(activePlayer).getFaction()));
- if(payout){
+ if(payout) {
List lands = board.getLandsForCorner(position);
- for (Config.Land land:lands){
- allPlayers.get(activePlayer).addResource(land.getResource(), 1);
+ for (Config.Land land : lands) {
+ if (land.getResource() != null) {
+ allPlayers.get(activePlayer).addResource(land.getResource(), 1);
+ }
}
}
return true;
@@ -202,24 +204,26 @@ public class SiedlerGame {
public Map> throwDice(int dicethrow) {
if (dicethrow == 7) {
handleDiceThrow7();
- return null;
} else {
- Map> returnMap = new HashMap<>();
+ Map> returnMap= new HashMap<>();
List diceValueFields = board.getFieldsForDiceValue(dicethrow);
for (Player player : allPlayers) {
returnMap.put(player.getFaction(), new ArrayList());
for (Point field : diceValueFields) {
- List resources = board.getResourcesforFaction(field, player.getFaction());
- for (Config.Resource resource : resources) {
+ List resources= board.getResourcesforFaction(field,player.getFaction());
+ for (Config.Resource resource : resources){
+ //TODO: Check if Resource Null notwendig?
returnMap.get(player.getFaction()).add(resource);
- player.addResource(resource, 1);
+ player.addResource(resource,1);
}
}
}
return returnMap;
}
+ return null;
}
+
private void handleDiceThrow7() {
for(Player player : allPlayers) {
HashMap resources = player.getResources();
@@ -353,10 +357,12 @@ public class SiedlerGame {
}
//3. Check if NeighbourEdge are Roads
boolean hasNeighbourRoad = (checkAdjacentEdgesList(roadStart) || checkAdjacentEdgesList(roadEnd));
- //4.Check if roadStart or roadEnd is Settlement of current player or if 3. is valid
- if(board.getCorner(roadStart).getFaction() == allPlayers.get(activePlayer).getFaction()
- || board.getCorner(roadEnd).getFaction() == allPlayers.get(activePlayer).getFaction()
- || hasNeighbourRoad){
+ if(hasNeighbourRoad) {
+ return true;
+ }
+ //4.Check if roadStart or roadEnd is Settlement of current player
+ if((board.getCorner(roadStart)!=null && board.getCorner(roadStart).getFaction() == allPlayers.get(activePlayer).getFaction())
+ ||(board.getCorner(roadEnd)!=null && board.getCorner(roadEnd).getFaction() == allPlayers.get(activePlayer).getFaction())) {
return true;
}
return false;
@@ -372,7 +378,11 @@ public class SiedlerGame {
if (!board.hasCorner(position)) {
return false;
}
- //2. Check if Corner is empty
+ //2. Check if water
+ if(checkIfWater(position)) {
+ return false;
+ }
+ //3. Check if Corner is empty
if(board.getCorner(position) != null) {
return false;
}
@@ -383,6 +393,16 @@ public class SiedlerGame {
return true;
}
+ private boolean checkIfWater(Point point) {
+ List fields = board.getFields(point);
+ for(Config.Land land : fields) {
+ if(!land.equals(Config.Land.WATER)) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/**
* This method checks if there are Roads build by active Player on adjacent edges
* @param point