From 6bd4f1dcbe79172add0da3f5b723cf5e0bd54f5b Mon Sep 17 00:00:00 2001 From: schrom01 Date: Sat, 4 Dec 2021 17:03:51 +0100 Subject: [PATCH] moved handleDiceThrow7 in Player.java --- src/ch/zhaw/catan/Player.java | 12 ++++++++++++ src/ch/zhaw/catan/Siedler.java | 2 +- src/ch/zhaw/catan/SiedlerGame.java | 21 ++++----------------- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/ch/zhaw/catan/Player.java b/src/ch/zhaw/catan/Player.java index 1af8d51..c53847d 100644 --- a/src/ch/zhaw/catan/Player.java +++ b/src/ch/zhaw/catan/Player.java @@ -146,4 +146,16 @@ public class Player { return true; } + public void handleDiceThrow7() { + int countResources = 0; + for(Config.Resource resource : resources.keySet()){ + countResources += resources.get(resource); + } + if(countResources > 7){ + int newCountResources = countResources / 2; + ArrayList resourceArrayList = new ArrayList<>(); + //for(Resource resource : ) todo complete + } + } + } diff --git a/src/ch/zhaw/catan/Siedler.java b/src/ch/zhaw/catan/Siedler.java index eaee90e..de9da7a 100644 --- a/src/ch/zhaw/catan/Siedler.java +++ b/src/ch/zhaw/catan/Siedler.java @@ -14,7 +14,7 @@ public class Siedler { boolean diceThrown = false; while (running){ Config.Faction currentPlayerFaction = game.getCurrentPlayerFaction(); - parser.displayGameboard(game.getBoard().getTextView()); + parser.displayGameboard(game.getBoard().getTextView()); //todo jedesmal ausgeben? oder nur wenn neuer Spieler oder separater Befehl? parser.playerTurn(currentPlayerFaction); if(!diceThrown) { throwDice(game, parser); diff --git a/src/ch/zhaw/catan/SiedlerGame.java b/src/ch/zhaw/catan/SiedlerGame.java index 2366058..885710e 100644 --- a/src/ch/zhaw/catan/SiedlerGame.java +++ b/src/ch/zhaw/catan/SiedlerGame.java @@ -203,14 +203,16 @@ public class SiedlerGame { */ public Map> throwDice(int dicethrow) { if (dicethrow == 7) { - handleDiceThrow7(); + for(Player player : allPlayers) { + player.handleDiceThrow7(); + } } 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()); + List resources = board.getResourcesforFaction(field,player.getFaction()); for (Config.Resource resource : resources){ //TODO: Check if Resource Null notwendig? returnMap.get(player.getFaction()).add(resource); @@ -224,21 +226,6 @@ public class SiedlerGame { } - 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.