package ch.zhaw.catan;

import java.util.HashMap;


public class Bank {
    private final HashMap<Config.Resource, Integer> resources = new HashMap<>();

    public Bank() {
        resources.putAll(Config.INITIAL_RESOURCE_CARDS_BANK);

    }

    public void storeResourceToBank(Config.Resource resource, int numberOfResources) {
        resources.put(resource, resources.get(resource) + numberOfResources);
    }

    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;
        }
    }
}
