Fixed Bug set strutcture in water and set bug addressource nullpointer exception
This commit is contained in:
parent
8f12b40e50
commit
4a352dd40a
|
@ -154,8 +154,10 @@ public class SiedlerGame {
|
|||
board.setCorner(position, new Settlement(allPlayers.get(activePlayer).getFaction()));
|
||||
List<Config.Land> lands = board.getLandsForCorner(position);
|
||||
for (Config.Land land:lands){
|
||||
if(land.getResource()!=null){
|
||||
allPlayers.get(activePlayer).addResource(land.getResource(), 1);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -205,6 +207,7 @@ public class SiedlerGame {
|
|||
for (Point field : diceValueFields) {
|
||||
List<Resource> 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);
|
||||
}
|
||||
|
@ -330,10 +333,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;
|
||||
|
@ -349,7 +354,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;
|
||||
}
|
||||
|
@ -360,6 +369,16 @@ public class SiedlerGame {
|
|||
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
|
||||
* @param point
|
||||
|
|
Loading…
Reference in New Issue