added Method handleDiceThrow7 in SiedlerGame

This commit is contained in:
schrom01 2021-12-04 13:20:09 +01:00
parent 7129435fea
commit f6865451a6
1 changed files with 32 additions and 11 deletions

View File

@ -198,20 +198,41 @@ public class SiedlerGame {
* @return the resource cards added to the stock of the different players * @return the resource cards added to the stock of the different players
*/ */
public Map<Faction, List<Resource>> throwDice(int dicethrow) { public Map<Faction, List<Resource>> throwDice(int dicethrow) {
Map<Faction,List<Resource>> returnMap= new HashMap<>(); if (dicethrow == 7) {
handleDiceThrow7();
return null;
} else {
Map<Faction, List<Resource>> returnMap = new HashMap<>();
List<Point> diceValueFields = board.getFieldsForDiceValue(dicethrow); List<Point> diceValueFields = board.getFieldsForDiceValue(dicethrow);
for (Player player : allPlayers) { for (Player player : allPlayers) {
returnMap.put(player.getFaction(), new ArrayList()); returnMap.put(player.getFaction(), new ArrayList());
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) {
returnMap.get(player.getFaction()).add(resource); returnMap.get(player.getFaction()).add(resource);
player.addResource(resource,1); player.addResource(resource, 1);
} }
} }
} }
return returnMap; return returnMap;
} }
}
private void handleDiceThrow7() {
for(Player player : allPlayers) {
HashMap<Resource, Integer> resources = player.getResources();
int countResources = 0;
for(Resource resource : resources.keySet()){
countResources += resources.get(resource);
}
if(countResources > 7){
int newCountResources = countResources / 2;
ArrayList<Resource> resourceArrayList = new ArrayList<>();
//for(Resource resource : ) todo complete
}
}
}
/** /**
* Builds a settlement at the specified position on the board. * Builds a settlement at the specified position on the board.
@ -431,7 +452,7 @@ public class SiedlerGame {
} }
} }
if(getLongestRoadFaction() == getCurrentPlayerFaction()){ if(getLongestRoadFaction() == getCurrentPlayerFaction()){
winPoints = winPoints + 2; winPoints += 2;
} }
return winPoints; return winPoints;
} }