Package com.jcloisterzone.figure

Examples of com.jcloisterzone.figure.Follower


    //scoring helpers

    public void scoreFeature(int points, ScoreContext ctx, Player p) {
        PointCategory pointCategory = ctx.getMasterFeature().getPointCategory();
        p.addPoints(points, pointCategory);
        Follower follower = ctx.getSampleFollower(p);
        boolean isFinalScoring = getPhase() instanceof GameOverPhase;
        ScoreEvent scoreEvent;
        if (fairyCapability != null && follower.at(fairyCapability.getFairyPosition())) {
            p.addPoints(FairyCapability.FAIRY_POINTS_FINISHED_OBJECT, PointCategory.FAIRY);
            scoreEvent = new ScoreEvent(follower.getFeature(), points+FairyCapability.FAIRY_POINTS_FINISHED_OBJECT, pointCategory, follower);
            scoreEvent.setLabel(points+" + "+FairyCapability.FAIRY_POINTS_FINISHED_OBJECT);
        } else {
            scoreEvent = new ScoreEvent(follower.getFeature(), points, pointCategory, follower);
        }
        scoreEvent.setFinal(isFinalScoring);
        post(scoreEvent);
    }
View Full Code Here


    public Map<Player, Integer> getPowers() {
        Collection<Follower> followers = getFollowers();
        int size = followers.size();
        if (size == 0) return Collections.emptyMap();
        if (size == 1) {
            Follower follower = followers.iterator().next();
            return Collections.singletonMap(follower.getPlayer(), follower.getPower());
        }
        //rare cases
        Map<Player, Integer> result = new HashMap<Player, Integer>();
        for (Follower follower : followers) {
            Integer val = result.get(follower.getPlayer());
            result.put(follower.getPlayer(), val == null ? follower.getPower() : val + follower.getPower());
        }
        return result;

    }
View Full Code Here

    @Override
    public boolean visit(Feature feature) {
        for (Meeple meeple : feature.getMeeples()) {
            if (meeple instanceof Follower) {
                Follower follower = (Follower) meeple;
                Integer prev = power.get(follower.getPlayer());
                int followerPower = follower.getPower();
                int curr = prev == null ? followerPower : prev + followerPower;
                power.put(follower.getPlayer(), curr);
                if (curr > bestPower) bestPower = curr;
                if (sample.containsKey(follower.getPlayer())) {
                    if (follower.at(preferedPos)) {
                        sample.put(follower.getPlayer(), follower);
                    }
                } else {
                    sample.put(follower.getPlayer(), follower);
                }
            }
            if (meeple instanceof Follower) {
                followers.add((Follower) meeple);
            } else if (meeple instanceof Special) {
View Full Code Here

        return captureAction;
    }

    @Override
    public void takePrisoner(Position p, Location loc, Class<? extends Meeple> meepleType, Integer meepleOwner) {
        Follower m = (Follower) game.getMeeple(p, loc, meepleType, game.getPlayer(meepleOwner));
        m.undeploy();
        //undeploy returns figure to owner -> we must handle capture / prisoner exchange
        Player me = getActivePlayer();
        if (m.getPlayer() != me) {
            TowerCapability towerCap = game.getCapability(TowerCapability.class);
            List<Follower> prisoners = towerCap.getPrisoners().get(m.getPlayer());
            List<Follower> myCapturedFollowers = new ArrayList<>();
            for (Follower f : prisoners) {
                if (f.getPlayer() == me) {
                    myCapturedFollowers.add(f);
                }
            }

            if (myCapturedFollowers.isEmpty()) {
                towerCap.inprison(m, me);
            } else {
                //opponent has my prisoner - figure exchange
                Follower exchanged = myCapturedFollowers.get(0); //TODO same type?
                boolean removeOk = prisoners.remove(exchanged);
                assert removeOk;
                exchanged.clearDeployment();
                game.post(new MeeplePrisonEvent(exchanged, m.getPlayer(), null));
            }
        }
        next();
    }
View Full Code Here

            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()));
            }
        }
        if (action.isEmpty()) {
            next();
View Full Code Here

        }
        Player opponent = game.getAllPlayers()[playerIndexToPay];

        Iterator<Follower> i = prisoners.get(opponent).iterator();
        while (i.hasNext()) {
            Follower meeple = i.next();
            if (meepleType.isInstance(meeple)) {
                i.remove();
                meeple.clearDeployment();
                opponent.addPoints(RANSOM_POINTS, PointCategory.TOWER_RANSOM);
                ransomPaidThisTurn = true;
                game.getActivePlayer().addPoints(-RANSOM_POINTS, PointCategory.TOWER_RANSOM);
                game.post(new MeeplePrisonEvent(meeple, opponent, null));
                game.getPhase().notifyRansomPaid();
View Full Code Here

TOP

Related Classes of com.jcloisterzone.figure.Follower

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.