Bank Klasse erstellt (wird warscheinlich wieder entfernt da Funktionalität in SiedlerGame sein soll)
This commit is contained in:
		
							parent
							
								
									ebc63b996d
								
							
						
					
					
						commit
						2f9f93d862
					
				| 
						 | 
				
			
			@ -0,0 +1,36 @@
 | 
			
		|||
package ch.zhaw.catan;
 | 
			
		||||
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
public class Bank {
 | 
			
		||||
    private Map<Config.Resource, Integer> resources;
 | 
			
		||||
 | 
			
		||||
    public Bank(){
 | 
			
		||||
        resources = Config.INITIAL_RESOURCE_CARDS_BANK;
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean getResourceFromBank(Config.Resource resource,int numberOfResources) {
 | 
			
		||||
        if(resources.get(resource) >= numberOfResources) {
 | 
			
		||||
            Integer newResourceNumber = resources.get(resource) - numberOfResources;
 | 
			
		||||
            resources.put(resource, newResourceNumber);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean tradeWithBank(Config.Resource resourceToReceive, Config.Resource resourceToGive) {
 | 
			
		||||
        if(resources.get(resourceToReceive) >= 1){
 | 
			
		||||
            Integer newResourceReceived = resources.get(resourceToReceive) + 4;
 | 
			
		||||
            Integer newResourcesGiven = resources.get(resourceToGive) - 1;
 | 
			
		||||
            resources.put(resourceToReceive, newResourceReceived);
 | 
			
		||||
            resources.put(resourceToGive, newResourcesGiven);
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        else{
 | 
			
		||||
            return false;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Loading…
	
		Reference in New Issue