Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Position


        @Override
        public boolean visit(Feature feature) {
            City city = (City) feature;
            if (city.isBesieged()) { //cloister must border Cathar tile
                Position p = city.getTile().getPosition();
                for (Tile tile : getBoard().getAdjacentAndDiagonalTiles(p)) {
                    if (tile.hasCloister()) {
                        result = true;
                        return false; //do not continue, besieged cloister exists
                    }
View Full Code Here


            City city = (City) feature;
            if (city.isBesieged()) {
                isBesieged = true;
            }

            Position p = city.getTile().getPosition();
            for (Tile tile : getBoard().getAdjacentAndDiagonalTiles(p)) {
                if (tile.hasCloister()) {
                    cloisterExists = true;
                    break;
                }
View Full Code Here

    public void moveDragon(Position p) {
        if (!dragonCap.getAvailDragonMoves().contains(p)) {
            throw new IllegalArgumentException("Invalid dragon move.");
        }
        Player player = getActivePlayer();
        Position fromPosition = dragonCap.getDragonPosition();
        dragonCap.moveDragon(p);
        for (Meeple m : game.getDeployedMeeples()) {
            if (m.at(p) && m.canBeEatenByDragon()) {
                m.undeploy();
            }
View Full Code Here

            placedTunnelCurrentTurn = (Road) getBoard().get(XmlUtils.extractPosition(el)).getFeature(Location.valueOf(el.getAttribute("location")));
        }
        nl = node.getElementsByTagName("tunnel");
        for (int i = 0; i < nl.getLength(); i++) {
            Element el = (Element) nl.item(i);
            Position pos = XmlUtils.extractPosition(el);
            Location loc = Location.valueOf(el.getAttribute("location"));
            Road road = (Road) getBoard().get(pos).getFeature(loc);
            if (!road.isTunnelEnd()) {
                logger.error("Tunnel end does not exist.");
                continue;
View Full Code Here

        if (snapshot != null) {
            NodeList nl = snapshot.getTileElements();
            for (int i = 0; i < nl.getLength(); i++) {
                Element el = (Element) nl.item(i);
                Position pos = XmlUtils.extractPosition(el);
                if (pos.x <= left) left = pos.x - 1;
                if (pos.x >= right) right = pos.x + 1;
                if (pos.y <= top) top = pos.y - 1;
                if (pos.y >= bottom) bottom = pos.y + 1;
            }
View Full Code Here

    // delegated UI methods

    public void tileEvent(TileEvent ev, TileLayer tileLayer) {
        Tile tile = ev.getTile();
        Position p = ev.getPosition();

        hideLayer(AbstractTilePlacementLayer.class);

        if (ev.getType() == TileEvent.PLACEMENT) {
            if (p.x == left) --left;
View Full Code Here

    }

    private void tilePlaced(TileEvent ev) {
        Tile tile = ev.getTile();
        if (ev.getType() == TileEvent.PLACEMENT && tile.hasTrigger(TileTrigger.VOLCANO)) {
            Position fromPosition = dragonPosition;
            dragonPosition = tile.getPosition();
            getTilePack().setGroupState("dragon", TileGroupState.ACTIVE);
            game.post(new NeutralFigureMoveEvent(NeutralFigureMoveEvent.DRAGON, null, fromPosition, dragonPosition));
        }
    }
View Full Code Here

    public Set<Position> getAvailDragonMoves() {
        Set<Position> result = new HashSet<>();
        FairyCapability fairyCap = game.getCapability(FairyCapability.class);
        for (Position offset: Position.ADJACENT.values()) {
            Position position = dragonPosition.add(offset);
            Tile tile = getBoard().get(position);
            if (tile == null || CountCapability.isTileForbidden(tile)) continue;
            if (dragonVisitedTiles != null && dragonVisitedTiles.contains(position)) { continue; }
            if (fairyCap != null && position.equals(fairyCap.getFairyPosition())) { continue; }
            result.add(position);
        }
        return result;
    }
View Full Code Here

            //check U-turn
            Location continueRiver = tile.getRiver().rotateCW(tile.getRotation()).substract(tileRelativePosition);
            if (continueRiver == Location.INNER_FARM) return true; //lake
            for (Location continueSide: Location.sides()) { //split beacuse of river fork
                if (continueRiver.intersect(continueSide) == null) continue;
                Position pCheck = p.add(continueSide).add(continueSide.rotateCW(Rotation.R90));
                if (getBoard().get(pCheck) != null) return false;
                pCheck = p.add(continueSide).add(continueSide.rotateCCW(Rotation.R90));
                if (getBoard().get(pCheck) != null) return false;
                pCheck = p.add(continueSide).add(continueSide);
                if (getBoard().get(pCheck) != null) return false;
View Full Code Here

            lastIncreasedTower = XmlUtils.extractPosition((Element) nl.item(0));
        }
        nl = node.getElementsByTagName("tower");
        for (int i = 0; i < nl.getLength(); i++) {
            Element te = (Element) nl.item(i);
            Position towerPos = XmlUtils.extractPosition(te);
            Tower tower = getBoard().get(towerPos).getTower();
            tower.setHeight(Integer.parseInt(te.getAttribute("height")));
            towers.add(towerPos);
            if (tower.getHeight() > 0) {
                game.post(new TowerIncreasedEvent(null, towerPos, tower.getHeight()));
View Full Code Here

TOP

Related Classes of com.jcloisterzone.board.Position

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.