Package org.freerealm.property

Examples of org.freerealm.property.ProduceResource


        xml.append("</ProduceResource>");
        return xml.toString();
    }

    public ProduceResource initializeFromNode(Realm realm, Node node) {
        ProduceResource produceResource = new ProduceResource();
        Node inputNode = XMLConverterUtility.findNode(node, "Input");
        if (inputNode != null) {
            for (Node subNode = inputNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
                if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                    if (subNode.getNodeName().equals("Resource")) {
                        int id = Integer.parseInt(subNode.getAttributes().getNamedItem("id").getFirstChild().getNodeValue());
                        int amount = Integer.parseInt(subNode.getAttributes().getNamedItem("quantity").getFirstChild().getNodeValue());
                        Resource resource = realm.getResourceManager().getResource(id);
                        produceResource.addInput(resource, amount);
                    }
                }
            }
        }
        Node outputNode = XMLConverterUtility.findNode(node, "Output");
        if (outputNode != null) {
            for (Node subNode = outputNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
                if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                    if (subNode.getNodeName().equals("Resource")) {
                        int id = Integer.parseInt(subNode.getAttributes().getNamedItem("id").getFirstChild().getNodeValue());
                        int amount = Integer.parseInt(subNode.getAttributes().getNamedItem("quantity").getFirstChild().getNodeValue());
                        int max = Integer.parseInt(subNode.getAttributes().getNamedItem("max").getFirstChild().getNodeValue());
                        Resource resource = realm.getResourceManager().getResource(id);
                        produceResource.addOutput(resource, amount, max);
                    }
                }
            }
        }
        return produceResource;
View Full Code Here


        int inputQuantity = 0;
        Iterator propertyIterator = getPropertiesIterator();
        while (propertyIterator.hasNext()) {
            Property property = (Property) propertyIterator.next();
            if (property instanceof ProduceResource) {
                ProduceResource produceResource = (ProduceResource) property;
                inputQuantity = inputQuantity + produceResource.getInputQuantity(resource);
            }
        }
        return inputQuantity;
    }
View Full Code Here

        int outputQuantity = 0;
        Iterator propertyIterator = getPropertiesIterator();
        while (propertyIterator.hasNext()) {
            Property property = (Property) propertyIterator.next();
            if (property instanceof ProduceResource) {
                ProduceResource produceResource = (ProduceResource) property;
                outputQuantity = outputQuantity + produceResource.getOutputQuantity(resource);
            }
        }
        return outputQuantity;
    }
View Full Code Here

        int maximumOutputQuantity = 0;
        Iterator propertyIterator = getPropertiesIterator();
        while (propertyIterator.hasNext()) {
            Property property = (Property) propertyIterator.next();
            if (property instanceof ProduceResource) {
                ProduceResource produceResource = (ProduceResource) property;
                maximumOutputQuantity = maximumOutputQuantity + produceResource.getMaximumOutputQuantity(resource);
            }
        }
        return maximumOutputQuantity;
    }
View Full Code Here

        Iterator<Resource> inputResourcesIterator = null;
        Iterator propertyIterator = getPropertiesIterator();
        while (propertyIterator.hasNext()) {
            Property property = (Property) propertyIterator.next();
            if (property instanceof ProduceResource) {
                ProduceResource produceResource = (ProduceResource) property;
                inputResourcesIterator = produceResource.getInputResourcesIterator();
            }
        }
        return inputResourcesIterator;
    }
View Full Code Here

        Iterator<Resource> outputResourcesIterator = null;
        Iterator propertyIterator = getPropertiesIterator();
        while (propertyIterator.hasNext()) {
            Property property = (Property) propertyIterator.next();
            if (property instanceof ProduceResource) {
                ProduceResource produceResource = (ProduceResource) property;
                outputResourcesIterator = produceResource.getOutputResourcesIterator();
            }
        }
        return outputResourcesIterator;
    }
View Full Code Here

TOP

Related Classes of org.freerealm.property.ProduceResource

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.