package ch.zhaw.catan; import java.util.HashMap; /** * New Class PLayer * This class is here to add players to the game. * @author: Stefan Amador */ public class Player { private String name; private Config.Faction faction; private HashMap resources; private int roadsToUse; private int settlementsToUse; public Player (String name, Config.Faction faction){ //Datenfelder this.name = name; this.faction = faction; roadsToUse = Config.Structure.ROAD.getStockPerPlayer(); settlementsToUse = Config.Structure.SETTLEMENT.getStockPerPlayer(); //Ressourcen initialisiern resources = new HashMap<>(); for(Config.Resource resource : Config.Resource.values()) { resources.put(resource,0); } } /** * This method returns all the resources the player has at the moment * @return HashMap */ public HashMap getResources() { return resources; } public boolean buildRoad() { if (roadsToUse > 0) { roadsToUse--; return true; } return false; } public boolean buildSettlement() { if (settlementsToUse > 0) { settlementsToUse--; return true; } return false; } }