fixing Method checkResourceToBuild
This commit is contained in:
		
							parent
							
								
									da6913d997
								
							
						
					
					
						commit
						4c56518ba0
					
				| 
						 | 
				
			
			@ -95,10 +95,17 @@ public class Player {
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
   //returns true if player has enough resources else false
 | 
			
		||||
    private boolean checkRessourceToBuild(List<Config.Resource> liste) {
 | 
			
		||||
        for (Config.Resource resource : liste) {
 | 
			
		||||
            int possesion = resources.get(resource);
 | 
			
		||||
            if (possesion == 0) {
 | 
			
		||||
    private boolean checkResourceToBuild(List<Config.Resource> list) {
 | 
			
		||||
        HashMap<Config.Resource, Integer> costs = new HashMap<>();
 | 
			
		||||
        for(Config.Resource resource : list){
 | 
			
		||||
            if(costs.containsKey(resource)){
 | 
			
		||||
                costs.put(resource, costs.get(resource) + 1);
 | 
			
		||||
            } else {
 | 
			
		||||
                costs.put(resource, 1);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        for (Config.Resource resource : costs.keySet()) {
 | 
			
		||||
            if (resources.get(resource) < costs.get(resource)) {
 | 
			
		||||
                return false;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -106,5 +113,4 @@ public class Player {
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -479,11 +479,11 @@ public class SiedlerGame {
 | 
			
		|||
     */
 | 
			
		||||
    public boolean tradeWithBankFourToOne(Resource offer, Resource want) {
 | 
			
		||||
        Player player = allPlayers.get(activePlayer);
 | 
			
		||||
         if(player.getSpecificResource(offer) >= FOUR_TO_ONE_TRADE_OFFER && addResourcesToPlayer(player, want, FOUR_TO_ONE_TRADE_WANT)){
 | 
			
		||||
             substractResourceFromPlayer(player, offer, FOUR_TO_ONE_TRADE_OFFER);
 | 
			
		||||
             return true;
 | 
			
		||||
         }
 | 
			
		||||
         return false;
 | 
			
		||||
        if(player.getSpecificResource(offer) >= FOUR_TO_ONE_TRADE_OFFER && addResourcesToPlayer(player, want, FOUR_TO_ONE_TRADE_WANT)){
 | 
			
		||||
            substractResourceFromPlayer(player, offer, FOUR_TO_ONE_TRADE_OFFER);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue