Package com.jcloisterzone.action

Examples of com.jcloisterzone.action.MeepleAction


    /** convenient method to find follower action in all actions */
    protected List<MeepleAction> findFollowerActions(List<PlayerAction<?>> actions) {
        List<MeepleAction> followerActions = new ArrayList<>();
        for (PlayerAction<?> a : actions) {
            if (a instanceof MeepleAction) {
                MeepleAction ma = (MeepleAction) a;
                if (Follower.class.isAssignableFrom(ma.getMeepleType())) {
                    followerActions.add(ma);
                }
            }
        }
        return followerActions;
View Full Code Here


        if (pointers.isEmpty()) return Collections.emptyList();

        List<PlayerAction<?>> actions = new ArrayList<>();
        //TODO nice to do this in generic way independently on particular followers enumeration
        if (getActivePlayer().hasFollower(SmallFollower.class)) {
            actions.add(new MeepleAction(SmallFollower.class).addAll(pointers));
        }
        if (getActivePlayer().hasFollower(BigFollower.class)) {
            actions.add(new MeepleAction(BigFollower.class).addAll(pointers));
        }
        if (getActivePlayer().hasFollower(Phantom.class)) {
            actions.add(new MeepleAction(Phantom.class).addAll(pointers));
        }
        if (cornType.equals(City.class) && getActivePlayer().hasFollower(Mayor.class)) {
            actions.add(new MeepleAction(Mayor.class).addAll(pointers));
        }
        if (!cornType.equals(Farm.class) && getActivePlayer().hasFollower(Wagon.class)) {
            actions.add(new MeepleAction(Wagon.class).addAll(pointers));
        }
        return actions;
    }
View Full Code Here

            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;
                    }
                }
            }

            if (allowAdd && landingExists) {
                MeepleAction action = new MeepleAction(f.getClass());
                action.add(new FeaturePointer(getTile().getPosition(), Location.FLIER));
                actions.add(action);
            }
        }
    }
View Full Code Here

    @Override
    public void prepareActions(List<PlayerAction<?>> actions, Set<FeaturePointer> followerOptions) {
        if (game.getActivePlayer().hasFollower(Mayor.class) && !followerOptions.isEmpty()) {
            Set<FeaturePointer> mayorLocations = filterMayorLocations(followerOptions);
            if (!mayorLocations.isEmpty()) {
                actions.add(new MeepleAction(Mayor.class).addAll(mayorLocations));
            }
        }
    }
View Full Code Here

        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()));
            }
        }
        if (action.isEmpty()) {
            next();
            return;
        }
        game.post(new SelectActionEvent(getActivePlayer(), action, false));
    }
View Full Code Here

    }

    @Override
    public void prepareActions(List<PlayerAction<?>> actions, Set<FeaturePointer> followerOptions) {
        if (game.getActivePlayer().hasFollower(Phantom.class) && !followerOptions.isEmpty()) {
            actions.add(new MeepleAction(Phantom.class).addAll(followerOptions));
        }
    }
View Full Code Here

        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

        Player wagonPlayer;
        while ((wagonPlayer = wagonCap.getWagonPlayer()) != null) {
            Feature f = rw.get(wagonPlayer);
            List<FeaturePointer> wagonMoves = prepareWagonMoves(f);
            if (!wagonMoves.isEmpty()) {
                game.post(new SelectActionEvent(getActivePlayer(), new MeepleAction(Wagon.class).addAll(wagonMoves), true));
                return true;
            } else {
                rw.remove(wagonPlayer);
            }
        }
View Full Code Here

        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));
        }
        actions.add(builderAction);

    }
View Full Code Here


    @Override
    protected void performAction(final Position pos, Location loc) {
        if (action instanceof MeepleAction) {
            MeepleAction ma = (MeepleAction) action;
            Feature piece = gridPanel.getTile(pos).getFeature(loc);
            if (piece instanceof Farm) {
                if (Follower.class.isAssignableFrom(ma.getMeepleType()) && getClient().getConfig().getConfirm().getFarm_place()) {
                    if (!confirmFarmPlacement()) return;
                }
            } else if (piece instanceof Tower) {
                if (getClient().getConfig().getConfirm().getTower_place()) {
                    if (!confirmTowerPlacement(pos)) return;
                }
            }
            if (loc == Location.FLIER) {
                getClient().getConnection().send(new RollFlierDiceMessage(getGame().getGameId(), ma.getMeepleType()));
                return;
            }
            if (loc == Location.CLOISTER && abbotOption) {
                String options[] = {_("Place as monk"), _("Place as abbot") };
                int result = JOptionPane.showOptionDialog(getClient(),
View Full Code Here

TOP

Related Classes of com.jcloisterzone.action.MeepleAction

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.