Merge remote-tracking branch 'origin/main'
# Conflicts: # src/ch/zhaw/catan/SiedlerGame.java
This commit is contained in:
commit
e23f8bcdde
|
@ -1,3 +1,6 @@
|
||||||
|
<<<<<<< HEAD
|
||||||
|
/out/
|
||||||
|
=======
|
||||||
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
|
# 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
|
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
|
||||||
|
|
||||||
|
@ -74,3 +77,4 @@ fabric.properties
|
||||||
|
|
||||||
# Android studio 3.1+ serialized cache file
|
# Android studio 3.1+ serialized cache file
|
||||||
.idea/caches/build_file_checksums.ser
|
.idea/caches/build_file_checksums.ser
|
||||||
|
>>>>>>> origin/main
|
||||||
|
|
|
@ -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_17" 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>
|
|
@ -155,9 +155,11 @@ public class SiedlerGame {
|
||||||
if(payout) {
|
if(payout) {
|
||||||
List<Config.Land> lands = board.getLandsForCorner(position);
|
List<Config.Land> lands = board.getLandsForCorner(position);
|
||||||
for (Config.Land land : lands) {
|
for (Config.Land land : lands) {
|
||||||
|
if (land.getResource() != null) {
|
||||||
allPlayers.get(activePlayer).addResource(land.getResource(), 1);
|
allPlayers.get(activePlayer).addResource(land.getResource(), 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -202,7 +204,6 @@ public class SiedlerGame {
|
||||||
public Map<Faction, List<Resource>> throwDice(int dicethrow) {
|
public Map<Faction, List<Resource>> throwDice(int dicethrow) {
|
||||||
if (dicethrow == 7) {
|
if (dicethrow == 7) {
|
||||||
handleDiceThrow7();
|
handleDiceThrow7();
|
||||||
return null;
|
|
||||||
} else {
|
} else {
|
||||||
Map<Faction,List<Resource>> returnMap= new HashMap<>();
|
Map<Faction,List<Resource>> returnMap= new HashMap<>();
|
||||||
List<Point> diceValueFields = board.getFieldsForDiceValue(dicethrow);
|
List<Point> diceValueFields = board.getFieldsForDiceValue(dicethrow);
|
||||||
|
@ -211,6 +212,7 @@ public class SiedlerGame {
|
||||||
for (Point field : diceValueFields) {
|
for (Point field : diceValueFields) {
|
||||||
List<Resource> resources= board.getResourcesforFaction(field,player.getFaction());
|
List<Resource> resources= board.getResourcesforFaction(field,player.getFaction());
|
||||||
for (Config.Resource resource : resources){
|
for (Config.Resource resource : resources){
|
||||||
|
//TODO: Check if Resource Null notwendig?
|
||||||
returnMap.get(player.getFaction()).add(resource);
|
returnMap.get(player.getFaction()).add(resource);
|
||||||
player.addResource(resource,1);
|
player.addResource(resource,1);
|
||||||
}
|
}
|
||||||
|
@ -218,8 +220,10 @@ public class SiedlerGame {
|
||||||
}
|
}
|
||||||
return returnMap;
|
return returnMap;
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void handleDiceThrow7() {
|
private void handleDiceThrow7() {
|
||||||
for(Player player : allPlayers) {
|
for(Player player : allPlayers) {
|
||||||
HashMap<Resource, Integer> resources = player.getResources();
|
HashMap<Resource, Integer> resources = player.getResources();
|
||||||
|
@ -353,10 +357,12 @@ public class SiedlerGame {
|
||||||
}
|
}
|
||||||
//3. Check if NeighbourEdge are Roads
|
//3. Check if NeighbourEdge are Roads
|
||||||
boolean hasNeighbourRoad = (checkAdjacentEdgesList(roadStart) || checkAdjacentEdgesList(roadEnd));
|
boolean hasNeighbourRoad = (checkAdjacentEdgesList(roadStart) || checkAdjacentEdgesList(roadEnd));
|
||||||
//4.Check if roadStart or roadEnd is Settlement of current player or if 3. is valid
|
if(hasNeighbourRoad) {
|
||||||
if(board.getCorner(roadStart).getFaction() == allPlayers.get(activePlayer).getFaction()
|
return true;
|
||||||
|| board.getCorner(roadEnd).getFaction() == allPlayers.get(activePlayer).getFaction()
|
}
|
||||||
|| hasNeighbourRoad){
|
//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 true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -372,7 +378,11 @@ public class SiedlerGame {
|
||||||
if (!board.hasCorner(position)) {
|
if (!board.hasCorner(position)) {
|
||||||
return false;
|
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) {
|
if(board.getCorner(position) != null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -383,6 +393,16 @@ public class SiedlerGame {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean checkIfWater(Point point) {
|
||||||
|
List<Config.Land> 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
|
* This method checks if there are Roads build by active Player on adjacent edges
|
||||||
* @param point
|
* @param point
|
||||||
|
|
Loading…
Reference in New Issue