Package org.freerealm.settlement.workforce

Examples of org.freerealm.settlement.workforce.WorkForce


    public void initializeFromNode(Realm realm, Node node) {
        workForceManager.clearAssignedWorkForce();
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                WorkForce workForce = new WorkForce();
                (new WorkForceXMLWrapper(workForce)).initializeFromNode(realm, subNode);
                workForceManager.addWorkForce(workForce.getCoordinate(), workForce);
            }
        }
    }
View Full Code Here


    private int getTotalResourceProduction(Resource resource) {
        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;
            }
        }
        return totalProduction;
    }
View Full Code Here

    private void manageWorkforce() {
        if (getProductionWorkforce() < 0) {
            int populationDecrease = -1 * getProductionWorkforce();
            Iterator<WorkForce> workforceIterator = getWorkForceManager().getWorkForceIterator();
            while (workforceIterator.hasNext()) {
                WorkForce workForce = (WorkForce) workforceIterator.next();
                if (workForce.getNumberOfWorkers() > populationDecrease) {
                    workForce.setNumberOfWorkers(workForce.getNumberOfWorkers() - populationDecrease);
                    return;
                } else {
                    populationDecrease = populationDecrease - workForce.getNumberOfWorkers();
                    workForce.setNumberOfWorkers(0);
                }
            }
        }
    }
View Full Code Here

    public int getTotalWorkers() {
        int totalWorkers = 0;
        Iterator<WorkForce> workforceIterator = getWorkForceIterator();
        while (workforceIterator.hasNext()) {
            WorkForce workForce = (WorkForce) workforceIterator.next();
            totalWorkers = totalWorkers + workForce.getNumberOfWorkers();
        }
        return totalWorkers;
    }
View Full Code Here

TOP

Related Classes of org.freerealm.settlement.workforce.WorkForce

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.