Package com.jcloisterzone.game

Examples of com.jcloisterzone.game.Game


     */
    @Override
    public void paintComponent(Graphics2D parentGraphics) {
        super.paintComponent(parentGraphics);

        Game game = client.getGame();

        //TODO better display
//        if (player.getSlot().getState() == SlotState.CLOSED) {
//            this.color = Color.GRAY;
//        }

//    GridPanel gp = client.getGridPanel();

//        boolean isActive = game.getActivePlayer() == player;
//        boolean playerTurn = game.getTurnPlayer() == player;

//    gp.profile(" > get flags");

        BufferedImage bimg = UiUtils.newTransparentImage(PANEL_WIDTH, 200);
        g2 = bimg.createGraphics();
        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);

//    gp.profile(" > create buffer");

        drawDelimiter(DELIMITER_Y);

        g2.setFont(FONT_POINTS);
        drawTextShadow(""+player.getPoints(), PADDING_L, 27);

        g2.setFont(FONT_NICKNAME);
        drawTextShadow(player.getNick(), 78, 27);

//    gp.profile(" > nick & score");

        g2.setFont(FONT_MEEPLE);
        bx = PADDING_L;
        by = 43;

        int small = 0;
        String smallImgKey = SmallFollower.class.getSimpleName();
        for (Follower f : Iterables.filter(player.getFollowers(), MeeplePredicates.inSupply())) {
            //instanceof cannot be used because of Phantom
            if (f.getClass().equals(SmallFollower.class)) {
                small++;
            } else { //all small followers are at beginning of collection
                drawMeepleBox(player, smallImgKey, small, true);
                small = 0;
                drawMeepleBox(player, f.getClass().getSimpleName(), 1, false);
            }
        }
        drawMeepleBox(player, smallImgKey, small, true); //case when only small followers are in collection (not drawn yet)

//    gp.profile(" > followers");

        for (Special meeple : Iterables.filter(player.getSpecialMeeples(), MeeplePredicates.inSupply())) {
            drawMeepleBox(player, meeple.getClass().getSimpleName(), 1, false);
        }

//    gp.profile(" > special");

        AbbeyCapability abbeyCap = game.getCapability(AbbeyCapability.class);
        TowerCapability towerCap = game.getCapability(TowerCapability.class);
        BridgeCapability bridgeCap = game.getCapability(BridgeCapability.class);
        CastleCapability castleCap = game.getCapability(CastleCapability.class);
        KingAndRobberBaronCapability kingRobberCap = game.getCapability(KingAndRobberBaronCapability.class);
        ClothWineGrainCapability cwgCap = game.getCapability(ClothWineGrainCapability.class);
        LittleBuildingsCapability lbCap = game.getCapability(LittleBuildingsCapability.class);

        if (abbeyCap != null) {
            drawMeepleBox(null, "abbey", abbeyCap.hasUnusedAbbey(player) ? 1 : 0, false);
        }

        if (towerCap != null) {
            drawMeepleBox(null, "towerpiece", towerCap.getTowerPieces(player), true);
            getMouseRegions().clear();
        }

        if (bridgeCap != null) {
            drawMeepleBox(null, "bridge", bridgeCap.getPlayerBridges(player), true);
        }
        if (castleCap != null) {
            drawMeepleBox(null, "castle", castleCap.getPlayerCastles(player), true);
        }
        if (lbCap != null) {
            drawMeepleBox(null, "lb-tower", lbCap.getBuildingsCount(player, LittleBuilding.TOWER), true);
            drawMeepleBox(null, "lb-house", lbCap.getBuildingsCount(player, LittleBuilding.HOUSE), true);
            drawMeepleBox(null, "lb-shed", lbCap.getBuildingsCount(player, LittleBuilding.SHED), true);
        }

        if (kingRobberCap != null) {
            if (kingRobberCap.getKing() == player) {
                Rectangle r = drawMeepleBox(null, "king", 1, false, "king");
                if ("king".equals(mouseOverKey)) {
                    g2.setFont(FONT_KING_ROBBER_OVERLAY);
                    g2.setColor(KING_ROBBER_OVERLAY);
                    g2.fillRect(r.x, r.y, r.width, r.height);
                    g2.setColor(Color.WHITE);
                    int size = kingRobberCap.getBiggestCitySize();
                    g2.drawString((size < 10 ? " " : "") + size, r.x+2, r.y+20);
                    g2.setFont(FONT_MEEPLE);
                }
            }
            if (kingRobberCap.getRobberBaron() == player) {
                Rectangle r = drawMeepleBox(null, "robber", 1, false, "robber");
                if ("robber".equals(mouseOverKey)) {
                    g2.setFont(FONT_KING_ROBBER_OVERLAY);
                    g2.setColor(KING_ROBBER_OVERLAY);
                    g2.fillRect(r.x, r.y, r.width, r.height);
                    g2.setColor(Color.WHITE);
                    int size = kingRobberCap.getLongestRoadLength();
                    g2.drawString((size < 10 ? " " : "") + size, r.x+2, r.y+20);
                    g2.setFont(FONT_MEEPLE);
                }
            }
        }
        if (cwgCap != null) {
            drawMeepleBox(null, "cloth", cwgCap.getTradeResources(player, TradeResource.CLOTH), true);
            drawMeepleBox(null, "grain", cwgCap.getTradeResources(player, TradeResource.GRAIN), true);
            drawMeepleBox(null, "wine", cwgCap.getTradeResources(player, TradeResource.WINE), true);
        }
        if (towerCap != null) {
            List<Follower> capturedFigures = towerCap.getPrisoners().get(player);
            Map<Class<? extends Follower>, Integer> groupedByType;
            if (!capturedFigures.isEmpty()) {
                groupedByType = new HashMap<>();
                for (Player opponent : game.getAllPlayers()) {
                    if (opponent == player) continue;
                    boolean isOpponentActive = opponent.equals(game.getActivePlayer()) && opponent.isLocalHuman();
                    boolean clickable = isOpponentActive && !towerCap.isRansomPaidThisTurn();
                    for (Follower f : capturedFigures) {
                        if (f.getPlayer() == opponent) {
                            Integer prevVal = groupedByType.get(f.getClass());
                            groupedByType.put(f.getClass(), prevVal == null ? 1 : prevVal+1);
View Full Code Here


    }

    //TODO is there faster game copying without snapshot? or without re-creating board and tile instances
    protected Game copyGame(Object gameListener) {
        Snapshot snapshot = new Snapshot(game);
        Game copy = snapshot.asGame(game.getGameId());
        copy.setConfig(game.getConfig());
        copy.getEventBus().register(gameListener);
        LoadGamePhase phase = new LoadGamePhase(copy, snapshot, getConnection());
        phase.setSlots(new PlayerSlot[0]);
        copy.getPhases().put(phase.getClass(), phase);
        copy.setPhase(phase);
        phase.startGame();
        return copy;
    }
View Full Code Here

                return;
            }
        }

        if (snapshot == null) {
            game = new Game(msg.getGameId());
            phase = new CreateGamePhase(game, conn);
        } else {
            game = snapshot.asGame(msg.getGameId());
            phase = new LoadGamePhase(game, snapshot, conn);
        }
View Full Code Here

TOP

Related Classes of com.jcloisterzone.game.Game

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.