Package org.freerealm.resource

Examples of org.freerealm.resource.Resource


    public void initializeFromNode(Realm realm, Node node) {
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("resource")) {
                    int resourceId = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    Resource resourceValue = realm.getResourceManager().getResource(resourceId);
                    workForce.setResource(resourceValue);
                } else if (subNode.getNodeName().equals("numberOfWorkers")) {
                    int numberOfWorkersValue = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    workForce.setNumberOfWorkers(numberOfWorkersValue);
                } else if (subNode.getNodeName().equals("Coordinate")) {
View Full Code Here


        int totalProduction = 0;
        Iterator workforceIterator = getWorkForceManager().getWorkforce().entrySet().iterator();
        while (workforceIterator.hasNext()) {
            Entry entry = (Entry) workforceIterator.next();
            WorkForce workForce = (WorkForce) entry.getValue();
            Resource workForceResource = workForce.getResource();
            if (resource.equals(workForceResource)) {
                Coordinate coordinate = (Coordinate) entry.getKey();
                Tile tile = getRealm().getTile(coordinate);
                int producedQuantity = tile.getProduction(resource) * workForce.getNumberOfWorkers();
                totalProduction = totalProduction + producedQuantity;
View Full Code Here

    public ResourceStorageManager(Realm realm) {
        resources = new TreeMap<Resource, Integer>();
        Iterator<Resource> resourceIterator = realm.getResourceManager().getResourcesIterator();
        while (resourceIterator.hasNext()) {
            Resource resource = resourceIterator.next();
            setResourceQuantity(resource, 0);
        }
    }
View Full Code Here

    }

    private void manageColonyTerrainResourceProduction(Settlement colony) {
        Iterator resourceIterator = realm.getResourceManager().getResourcesIterator();
        while (resourceIterator.hasNext()) {
            Resource resource = (Resource) resourceIterator.next();
            colony.setResourceQuantity(resource, colony.getResourceQuantity(resource) + colony.getResourceProduction(resource));
        }
    }
View Full Code Here

        float outputMultiplier = 10000;
        Iterator<Resource> inputResourcesIterator = cityImprovement.getType().getInputResourcesIterator();
        if (inputResourcesIterator != null) {

            while (inputResourcesIterator.hasNext()) {
                Resource resource = inputResourcesIterator.next();
                int inputResourceQuantity = colony.getResourceQuantity(resource);
                int tempMultiplier = inputResourceQuantity / cityImprovement.getType().getInputQuantity(resource);
                if (tempMultiplier < outputMultiplier) {
                    outputMultiplier = tempMultiplier;
                }
            }
        }

        Iterator<Resource> outputResourcesIterator = cityImprovement.getType().getOutputResourcesIterator();
        if (outputResourcesIterator != null) {
            while (outputResourcesIterator.hasNext()) {
                Resource resource = outputResourcesIterator.next();
                int out = cityImprovement.getType().getOutputQuantity(resource);
                int maxOut = cityImprovement.getType().getMaximumOutputQuantity(resource);
                if (cityImprovement.getType().getMaximumWorkers() > 0) {
                    maxOut = maxOut * cityImprovement.getNumberOfWorkers() / cityImprovement.getType().getMaximumWorkers();
                }
                if (out * outputMultiplier > maxOut) {
                    outputMultiplier = (float) maxOut / (float) out;
                }
            }
        }

        inputResourcesIterator = cityImprovement.getType().getInputResourcesIterator();
        if (inputResourcesIterator != null) {
            while (inputResourcesIterator.hasNext()) {
                Resource resource = inputResourcesIterator.next();
                int resourceAmount = (int) (cityImprovement.getType().getInputQuantity(resource) * outputMultiplier);
                Executor.getInstance().execute(new ResourceRemoveCommand(colony, resource, resourceAmount));
            }
        }

        outputResourcesIterator = cityImprovement.getType().getOutputResourcesIterator();
        if (outputResourcesIterator != null) {
            while (outputResourcesIterator.hasNext()) {
                Resource resource = outputResourcesIterator.next();
                int resourceAmount = (int) (cityImprovement.getType().getOutputQuantity(resource) * outputMultiplier);
                Executor.getInstance().execute(new ResourceAddCommand(colony, resource, resourceAmount));
            }
        }

View Full Code Here

    private void manageCityProductionPoints(Settlement settlement) {
        settlement.setProductionPoints(settlement.getProductionPoints() + settlement.getProductionPointsPerTurn());
    }

    private void manageCityPopulation(Settlement settlement) {
        Resource foodResource = realm.getResourceManager().getResource(Resource.FOOD);
        int foodQuantity = settlement.getResourceQuantity(foodResource);
        int defaultPopulationChange = Integer.parseInt(realm.getProperty("default_population_change"));
        //if (settlement.getResourceProduction(foodResource) >= settlement.getFoodNeeded()) {
        if (foodQuantity >= settlement.getFoodNeeded()) {
            int populationChange = (settlement.getPopulation() * settlement.getPopulationIncreasePercent()) / 100;
View Full Code Here

    }

    private void manageCityStorage(Settlement settlement) {
        Iterator resourceIterator = realm.getResourceManager().getResourcesIterator();
        while (resourceIterator.hasNext()) {
            Resource resource = (Resource) resourceIterator.next();
            int storage = settlement.getTotalCapacity(resource);
            if (settlement.getResourceQuantity(resource) > storage) {
                int wastedAmount = settlement.getResourceQuantity(resource) - storage;
                StringBuffer messageText = new StringBuffer(wastedAmount + " units of " + resource + " is wasted in " + settlement.getName());
                ResourceWastedMessage message = new ResourceWastedMessage();
View Full Code Here

TOP

Related Classes of org.freerealm.resource.Resource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.