Package org.freerealm.property

Examples of org.freerealm.property.BuildTileImprovement


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

    public BuildTileImprovement initializeFromNode(Realm realm, Node node) {
        BuildTileImprovement buildTileImprovement = new BuildTileImprovement();
        String productionPointsValue = node.getAttributes().getNamedItem("productionPoints").getNodeValue();
        buildTileImprovement.setProductionPoints(Integer.parseInt(productionPointsValue));
        for (Node subNode = node.getFirstChild(); subNode != null; subNode = subNode.getNextSibling()) {
            if (subNode.getNodeType() == Node.ELEMENT_NODE) {
                if (subNode.getNodeName().equals("TileImprovementType")) {
                    String nameValue = subNode.getFirstChild().getNodeValue();
                    TileImprovementType tileImprovementTypeValue = (TileImprovementType) realm.getTileImprovementTypeManager().getImprovement(nameValue);
                    buildTileImprovement.getTileImprovements().add(tileImprovementTypeValue);
                }
            }
        }
        return buildTileImprovement;
    }
View Full Code Here


        setRealm(realm);
    }

    @Override
    public void execute(Realm realm) {
        BuildTileImprovement buildTileImprovement = (BuildTileImprovement) getUnit().getType().getAbility("BuildTileImprovement");
        if (buildTileImprovement != null) {
            Tile tile = realm.getTile(getUnit().getCoordinate());
            if (buildTileImprovement.canBuildTileImprovement(tileImprovementType, tile)) {
                int productionCost = tileImprovementType.getProductionCost();
                int productionPoints = buildTileImprovement.getProductionPoints();
                int turnsNeeded = (productionCost / productionPoints);
                int turnsSpent = realm.getNumberOfTurns() - getTurnGiven();
                if (turnsSpent >= turnsNeeded) {
                    AddTileImprovementCommand addTileImprovementCommand = new AddTileImprovementCommand(tile, tileImprovementType);
                    Executor.getInstance().execute(addTileImprovementCommand);
View Full Code Here

        this.tileImprovementType = tileImprovementType;
    }

    @Override
    public int getRemainingTurns() {
        BuildTileImprovement buildTileImprovement = (BuildTileImprovement) getUnit().getType().getAbility("BuildTileImprovement");
        if (buildTileImprovement != null) {
            int productionCost = tileImprovementType.getProductionCost();
            int productionPoints = buildTileImprovement.getProductionPoints();
            int turnsNeeded = (productionCost / productionPoints);
            int turnsSpent = getRealm().getNumberOfTurns() - getTurnGiven();
            return turnsNeeded - turnsSpent;
        }
        return -1;
View Full Code Here

TOP

Related Classes of org.freerealm.property.BuildTileImprovement

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.