Package org.freerealm.resource

Examples of org.freerealm.resource.Resource


        StringBuffer xml = new StringBuffer();
        xml.append("<ResourceStorage>\n");
        Iterator<Entry<Resource, Integer>> resourceIterator = resourceStorageManager.getResources().entrySet().iterator();
        while (resourceIterator.hasNext()) {
            Entry<Resource, Integer> entry = (Entry<Resource, Integer>) resourceIterator.next();
            Resource resource = entry.getKey();
            int quantity = entry.getValue();
            xml.append("<storedResource>\n");
            xml.append("<resourceId>" + resource.getId() + "</resourceId>\n");
            xml.append("<resourceQuantity>" + quantity + "</resourceQuantity>\n");
            xml.append("</storedResource>\n");
        }
        xml.append("</ResourceStorage>");
        return xml.toString();
View Full Code Here


            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                Node resourceIdNode = XMLConverterUtility.findNode(subNode, "resourceId");
                Node resourceQuantityNode = XMLConverterUtility.findNode(subNode, "resourceQuantity");
                int resourceId = Integer.parseInt(resourceIdNode.getFirstChild().getNodeValue());
                int resourceQuantity = Integer.parseInt(resourceQuantityNode.getFirstChild().getNodeValue());
                Resource resource = realm.getResourceManager().getResource(resourceId);
                resourceStorageManager.setResourceQuantity(resource, resourceQuantity);
            }
        }
        return resourceStorageManager;
    }
View Full Code Here

                tileType.setId(id);
                for (Node subNode = tileTypeNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
                    if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                        String resourceName = subNode.getNodeName();
                        int quantity = Integer.parseInt(subNode.getFirstChild().getNodeValue().trim());
                        Resource resource = realm.getResourceManager().getResource(resourceName);
                        tileType.addProduction(resource, quantity);
                    }
                }
                tileTypeManager.addTileType(tileType);
            }
View Full Code Here

        StringBuffer xml = new StringBuffer();
        xml.append("<ProduceResource>\n");
        xml.append("<Input>\n");
        Iterator<Resource> inputResourcesIterator = produceResource.getInputResourcesIterator();
        while (inputResourcesIterator.hasNext()) {
            Resource resource = inputResourcesIterator.next();
            xml.append("<Resource id=\"" + resource.getId() + "\" quantity=\"" + produceResource.getInputQuantity(resource) + "\"/>\n");
        }
        xml.append("</Input>\n");
        xml.append("<Output>\n");
        Iterator<Resource> outputResourcesIterator = produceResource.getOutputResourcesIterator();
        while (outputResourcesIterator.hasNext()) {
            Resource resource = outputResourcesIterator.next();
            xml.append("<Resource ");
            xml.append("id=\"" + resource.getId() + "\" ");
            xml.append("quantity=\"" + produceResource.getOutputQuantity(resource) + "\" ");
            xml.append("max=\"" + produceResource.getMaximumOutputQuantity(resource) + "\"/>\n");
        }
        xml.append("</Output>\n");
        xml.append("</ProduceResource>");
View Full Code Here

            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);
                    }
                }
            }
        }
View Full Code Here

    public String toXML() {
        StringBuffer xml = new StringBuffer();
        xml.append("<Resources>\n");
        for (Iterator it = resourceManager.getResourcesIterator(); it.hasNext();) {
            Resource resource = (Resource) it.next();
            xml.append((new ResourceXMLWrapper(resource)).toXML() + "\n");
        }
        xml.append("</Resources>");
        return xml.toString();
    }
View Full Code Here

    public void initializeFromNode(Realm realm, Node node) {
        for (Node resourceNode = node.getFirstChild(); resourceNode != null; resourceNode = resourceNode.getNextSibling()) {
            if (resourceNode.getNodeType() == Node.ELEMENT_NODE) {
                String name = resourceNode.getAttributes().getNamedItem("name").getNodeValue();
                Resource resource = new Resource(name);
                String idString = resourceNode.getAttributes().getNamedItem("id").getNodeValue();
                int id = Integer.parseInt(idString);
                resource.setId(id);
                resourceManager.addResource(resource);
            }
        }
    }
View Full Code Here

        xml.append("\" defencePercentage=\"");
        xml.append(tileType.getDefencePercentage());
        xml.append("\">\n");
        Iterator<Resource> productionIterator = tileType.getProduction().keySet().iterator();
        while (productionIterator.hasNext()) {
            Resource resource = productionIterator.next();
            xml.append("<");
            xml.append(resource.getName());
            xml.append(">");
            xml.append(tileType.getProduction().get(resource));
            xml.append("</");
            xml.append(resource.getName());
            xml.append(">\n");
        }
        xml.append("</TileType>");
        return xml.toString();
    }
View Full Code Here

        xml.append("capacity=\"");
        xml.append(containerProperty.getCapacity());
        xml.append("\" >\n");
        Iterator<Resource> resourceIterator = containerProperty.getResourcesIterator();
        while (resourceIterator.hasNext()) {
            Resource resource = resourceIterator.next();
            xml.append("<Resource>" + resource.getName() + "</Resource>\n");
        }
        Iterator<Integer> unitTypeIterator = containerProperty.getUnitTypesIterator();
        while (unitTypeIterator.hasNext()) {
            Integer unitTypeId = unitTypeIterator.next();
            xml.append("<UnitType>" + unitTypeId.intValue() + "</UnitType>\n");
View Full Code Here

        containerProperty.setCapacity(Integer.parseInt(capacityValue));
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("Resource")) {
                    String resourceNameValue = subNode.getFirstChild().getNodeValue();
                    Resource resource = realm.getResourceManager().getResource(resourceNameValue);
                    containerProperty.addResource(resource);
                } else if (subNode.getNodeName().equals("UnitType")) {
                    String unitTypeIdValue = subNode.getFirstChild().getNodeValue();
                    int unitTypeId = Integer.parseInt(unitTypeIdValue);
                    containerProperty.addUnitType(unitTypeId);
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.