From f6865451a63fe4982ae1a210b7a79d5ea104e29d Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sat, 4 Dec 2021 13:20:09 +0100 Subject: [PATCH] added Method handleDiceThrow7 in SiedlerGame --- src/ch/zhaw/catan/SiedlerGame.java | 43 ++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java index 2b8b00c..ccc8d2e 100644 --- a/src/ch/zhaw/catan/SiedlerGame.java +++ b/src/ch/zhaw/catan/SiedlerGame.java @@ -198,21 +198,42 @@ public class SiedlerGame { * @return the resource cards added to the stock of the different players */ public Map> throwDice(int dicethrow) { - 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){ - returnMap.get(player.getFaction()).add(resource); - player.addResource(resource,1); + if (dicethrow == 7) { + handleDiceThrow7(); + return null; + } else { + 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) { + returnMap.get(player.getFaction()).add(resource); + player.addResource(resource, 1); + } } } + return returnMap; } - return returnMap; } + private void handleDiceThrow7() { + for(Player player : allPlayers) { + HashMap resources = player.getResources(); + int countResources = 0; + for(Resource resource : resources.keySet()){ + countResources += resources.get(resource); + } + if(countResources > 7){ + int newCountResources = countResources / 2; + ArrayList resourceArrayList = new ArrayList<>(); + //for(Resource resource : ) todo complete + } + } + } + + /** * Builds a settlement at the specified position on the board. * @@ -431,7 +452,7 @@ public class SiedlerGame { } } if(getLongestRoadFaction() == getCurrentPlayerFaction()){ - winPoints = winPoints + 2; + winPoints += 2; } return winPoints; }