Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Location


    public static String getTileId(Expansion expansion, Element xml) {
        return expansion.getCode() + "." + xml.getAttribute("id");
    }

    public static  Location union(String[] locations) {
        Location u = null;
        for (String locStr : locations) {
            Location loc = Location.valueOf(locStr);
            u = loc.union(u);
        }
        return u;
    }
View Full Code Here


    public void prepareActions(List<PlayerAction<?>> actions, Set<FeaturePointer> followerOptions) {
        Position pos = getTile().getPosition();

        if (game.getActivePlayer().hasSpecialMeeple(Barn.class)) {
            BarnAction barnAction = null;
            Location corner = Location.WR.union(Location.NL);
            Location positionChange = Location.W;
            for (int i = 0; i < 4; i++) {
                if (isBarnCorner(corner, positionChange)) {
                    if (barnAction == null) {
                        barnAction = new BarnAction();
                        actions.add(barnAction);
                    }
                    barnAction.add(new FeaturePointer(pos, corner));
                }
                corner = corner.next();
                positionChange = positionChange.next();
            }
        }
    }
View Full Code Here

        case "CASTLE": featureType = Castle.class; break;
        case "BRIDGE": featureType = Bridge.class; break;
        case "@": featureType = null; break;
        default: throw new IllegalArgumentException("Unsupported feature "+featureName);
        }
        Location location = Location.valueOf(locationName);
        assert featureType == null || (location.isFarmLocation() ^ !featureType.equals(Farm.class)) : "improper location "+locationName;
        return new FeatureDescriptor(tileId, featureType, location);
    }
View Full Code Here

    public BridgeAction prepareMandatoryBridgeAction() {
        Tile tile = game.getCurrentTile();
        for (Entry<Location, Tile> entry : getBoard().getAdjacentTilesMap(tile.getPosition()).entrySet()) {
            Tile adjacent = entry.getValue();
            Location rel = entry.getKey();

            char adjacentSide = adjacent.getEdge(rel.rev());
            char tileSide = tile.getEdge(rel);
            if (tileSide != adjacentSide) {
                Location bridgeLoc = getBridgeLocationForAdjacent(rel);
                BridgeAction action = prepareTileBridgeAction(tile, null, bridgeLoc);
                if (action != null) return action;
                return prepareTileBridgeAction(adjacent, null, bridgeLoc);
            }
        }
View Full Code Here

        Tile tile = game.getCurrentTile();
        action = prepareTileBridgeAction(tile, action, Location.NS);
        action = prepareTileBridgeAction(tile, action, Location.WE);
        for (Entry<Location, Tile> entry : getBoard().getAdjacentTilesMap(tile.getPosition()).entrySet()) {
            Tile adjacent = entry.getValue();
            Location rel = entry.getKey();
            action = prepareTileBridgeAction(adjacent, action, getBridgeLocationForAdjacent(rel));
        }
        return action;
    }
View Full Code Here

    }

    private boolean isBridgePlacementAllowed(Tile tile, Position p, Location bridgeLoc) {
        if (!tile.isBridgeAllowed(bridgeLoc)) return false;
        for (Entry<Location, Tile> e : getBoard().getAdjacentTilesMap(p).entrySet()) {
            Location rel = e.getKey();
            if (rel.intersect(bridgeLoc) != null) {
                Tile adjacent = e.getValue();
                char adjacentSide = adjacent.getEdge(rel.rev());
                if (adjacentSide != 'R') return false;
            }
        }
        return true;
    }
View Full Code Here

                }
                handler.processApply(child, fd, af);
                if (XmlUtils.attributeBoolValue(child, "allRotations")) {
                    Rotation rot = Rotation.R90;
                    for (int ri = 0; ri < 3; ri++) {
                        Location rotatedLoc = fd.getLocation().rotateCW(rot);
                        FeatureDescriptor rotatedFd = new FeatureDescriptor(fd.getTileId(), fd.getFeatureType(), rotatedLoc);
                        af.concatenate(Rotation.R90.getAffineTransform(ResourcePlugin.NORMALIZED_SIZE));
                        handler.processApply(child, rotatedFd, af);
                        rot = rot.next();
                    }
View Full Code Here

    private boolean isTilePlacementWithBridgeAllowed(Tile tile, Position p, Location bridgeLoc) {
        if (!tile.isBridgeAllowed(bridgeLoc)) return false;

        for (Entry<Location, Tile> e : getBoard().getAdjacentTilesMap(p).entrySet()) {
            Tile adjacent = e.getValue();
            Location rel = e.getKey();

            char adjacentSide = adjacent.getEdge(rel.rev());
            char tileSide = tile.getEdge(rel);
            if (rel.intersect(bridgeLoc) != null) {
                if (adjacentSide != 'R') return false;
            } else {
                if (adjacentSide != tileSide) return false;
            }
        }
View Full Code Here

    private boolean isTilePlacementWithOneAdjacentBridgeAllowed(Tile tile, Position p) {
        boolean bridgeUsed = false;
        for (Entry<Location, Tile> e : getBoard().getAdjacentTilesMap(p).entrySet()) {
            Tile adjacent = e.getValue();
            Location rel = e.getKey();

            char tileSide = tile.getEdge(rel);
            char adjacentSide = adjacent.getEdge(rel.rev());

            if (tileSide != adjacentSide) {
                if (bridgeUsed) return false;
                if (tileSide != 'R') return false;

                Location bridgeLoc = getBridgeLocationForAdjacent(rel);
                if (!isBridgePlacementAllowed(adjacent, adjacent.getPosition(), bridgeLoc)) return false;
                bridgeUsed = true;
            }
        }
        return bridgeUsed; //ok if exactly one bridge is used
View Full Code Here


    @Override
    public void saveTileToSnapshot(Tile tile, Document doc, Element tileNode) {
        if (tile.getBridge() != null) {
            Location realLoc = tile.getBridge().getRawLocation();
            tileNode.setAttribute("bridge", realLoc.toString());
        }
    }
View Full Code Here

TOP

Related Classes of com.jcloisterzone.board.Location

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.