Package org.freerealm.tile

Examples of org.freerealm.tile.TileType


    public CommandResult execute(Realm realm) {
        WorldMap currentMap = realm.getWorldMap();
        int probabilityTotal = 0;
        Iterator<TileType> tileIterator = realm.getTileTypeManager().getTileTypesIterator();
        while (tileIterator.hasNext()) {
            TileType tileType = tileIterator.next();
            probabilityTotal = probabilityTotal + tileType.getProbability();
        }
        int newColumnsToAdd = width - currentMap.getWidth();
        int newRowsToAdd = height - currentMap.getHeight();
        int columnSegmentSize = currentMap.getWidth() / newColumnsToAdd;
        int rowSegmentSize = currentMap.getHeight() / newRowsToAdd;
View Full Code Here


    }

    private TileType generateTileType(Realm realm, int probabilityTotal) {
        int randomNumber = rand.nextInt(probabilityTotal);
        Iterator tileIterator = realm.getTileTypeManager().getTileTypesIterator();
        TileType tileType = null;
        while (tileIterator.hasNext()) {
            tileType = (TileType) tileIterator.next();
            randomNumber = randomNumber - tileType.getProbability();
            if (randomNumber < 0) {
                return tileType;
            }
        }
        return tileType;
View Full Code Here

    public String toXML() {
        StringBuffer xml = new StringBuffer();
        xml.append("<TileTypes>\n");
        for (Iterator<TileType> it = tileTypeManager.getTileTypesIterator(); it.hasNext();) {
            TileType tileType = it.next();
            xml.append((new TileTypeXMLWrapper(tileType)).toXML() + "\n");
        }
        xml.append("</TileTypes>");
        return xml.toString();
    }
View Full Code Here

                String name = tileTypeNode.getAttributes().getNamedItem("name").getNodeValue();
                int movementCost = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("movementCost").getNodeValue());
                int probability = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("probability").getNodeValue());
                int defencePercentage = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("defencePercentage").getNodeValue());
                int id = Integer.parseInt(tileTypeNode.getAttributes().getNamedItem("id").getNodeValue());
                TileType tileType = new TileType();
                tileType.setName(name);
                tileType.setMovementCost(movementCost);
                tileType.setProbability(probability);
                tileType.setDefencePercentage(defencePercentage);
                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

        Tile tile = new Tile();
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("type")) {
                    int tileTypeId = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    TileType tileType = realm.getTileTypeManager().getTileType(tileTypeId);
                    tile.setType(tileType);
                } else if (subNode.getNodeName().equals("improvements")) {
                    tile.clearImprovements();
                    for (Node improvementNode = subNode.getFirstChild(); improvementNode != null; improvementNode = improvementNode.getNextSibling()) {
                        if (improvementNode.getNodeType() == Node.ELEMENT_NODE) {
View Full Code Here

        tileImprovementType.setUpkeepCost(upkeepCost);
        Node tileTypesNode = XMLConverterUtility.findNode(node, "tileTypes");
        for (Node tileTypeNode = tileTypesNode.getFirstChild(); tileTypeNode != null; tileTypeNode = tileTypeNode.getNextSibling()) {
            if (tileTypeNode.getNodeType() == Node.ELEMENT_NODE) {
                int tileTypeId = Integer.parseInt(tileTypeNode.getFirstChild().getNodeValue());
                TileType tileType = realm.getTileTypeManager().getTileType(tileTypeId);
                tileImprovementType.addTileType(tileType);
            }
        }
        Node propertiesNode = XMLConverterUtility.findNode(node, "properties");
        for (Node propertyNode = propertiesNode.getFirstChild(); propertyNode != null; propertyNode = propertyNode.getNextSibling()) {
View Full Code Here

        xml.append("<name>" + vegetation.getName() + "</name>\n");
        xml.append("<turnsNeededToClear>" + vegetation.getTurnsNeededToClear() + "</turnsNeededToClear>\n");
        xml.append("<tileTypes>\n");
        Iterator<TileType> iterator = vegetation.getGrowableTileTypesIterator();
        while (iterator.hasNext()) {
            TileType tileType = iterator.next();
            xml.append("<tileTypeId>" + tileType.getId() + "</tileTypeId>\n");
        }
        xml.append("</tileTypes>\n");
        xml.append("<properties>\n");
        Iterator<Property> propertyIterator = vegetation.getPropertiesIterator();
        while (propertyIterator.hasNext()) {
View Full Code Here

        Node tileTypesNode = XMLConverterUtility.findNode(node, "tileTypes");
        for (Node subNode = tileTypesNode.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("tileTypeId")) {
                    int tileTypeId = Integer.parseInt(subNode.getFirstChild().getNodeValue());
                    TileType tileType = realm.getTileTypeManager().getTileType(tileTypeId);
                    vegetationImpl.addGrowableTileType(tileType);
                }
            }
        }
        Node propertiesNode = XMLConverterUtility.findNode(node, "properties");
View Full Code Here

    public String toXML(Move move) {
        StringBuffer xml = new StringBuffer();
        xml.append("<Move points=\"" + move.getPoints() + "\">\n");
        Iterator<TileType> tileTypesIterator = move.getTileTypesIterator();
        while (tileTypesIterator.hasNext()) {
            TileType tileType = tileTypesIterator.next();
            xml.append("<TileType>" + tileType.getName() + "</TileType>\n");
        }
        xml.append("</Move>");
        return xml.toString();
    }
View Full Code Here

        move.setPoints(points);
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("TileType")) {
                    String tileTypeNameValue = subNode.getFirstChild().getNodeValue();
                    TileType tileType = realm.getTileTypeManager().getTileType(tileTypeNameValue);
                    move.addTileType(tileType);
                }
            }
        }
        return move;
View Full Code Here

TOP

Related Classes of org.freerealm.tile.TileType

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.