Package com.jcloisterzone.feature

Examples of com.jcloisterzone.feature.Castle


    private void undeployed(MeepleEvent ev) {
        if (ev.getFrom() == null) return;
        Feature f = getBoard().get(ev.getFrom());
        if (f instanceof Castle) {
            Castle castle = (Castle) f.getMaster();
            scoreableCastleVicinity.remove(castle);
            emptyCastles.add(castle);
        }
    }
View Full Code Here


        for (Position p : triggerPositions) {
            for (Entry<Castle, Position[]> entry : scoreableCastleVicinity.entrySet()) {
                Position[] vicinity = entry.getValue();
                for (int i = 0; i < vicinity.length; i++) {
                    if (vicinity[i].equals(p)) {
                        Castle master = entry.getKey();
                        Integer currentCastleScore = castleScore.get(master);
                        if (currentCastleScore == null || currentCastleScore < score) {
                            castleScore.put(master, score);
                            //chain reaction, one completed castle triggers another
                            checkCastleVicinity(Arrays.asList(master.getCastleBase()), score);
                        }
                        break;
                    }
                }
            }
View Full Code Here

        }
        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);
        castle.setId(game.idSequnceNextVal());
        castle.setLocation(loc.rotateCCW(tile.getRotation()));
        iter.set(castle);

        for (Feature f : tile.getFeatures()) { //replace also city references
            if (f instanceof Farm) {
                Farm farm = (Farm) f;
View Full Code Here

    public Castle convertCityToCastle(Position pos, Location loc) {
        return convertCityToCastle(pos, loc, false);
    }

    private Castle convertCityToCastle(Position pos, Location loc, boolean loadFromSnaphot) {
        Castle castle1 = replaceCityWithCastle(getBoard().get(pos), loc);
        Castle castle2 = replaceCityWithCastle(getBoard().get(pos.add(loc)), loc.rev());
        castle1.getEdges()[0] = castle2;
        castle2.getEdges()[0] = castle1;
        if (!loadFromSnaphot) {
            newCastles.add(castle1.getMaster());
        }
        game.post(new CastleDeployedEvent(game.getActivePlayer(), castle1, castle2));
        return castle1.getMaster();
View Full Code Here

        nl = node.getElementsByTagName("castle");
        for (int i = 0; i < nl.getLength(); i++) {
            Element castleEl = (Element) nl.item(i);
            Position pos = XmlUtils.extractPosition(castleEl);
            Location loc = Location.valueOf(castleEl.getAttribute("location"));
            Castle castle = convertCityToCastle(pos, loc, true);
            boolean isNew = XmlUtils.attributeBoolValue(castleEl, "new");
            boolean isCompleted = XmlUtils.attributeBoolValue(castleEl, "completed");
            if (isNew) {
                newCastles.add(castle);
            } else if (isCompleted) {
                emptyCastles.add(castle);
            } else {
                scoreableCastleVicinity.put(castle, castle.getVicinity());
            }
        }
    }
View Full Code Here

TOP

Related Classes of com.jcloisterzone.feature.Castle

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.