Examples of FarmScoreContext


Examples of com.jcloisterzone.feature.visitor.score.FarmScoreContext

        if (!(feature instanceof Farm)) {
            return new DeploymentCheckResult("The barn must be placed only on a farm.");
        }
        Farm farm = (Farm) feature;

        FarmScoreContext ctx = farm.getScoreContext();
        ctx.setCityCache(new HashMap<City, CityScoreContext>());
        farm.walk(ctx);

        if (!farm.getTile().getGame().hasRule(CustomRule.MULTI_BARN_ALLOWED)) {
            for (Special m : ctx.getSpecialMeeples()) {
                if (m instanceof Barn) {
                    return new DeploymentCheckResult("Another barn is already placed on the farm.");
                }
            }
        }

        //all ok - score non barn meeples
        for (Player owner : ctx.getMajorOwners()) {
            int points = ctx.getPoints(owner);
            game.scoreFeature(points, ctx, owner);
        }
        for (Meeple m : ctx.getMeeples()) {
            m.undeploy(false);
        }

        return super.isDeploymentAllowed(feature);
    }
View Full Code Here

Examples of com.jcloisterzone.feature.visitor.score.FarmScoreContext

        return PointCategory.FARM;
    }

    @Override
    public FarmScoreContext getScoreContext() {
        return new FarmScoreContext(getGame());
    }
View Full Code Here

Examples of com.jcloisterzone.feature.visitor.score.FarmScoreContext

        alreadyRated.addAll(ctx.getFollowers());
        callback.scoreCompletableFeature(ctx);
    }

    private void scoreFarm(Farm farm, ScoreAllCallback callback) {
        FarmScoreContext ctx = callback.getFarmScoreContext(farm);
        ctx.setCityCache(cityCache);
        farm.walk(ctx);
        alreadyRated.addAll(ctx.getFollowers());
        alreadyRated.addAll(ctx.getSpecialMeeples()); //farm can contains Barn!

        for (Special sp : ctx.getSpecialMeeples()) {
            if (sp instanceof Barn) {
                callback.scoreBarn(ctx, (Barn) sp);
            }
        }
        for (Player p : ctx.getMajorOwners()) {
            callback.scoreFarm(ctx, p);
        }
    }
View Full Code Here

Examples of com.jcloisterzone.feature.visitor.score.FarmScoreContext

            }
        }
    }

    private void scoreFollowersOnBarnFarm(Farm farm, Map<City, CityScoreContext> cityCache) {
        FarmScoreContext ctx = farm.getScoreContext();
        ctx.setCityCache(cityCache);
        farm.walk(ctx);

        boolean hasBarn = false;
        for (Meeple m : ctx.getSpecialMeeples()) {
            if (m instanceof Barn) {
                hasBarn = true;
                break;
            }
        }
        if (hasBarn) {
            for (Player p : ctx.getMajorOwners()) {
                int points = ctx.getPointsWhenBarnIsConnected(p);
                game.scoreFeature(points, ctx, p);
            }
            for (Meeple m : ctx.getMeeples()) {
                if (!(m instanceof Barn)) {
                    undeloyMeeple(m);
                }
            }
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.