// Update the current players resource ratios according to the given vertex private void updatePort(Vertex v) { Player current = GameManager.instance.getCurrentPlayer(); int[] ratios = current.getResourceRatios(); Enums.PortType port = v.getPortType(); // If the port is generic, update the ratios accordingly if (port == Enums.PortType.GENERIC) { for (int i = 0; i < ratios.Length; i++) { if (ratios [i] > 3) { ratios [i] = 3; } } current.updateResourceRatios(ratios); // If there is a specific port, update the correct ratio } else if (port != Enums.PortType.NONE) { current.updateResourceRatio(getResourceFromPort(port), 2); } }
// Get a resource type from a port type private Enums.ResourceType getResourceFromPort(Enums.PortType port) { switch (port) { case Enums.PortType.BRICK: return(Enums.ResourceType.BRICK); case Enums.PortType.WOOL: return(Enums.ResourceType.WOOL); case Enums.PortType.ORE: return(Enums.ResourceType.ORE); case Enums.PortType.LUMBER: return(Enums.ResourceType.LUMBER); case Enums.PortType.GRAIN: return(Enums.ResourceType.GRAIN); default: return(Enums.ResourceType.NONE); } }