Package com.jcloisterzone.feature

Examples of com.jcloisterzone.feature.MultiTileFeature


        private List<FeaturePointer> wagonMoves = new ArrayList<>();

        @Override
        public boolean visit(Feature feature) {
            if (feature instanceof MultiTileFeature) {
                MultiTileFeature f = (MultiTileFeature) feature;
                MultiTileFeature[] edges = f.getEdges();
                for (int i = 0; i < edges.length; i++) {
                    if (edges[i] == f) { //special value - neigbouring abbey
                        int j = 0;
                        for (Location side : Location.sides()) {
                            if (side.intersect(f.getLocation()) != null) {
                                if (j == i) {
                                    //Abbey at side;
                                    Position target = f.getTile().getPosition().add(side);
                                    Tile abbeyTile = getBoard().get(target);
                                    assert abbeyTile.isAbbeyTile();
                                    if (!abbeyTile.getCloister().walk(new IsOccupiedOrCompleted())) {
                                        wagonMoves.add(new FeaturePointer(target, Location.CLOISTER));
                                    }
View Full Code Here


    /** merge this to another tile - method argument is tile placed before */
    protected void merge(Tile tile, Location loc) {
        //if (logger.isDebugEnabled()) logger.debug("Merging " + id + " with " + tile.getId());
        Location oppositeLoc = loc.rev();
        MultiTileFeature oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeLoc);
        if (oppositePiece != null) {
            if (isAbbeyTile()) {
                oppositePiece.setAbbeyEdge(oppositeLoc);
            } else {
                MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(loc);
                oppositePiece.setEdge(oppositeLoc, thisPiece);
                thisPiece.setEdge(loc, oppositePiece);
            }
        }
        for (int i = 0; i < 2; i++) {
            Location halfSide = i == 0 ? loc.getLeftFarm() : loc.getRightFarm();
            Location oppositeHalfSide = halfSide.rev();
            oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeHalfSide);
            if (oppositePiece != null) {
                if (isAbbeyTile()) {
                    oppositePiece.setAbbeyEdge(oppositeHalfSide);
                } else {
                    MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(halfSide);
                    oppositePiece.setEdge(oppositeHalfSide, thisPiece);
                    thisPiece.setEdge(halfSide, oppositePiece);
                }
            }
        }
    }
View Full Code Here

        }
    }

    protected void unmerge(Tile tile, Location loc) {
        Location oppositeLoc = loc.rev();
        MultiTileFeature oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeLoc);
        if (oppositePiece != null) {
            oppositePiece.setEdge(oppositeLoc, null);
            if (!isAbbeyTile()) {
                MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(loc);
                thisPiece.setEdge(loc, null);
            }
        }
        for (int i = 0; i < 2; i++) {
            Location halfSide = i == 0 ? loc.getLeftFarm() : loc.getRightFarm();
            Location oppositeHalfSide = halfSide.rev();
            oppositePiece = (MultiTileFeature) tile.getFeaturePartOf(oppositeHalfSide);
            if (oppositePiece != null) {
                oppositePiece.setEdge(oppositeHalfSide, null);
                if (!isAbbeyTile()) {
                    MultiTileFeature thisPiece = (MultiTileFeature) getFeaturePartOf(halfSide);
                    thisPiece.setEdge(halfSide, null);
                }
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.jcloisterzone.feature.MultiTileFeature

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.