Package com.jcloisterzone.feature

Examples of com.jcloisterzone.feature.City


    static class PennatsCountingVisitor implements FeatureVisitor<Integer> {
        int pennats = 0;

        @Override
        public boolean visit(Feature feature) {
            City c = (City) feature;
            pennats += c.getPennants();
            return true;
        }
View Full Code Here


        Set<FeaturePointer> pointers = new HashSet<>();
        for (Location loc: tile.getUnoccupiedScoreables(excludeFinished)) {
            //exclude finished == false -> just placed tile - it means do not check princess for magic portal
            //TODO very cryptic, refactor
            if (!excludeFinished && hasCapability(PrincessCapability.class) && hasRule(CustomRule.PRINCESS_MUST_REMOVE_KNIGHT)) {
                City princessCity = tile.getCityWithPrincess();
                if (princessCity != null) {
                    continue;
                }
            }
            pointers.add(new FeaturePointer(tile.getPosition(), loc));
View Full Code Here

    }

    private void addAdjoiningCompletedCities(Feature[] adjoiningCities) {
        for (Feature feature : adjoiningCities) {
            if (feature instanceof City) {
                City c = (City) feature;
                CityScoreContext ctx = cityCache.get(c);
                if (ctx == null) {
                    ctx = c.getScoreContext();
                    ctx.setCityCache(cityCache);
                    c.walk(ctx);
                }
                if (ctx.isCompleted()) {
                    adjoiningCompletedCities.put((City) ctx.getMasterFeature(), ctx);
                }
            } else if (feature instanceof Castle) {
View Full Code Here

    this.cityCache = cityCache;
  }

  @Override
  public boolean visit(Feature feature) {
    City city = (City) feature;
    pennants += city.getPennants();
    cathedral = cathedral || city.isCathedral();
    besieged = besieged || city.isBesieged();
    TradeResource tr = city.getTradeResource();
    if (tr != null) {
      if (cityTradeResources == null) {
        cityTradeResources = new int[TradeResource.values().length];
      }
      cityTradeResources[tr.ordinal()]++;
View Full Code Here

    }

    @Override
    public void initFeature(Tile tile, Feature feature, Element xml) {
        if (feature instanceof City && xml.hasAttribute("resource")) {
            City city = (City) feature;
            String val = xml.getAttribute("resource");
            city.setTradeResource(TradeResource.valueOf(val.toUpperCase()));
        }
    }
View Full Code Here

        List<Follower> followers = new ArrayList<>();
        //Player owner;

        @Override
        public boolean visit(Feature feature) {
            City c = (City) feature;
            if (!c.isCastleBase()) {
                castleBase = false;
                return false;
            }
            for (Meeple m : c.getMeeples()) {
                if (m instanceof Follower) {
                    followers.add((Follower) m);
                }
            }
            size++;
View Full Code Here

    private boolean isPrincessUndeploy(Meeple m) {
        boolean tileHasPrincess = false;
        for (Feature f : getTile().getFeatures()) {
            if (f instanceof City) {
                City c = (City) f;
                if (c.isPricenss()) {
                    tileHasPrincess = true;
                    break;
                }
            }
        }
View Full Code Here

        }
    }

    private Castle replaceCityWithCastle(Tile tile, Location loc) {
        ListIterator<Feature> iter = tile.getFeatures().listIterator();
        City city = null;
        while (iter.hasNext()) {
            Feature feature =  iter.next();
            if (feature.getLocation() == loc) {
                city = (City) feature;
                break;
            }
        }
        List<Meeple> meeples = new ArrayList<>(city.getMeeples()); //collection copy required!!! undeploy modify it
        for (Meeple m : meeples) {
            m.undeploy();
        }
        Castle castle = new Castle();
        castle.setTile(tile);
View Full Code Here

            return result;
        }

        @Override
        public boolean visit(Feature feature) {
            City city = (City) feature;
            if (city.isBesieged()) { //cloister must border Cathar tile
                Position p = city.getTile().getPosition();
                for (Tile tile : getBoard().getAdjacentAndDiagonalTiles(p)) {
                    if (tile.hasCloister()) {
                        result = true;
                        return false; //do not continue, besieged cloister exists
                    }
View Full Code Here

            return isBesieged && cloisterExists;
        }

        @Override
        public boolean visit(Feature feature) {
            City city = (City) feature;
            if (city.isBesieged()) {
                isBesieged = true;
            }

            Position p = city.getTile().getPosition();
            for (Tile tile : getBoard().getAdjacentAndDiagonalTiles(p)) {
                if (tile.hasCloister()) {
                    cloisterExists = true;
                    break;
                }
View Full Code Here

TOP

Related Classes of com.jcloisterzone.feature.City

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.