Package org.freerealm.property

Examples of org.freerealm.property.ContainerProperty


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

    public ContainerProperty initializeFromNode(Realm realm, Node node) {
        ContainerProperty containerProperty = new ContainerProperty();
        String capacityValue = node.getAttributes().getNamedItem("capacity").getNodeValue();
        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);
                } else if (subNode.getNodeName().equals("Population")) {
                    containerProperty.setAccomodatingPopulation(true);
                }
            }
        }
        return containerProperty;
    }
View Full Code Here


    public void setResourceQuantity(Resource resource, int quantity) {
        containerManager.setResourceQuantity(resource, quantity);
    }

    public int getRemainingCapacity(Resource resource) {
        ContainerProperty storeResource = (ContainerProperty) getType().getAbility("ContainerProperty");
        if (storeResource == null) {
            return 0;
        }
        if (!storeResource.hasResource(resource)) {
            return 0;
        }
        return getTotalCapacity(resource) - getTotalContainedWeight();
    }
View Full Code Here

        }
        return getTotalCapacity(resource) - getTotalContainedWeight();
    }

    public int getTotalCapacity() {
        ContainerProperty containerProperty = (ContainerProperty) getType().getAbility("ContainerProperty");
        if (containerProperty == null) {
            return 0;
        }
        return containerProperty.getCapacity();
    }
View Full Code Here

    public void setContainerManager(ContainerManager containerManager) {
        this.containerManager = containerManager;
    }

    public Iterator<Resource> getStorableResourcesIterator() {
        ContainerProperty containerProperty = (ContainerProperty) getType().getAbility("ContainerProperty");
        if (containerProperty == null) {
            return new Vector<Resource>().iterator();
        }
        return containerProperty.getResourcesIterator();
    }
View Full Code Here

    public Iterator<Resource> getContainedResourcesIterator() {
        return containerManager.getContainedResourcesIterator();
    }

    public boolean isStoringResource(Resource resource) {
        ContainerProperty containerProperty = (ContainerProperty) getType().getAbility("ContainerProperty");
        if (containerProperty == null) {
            return false;
        }
        return containerProperty.hasResource(resource);
    }
View Full Code Here

    public Iterator<Integer> getContainedUnitsIterator() {
        return containerManager.getContainedUnitsIterator();
    }

    public boolean canContainUnit(UnitType unitType) {
        ContainerProperty containerProperty = (ContainerProperty) getType().getAbility("ContainerProperty");
        if (containerProperty == null) {
            return false;
        }
        return containerProperty.hasUnitType(unitType.getId());
    }
View Full Code Here

    public void setContainedPopulation(int population) {
        containerManager.setContainedPopulation(population);
    }

    public boolean canContainPopulation() {
        ContainerProperty containerProperty = (ContainerProperty) getType().getAbility("ContainerProperty");
        if (containerProperty == null) {
            return false;
        }
        return containerProperty.isAccomodatingPopulation();
    }
View Full Code Here

TOP

Related Classes of org.freerealm.property.ContainerProperty

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.