Package org.freerealm.property

Examples of org.freerealm.property.Move


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

    public Move initializeFromNode(Realm realm, Node node) {
        Move move = new Move();
        int points = Integer.parseInt(node.getAttributes().getNamedItem("points").getNodeValue());
        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


     * @param realm Realm to execute the command
     * @return CommandResult
     */
    public CommandResult execute(Realm realm) {
        boolean tileHasAllowMovement = false;
        Move moveAbility = (Move) unit.getType().getAbility("Move");
        if (moveAbility == null) {
            return new CommandResult(CommandResult.RESULT_ERROR, "");
        }
        Tile toTile = realm.getTile(coordinate);
        Iterator<TileImprovementType> iterator = toTile.getImprovementsIterator();
        while (iterator.hasNext()) {
            TileImprovementType tileImprovement = iterator.next();
            if (tileImprovement.hasPropertyNamed("AllowMovement")) {
                tileHasAllowMovement = true;
                break;
            }
        }
        if (!moveAbility.hasTileType(toTile.getType()) && !tileHasAllowMovement) {
            return new CommandResult(CommandResult.RESULT_ERROR, "");
        }
        Vector<Coordinate> adjacentTiles = Utility.getNeighborCoordinates(realm, unit.getCoordinate());
        if (!adjacentTiles.contains(coordinate)) {
            return new CommandResult(CommandResult.RESULT_ERROR, "");
View Full Code Here

        if (!unit.getPlayer().isCoordinateExplored(coordinate)) {
            return false;
        }

        Move moveAbility = (Move) unit.getType().getAbility("Move");
        if (moveAbility == null) {
            return false;
        }

        if (!ignoreOtherPlayers && isTileBlockedByOtherPlayers(tile, unit)) {
            return false;
        }

        //TODO : Use set movement point instead of checking for roads
        TileImprovementType road = realm.getTileImprovementTypeManager().getImprovement("Road");
        if (tile.hasImprovement(road)) {
            return true;
        }

        if (!moveAbility.hasTileType(tile.getType())) {
            return false;
        }
        return true;
    }
View Full Code Here

    public void setName(String name) {
        this.name = name;
    }

    public int getMovementPoints() {
        Move move = (Move) getAbility("Move");
        if (move != null) {
            return move.getPoints();
        } else {
            return 0;
        }
    }
View Full Code Here

TOP

Related Classes of org.freerealm.property.Move

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.