Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Location


            int y = e.getY() - gridPanel.getOffsetY();
            if (x < 0) x += 1000 * size; //prevent mod from negative number
            if (y < 0) y += 1000 * size; //prevent mod from negative number
            x = x % size;
            y = y % size;
            Location swap = null;
            for (Entry<Location, Area> enrty : areas.entrySet()) {
                if (enrty.getValue().contains(x, y)) {
                    if (swap != null) { // 2 areas at point - select no one
                        swap = null;
                        break;
View Full Code Here


        }
        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

    public void initTile(Tile tile, Element xml) {
        NodeList nl;
        nl = xml.getElementsByTagName("river");
        assert nl.getLength() <= 1;
        if (nl.getLength() == 1) {
            Location river = XmlUtils.union(XmlUtils.asLocation((Element) nl.item(0)));
            tile.setRiver(river);
            if (tile.getSymmetry() != TileSymmetry.NONE) {
                if (tile.getRiver().isRotationOf(Location.WE)) {
                    tile.setSymmetry(TileSymmetry.S2);
                } else {
View Full Code Here

    public boolean isTilePlacementAllowed(Tile tile, Position p) {
        if (tile.getRiver() == null) return true;
        for (Entry<Location, Tile> e : getBoard().getAdjacentTilesMap(p).entrySet()) {

            //check river connection
            Location tileRelativePosition = e.getKey();
            Tile placedTile = e.getValue();
            if (placedTile.getRiver() == null) return false; //e.g. count of carcassone preplaced tiles
            boolean r1 = tileRelativePosition.rotateCCW(tile.getRotation()).isPartOf(tile.getRiver());
            boolean r2 = tileRelativePosition.rotateCCW(placedTile.getRotation()).rev().isPartOf(placedTile.getRiver());
            if (!(r1 & r2)) return false;

            //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);
View Full Code Here

    public List<Meeple> extractTileMeeples(Element tileEl, Game game, Position pos) throws SnapshotCorruptedException {
        NodeList nl = tileEl.getElementsByTagName("meeple");
        List<Meeple> result = new ArrayList<>();
        for (int i = 0; i < nl.getLength(); i++) {
            Element el = (Element) nl.item(i);
            Location loc = Location.valueOf(el.getAttribute("loc"));
            String meepleType = el.getAttribute("type");
            if (!meepleType.startsWith("com.")) { // 2.X snapshot compatibility
                meepleType = "com.jcloisterzone.figure." + meepleType;
            }
            Class<? extends Meeple> mt = (Class<? extends Meeple>) XmlUtils.classForName(meepleType);
View Full Code Here

    }

    private void tilePlaced(TileEvent ev) {
        if (ev.getType() != TileEvent.PLACEMENT) return;
        Tile tile = ev.getTile();
        Location rose = tile.getWindRose();
        if (rose == null) return;
        if (rose == Location.NWSE) {
            roseRotation = tile.getRotation();
            rosePosition = tile.getPosition();
        } else {
            rose = rose.rotateCW(roseRotation);
            if (isInProperQuadrant(rose, tile.getPosition())) {
                Player p = game.getActivePlayer();
                p.addPoints(WIND_ROSE_POINTS, PointCategory.WIND_ROSE);
                game.post(new ScoreEvent(tile.getPosition(), p, WIND_ROSE_POINTS, PointCategory.WIND_ROSE));
            }
View Full Code Here

    }

    @Override
    public void initTile(Tile tile, Element xml) {
        if (xml.hasAttribute("wind-rose")) {
            Location loc = Location.valueOf(xml.getAttribute("wind-rose"));
            tile.setWindRose(loc);
        }
    }
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.