Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Tile


    }

    // 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;
            if (p.x == right) ++right;
            if (p.y == top) --top;
            if (p.y == bottom) ++bottom;

            tileLayer.tilePlaced(tile);

            boolean initialPlacement = ev.getTriggeringPlayer() == null;//if triggering player is null we are placing initial tiles
            if ((!initialPlacement && !ev.getTriggeringPlayer().isLocalHuman()) ||
                (initialPlacement && tile.equals(client.getGame().getCurrentTile()))) {
                getAnimationService().registerAnimation(new RecentPlacement(tile.getPosition()));
            }
        } else if (ev.getType() == TileEvent.REMOVE) {
            tileLayer.tileRemoved(tile);
        }
        repaint();
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);
        }
View Full Code Here

    }

    public void activateNonRiverTiles() {
        getTilePack().setGroupState("default", TileGroupState.ACTIVE);
        getTilePack().setGroupState("river", TileGroupState.RETIRED);
        Tile lake = getTilePack().drawTile(TilePack.INACTIVE_GROUP, getLakeId());
        getBoard().refreshAvailablePlacements(lake);
        Entry<Position, Set<Rotation>> entry = getBoard().getAvailablePlacements().entrySet().iterator().next();
        lake.setRotation(entry.getValue().iterator().next());
        getBoard().add(lake, entry.getKey());
        getBoard().mergeFeatures(lake);
        game.post(new TileEvent(TileEvent.PLACEMENT, null, lake, lake.getPosition()));
    }
View Full Code Here

        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);
                if (getBoard().get(pCheck) != null) return false;
                //also forbid fork "parallel river"
                Tile next = getBoard().get(p.add(continueSide.rotateCW(Rotation.R90)));
                if (next != null && next.getRiver().rotateCW(next.getRotation()).intersect(continueSide) == continueSide) return false;
                next = getBoard().get(p.add(continueSide.rotateCCW(Rotation.R90)));
                if (next != null && next.getRiver().rotateCW(next.getRotation()).intersect(continueSide) == continueSide) return false;
            }
        }
        return true;
    }
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

TOP

Related Classes of com.jcloisterzone.board.Tile

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.