moved handleDiceThrow7 in Player.java
This commit is contained in:
		
							parent
							
								
									79a0b9175e
								
							
						
					
					
						commit
						6bd4f1dcbe
					
				| 
						 | 
					@ -146,4 +146,16 @@ public class Player {
 | 
				
			||||||
        return true;
 | 
					        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<Config.Resource> resourceArrayList = new ArrayList<>();
 | 
				
			||||||
 | 
					            //for(Resource resource : ) todo complete
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -14,7 +14,7 @@ public class Siedler {
 | 
				
			||||||
        boolean diceThrown = false;
 | 
					        boolean diceThrown = false;
 | 
				
			||||||
        while (running){
 | 
					        while (running){
 | 
				
			||||||
            Config.Faction currentPlayerFaction = game.getCurrentPlayerFaction();
 | 
					            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);
 | 
					            parser.playerTurn(currentPlayerFaction);
 | 
				
			||||||
            if(!diceThrown) {
 | 
					            if(!diceThrown) {
 | 
				
			||||||
                throwDice(game, parser);
 | 
					                throwDice(game, parser);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -203,14 +203,16 @@ 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();
 | 
					            for(Player player : allPlayers) {
 | 
				
			||||||
 | 
					                player.handleDiceThrow7();
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
        } 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);
 | 
				
			||||||
            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){
 | 
				
			||||||
                        //TODO: Check if Resource Null notwendig?
 | 
					                        //TODO: Check if Resource Null notwendig?
 | 
				
			||||||
                        returnMap.get(player.getFaction()).add(resource);
 | 
					                        returnMap.get(player.getFaction()).add(resource);
 | 
				
			||||||
| 
						 | 
					@ -224,21 +226,6 @@ public class SiedlerGame {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue