Package com.jcloisterzone.board

Examples of com.jcloisterzone.board.Tile


    }

    @Override
    public void enter() {
        int distance = flierCap.getFlierDistance();
        Tile origin = game.getCurrentTile();
        Location direction = origin.getFlier().rotateCW(origin.getRotation());
        Position pos = game.getCurrentTile().getPosition();
        for (int i = 0; i < distance; i++) {
            pos = pos.add(direction);
        }
        Tile target = getBoard().get(pos);

        Class<? extends Meeple> meepleType = flierCap.getMeepleType();
        Follower follower = (Follower) getActivePlayer().getMeepleFromSupply(meepleType);

        if (target == null || !game.isDeployAllowed(target, meepleType)) {
            next();
            return;
        }

        MeepleAction action = new MeepleAction(meepleType);
        for (Feature f : target.getFeatures()) {
            if (!(f instanceof Completable)) continue;
            if (f.walk(new IsCompleted())) continue;
            if (follower.isDeploymentAllowed(f).result) {
                action.add(new FeaturePointer(pos, f.getLocation()));
            }
View Full Code Here


    public void deployMeeple(Position p, Location loc, Class<? extends Meeple> meepleType) {
        if (!meepleType.equals(flierCap.getMeepleType())) {
            throw new IllegalArgumentException("Invalid meeple type.");
        }
        Meeple m = getActivePlayer().getMeepleFromSupply(meepleType);
        Tile tile = getBoard().get(p);
        m.deploy(tile, loc);
        next();
    }
View Full Code Here

    @Override
    public void prepareActions(List<PlayerAction<?>> actions, Set<FeaturePointer> followerOptions) {
        Player player = game.getActivePlayer();
        if (!player.hasSpecialMeeple(Pig.class)) return;

        Tile tile = getTile();
        if (!game.isDeployAllowed(tile, Pig.class)) return;

        Position pos = tile.getPosition();
        MeepleAction pigAction = null;
        for (Location loc : tile.getPlayerFeatures(player, Farm.class)) {
            if (pigAction == null) {
                pigAction = new MeepleAction(Pig.class);
                actions.add(pigAction);
            }
            pigAction.add(new FeaturePointer(pos, loc));
View Full Code Here

        return p == null ? game.getTurnPlayer() : p;
    }

    @Override
    public void enter() {
        Tile tile = getTile();
        Map<Player, Set<Location>> currentTileCastleBases = null;
        for (Feature f : tile.getFeatures()) {
            if (!(f instanceof City)) continue;
            Player owner = f.walk(new FindCastleBaseVisitor());
            if (owner == null || castleCap.getPlayerCastles(owner) == 0) continue;
            if (currentTileCastleBases == null) currentTileCastleBases = new HashMap<>();
            Set<Location> locs = currentTileCastleBases.get(owner);
View Full Code Here

        List<Feature> result = new ArrayList<>();
        Location direction = getTile().getFlier().rotateCW(getTile().getRotation());
        Position pos = getTile().getPosition();
        for (int i = 0; i < 3; i++) {
            pos = pos.add(direction);
            Tile target = getBoard().get(pos);
            if (target != null) {
                for (Feature f : target.getFeatures()) {
                    if (f instanceof Completable) {
                        if (f.walk(new IsCompleted())) continue;
                        result.add(f);
                    }
                }
View Full Code Here

        prepareFlier(actions, true);
    }


    public void prepareFlier(List<PlayerAction<?>> actions, boolean allowAdd) {
        Tile tile = game.getCurrentTile();
        if (flierUsed || tile.getFlier() == null) return;

        List<Feature> reachable = getReachableFeatures();
        if (reachable.isEmpty()) return;

        followerLoop:
        for (Follower f : game.getActivePlayer().getFollowers()) {
            if (!f.isInSupply()) continue;
            boolean landingExists = isLandingExists(f, reachable);

            for (PlayerAction<?> action : actions) {
                if (action instanceof MeepleAction) {
                    MeepleAction ma = (MeepleAction) action;
                    if (ma.getMeepleType().equals(f.getClass())) {
                        if (landingExists) {
                            ma.add(new FeaturePointer(tile.getPosition(), Location.FLIER));
                        }
                        continue followerLoop;
                    }
                }
            }
View Full Code Here

    private List<FeaturePointer> prepareWagonMoves(Feature source) {
        if (source.getTile().isAbbeyTile()) {
            List<FeaturePointer> wagonMoves = new ArrayList<>();
            for (Entry<Location, Tile> entry : getBoard().getAdjacentTilesMap(source.getTile().getPosition()).entrySet()) {
                Tile tile = entry.getValue();
                Feature f = tile.getFeaturePartOf(entry.getKey().rev());
                if (f == null || f.walk(new IsOccupiedOrCompleted())) continue;
                wagonMoves.add(new FeaturePointer(tile.getPosition(), f.getLocation()));
            }
            return wagonMoves;
        } else {
            return source.walk(new FindUnoccupiedNeighbours());
        }
View Full Code Here

    @Override
    public void prepareActions(List<PlayerAction<?>> actions, Set<FeaturePointer> followerOptions) {
        Player player = game.getActivePlayer();
        if (!player.hasSpecialMeeple(Builder.class)) return;

        Tile tile = getTile();
        if (!game.isDeployAllowed(tile, Builder.class)) return;

        Set<Location> roads = tile.getPlayerUncompletedFeatures(player, Road.class);
        Set<Location> cities = tile.getPlayerUncompletedFeatures(player, City.class);
        if (roads.isEmpty() && cities.isEmpty()) return;

        Position pos = tile.getPosition();
        MeepleAction builderAction = new MeepleAction(Builder.class);

        for (Location loc : Iterables.concat(roads, cities)) {
            builderAction.add(new FeaturePointer(pos, loc));
        }
View Full Code Here

                        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));
                                    }
                                }
                                j++;
                            }
View Full Code Here

    @Override
    protected void preplaceTiles() {
        //super.preplaceTiles();
        for (Iterator<Tile> iter = ((DefaultTilePack)getTilePack()).drawPrePlacedActiveTiles().iterator(); iter.hasNext();) {
            Tile preplaced = iter.next();
            game.getBoard().add(preplaced, preplaced.getPosition(), true);
            game.getBoard().mergeFeatures(preplaced);
            game.post(new TileEvent(TileEvent.PLACEMENT, null, preplaced, preplaced.getPosition()));
            if (preplaced.getBridge() != null) {
                game.post(new BridgeDeployedEvent(null, preplaced.getPosition(), preplaced.getBridge().getLocation()));
            }
        }
        snapshot.loadCapabilities(game);
        //meeples must be places after capabilites are loaded - when cities replaces castles
        for (Meeple m : tilePackFactory.getPreplacedMeeples()) {
            Tile tile = game.getBoard().get(m.getPosition());
            Feature f;
            if (m instanceof Barn) {
                //special case, barn holds 'corner' location
                f = tile.getFeaturePartOf(m.getLocation());
            } else {
                f = tile.getFeature(m.getLocation());
            }
            m.setFeature(f);
            f.addMeeple(m);
            game.post(new MeepleEvent(null, m, null, new FeaturePointer(m.getPosition(), m.getLocation())));
        }
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.