Package com.jcloisterzone

Examples of com.jcloisterzone.Player


    private ReceivedChatMessage createReceivedMessage(ChatEvent ev) {
        String nick = ev.getRemoteClient().getName();
        Color color = Color.DARK_GRAY;

        if (game.isStarted()) {
            Player selected = null, active = game.getActivePlayer();
            for (Player player : game.getAllPlayers()) {
                if (player.getSlot().getClientId().equals(ev.getRemoteClient().getClientId())) {
                    if (selected == null) {
                        selected = player;
                    } else {
                        if (selected.getSlot().getAiClassName() != null
                                && player.getSlot().getAiClassName() == null) {
                            // prefer real user for remote inactive client with
                            // more players
                            selected = player;
                        }
                    }
                    if (player.equals(active)) {
                        selected = player;
                        break;
                    }
                }
            }
            if (selected != null) {
                nick = selected.getNick();
                color = selected.getColors().getFontColor();
            }
        } else {
             PlayerSlot[] slots = ((CreateGamePhase) game.getPhase()).getPlayerSlots();
             for (PlayerSlot slot: slots) {
                 if (ev.getRemoteClient().getClientId().equals(slot.getClientId()) && !slot.getNickname().equals("")) {
View Full Code Here


    private void paintBackgroundShadow(Graphics2D g2) {
        GridPanel gp = client.getGridPanel();
        int h = gp.getHeight();

        Player player = game.getTurnPlayer();
        if (player == null) {
            g2.setColor(PANEL_BG_COLOR);
            g2.fillRect(-LEFT_PADDING , 0, LEFT_PADDING, h);
            g2.setColor(PANEL_BG_COLOR_SHADOW);
            g2.fillRect(-LEFT_PADDING-3, 0, 3, h);
        } else {
            int y = playerPanels[player.getIndex()].getCenterY();

            g2.setColor(PANEL_BG_COLOR);
            g2.fillRect(-LEFT_PADDING , 0, LEFT_PADDING, y-ACTIVE_MARKER_SIZE);
            g2.fillRect(-LEFT_PADDING , y+ACTIVE_MARKER_SIZE, LEFT_PADDING, h-y-ACTIVE_MARKER_SIZE);
            g2.fillPolygon(
                new int[] { -LEFT_PADDING, 0, 0, -ACTIVE_MARKER_PADDING },
                new int[] { y-ACTIVE_MARKER_SIZE, y-ACTIVE_MARKER_SIZE, y, y}, 4
            );
            g2.fillPolygon(
                new int[] { -LEFT_PADDING, 0, 0, -ACTIVE_MARKER_PADDING },
                new int[] { y+ACTIVE_MARKER_SIZE, y+ACTIVE_MARKER_SIZE, y, y}, 4
            );
            g2.setColor(PANEL_BG_COLOR_SHADOW);
            //g2.setColor(Color.RED);
            g2.fillRect(-LEFT_PADDING-PANEL_SHADOW_WIDTH, 0, PANEL_SHADOW_WIDTH, y-ACTIVE_MARKER_SIZE);
            g2.fillRect(-LEFT_PADDING-PANEL_SHADOW_WIDTH, y+ACTIVE_MARKER_SIZE, PANEL_SHADOW_WIDTH, h-y+ACTIVE_MARKER_SIZE);
            g2.fillPolygon(
                new int[] { -LEFT_PADDING-PANEL_SHADOW_WIDTH, -LEFT_PADDING, -ACTIVE_MARKER_PADDING, -PANEL_SHADOW_WIDTH-ACTIVE_MARKER_PADDING},
                new int[] { y-ACTIVE_MARKER_SIZE, y-ACTIVE_MARKER_SIZE, y, y}, 4
            );
            g2.fillPolygon(
                new int[] { -LEFT_PADDING-PANEL_SHADOW_WIDTH, -LEFT_PADDING, -ACTIVE_MARKER_PADDING, -PANEL_SHADOW_WIDTH-ACTIVE_MARKER_PADDING },
                new int[] { y+ACTIVE_MARKER_SIZE, y+ACTIVE_MARKER_SIZE, y, y}, 4
            );
        }

        player = game.getActivePlayer();
        if (player != null) {
            g2.setColor(Color.BLACK);
            int y = playerPanels[player.getIndex()].getCenterY();
//            g2.fillPolygon(
//                new int[] { -LEFT_PADDING-PANEL_SHADOW_WIDTH, -PANEL_SHADOW_WIDTH-ACTIVE_MARKER_PADDING, -LEFT_PADDING-PANEL_SHADOW_WIDTH},
//                new int[] { y-ACTIVE_MARKER_SIZE, y, y+ACTIVE_MARKER_SIZE,}, 3
//            );
            g2.fillPolygon(
View Full Code Here

        int availableWidth = ControlPanel.PANEL_WIDTH - LEFT_MARGIN - (actions.length-1)*PADDING;
        double units = actions.length + (ACTIVE_SIZE_RATIO-1.0);
        int baseSize = Math.min(maxIconSize, (int) Math.floor(availableWidth / units));
        int activeSize = (int) (baseSize * ACTIVE_SIZE_RATIO);

        Player activePlayer = client.getGame().getActivePlayer();
        for (int i = 0; i < actions.length; i++) {
            selected[i] = new ImageIcon(
                actions[i].getImage(activePlayer, true).getScaledInstance(activeSize, activeSize, Image.SCALE_SMOOTH)
            ).getImage();
            deselected[i] = new ImageIcon(
View Full Code Here

    private void dbgPringHeader() {
        StringBuilder sb = new StringBuilder("*** ranking start * ");
        sb.append(game.getPhase().getClass().getSimpleName());
        sb.append(" * ");
        Player p = game.getActivePlayer();
        sb.append(p.getNick());
        sb.append(" ***");
        System.out.println(sb);
    }
View Full Code Here

    @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) {
View Full Code Here

    public void loadFromSnapshot(Document doc, Element node) {
        bridgeUsed = Boolean.parseBoolean(node.getAttribute("bridgeUsed"));
        NodeList nl = node.getElementsByTagName("player");
        for (int i = 0; i < nl.getLength(); i++) {
            Element playerEl = (Element) nl.item(i);
            Player player = game.getPlayer(Integer.parseInt(playerEl.getAttribute("index")));
            bridges.put(player, Integer.parseInt(playerEl.getAttribute("bridges")));
        }
    }
View Full Code Here

        return game.hasCapability(CornCircleCapability.class);
    }

    @Override
    public Player getActivePlayer() {
        Player player = cornCircleCap.getCornCirclePlayer();
        if (player == null) return super.getActivePlayer();
        return player;
    }
View Full Code Here

        }
        game.post(new CornCircleSelectOptionEvent(getActivePlayer(), getTile().getPosition()));
    }

    private void nextCornPlayer() {
        Player active = getActivePlayer();
        if (active == game.getTurnPlayer()) {
            cornCircleCap.setCornCirclePlayer(null);
            cornCircleCap.setCornCircleOption(null);
            next();
        } else {
            Player cornPlayer = game.getNextPlayer(active);
            cornCircleCap.setCornCirclePlayer(cornPlayer);
            prepareCornAction();
        }
    }
View Full Code Here

        if (remove) {
            cornCircleCap.setCornCircleOption(CornCicleOption.REMOVAL);
        } else {
            cornCircleCap.setCornCircleOption(CornCicleOption.DEPLOYMENT);
        }
        Player cornPlayer = game.getNextPlayer(getActivePlayer());
        cornCircleCap.setCornCirclePlayer(cornPlayer);
        prepareCornAction();
    }
View Full Code Here

    private void completed(FeatureCompletedEvent ev) {
        if (ev.getFeature() instanceof City) {
            int cityTradeResources[] = ((CityScoreContext)ev.getScoreContent()).getCityTradeResources();
            if (cityTradeResources != null) {
                Player player = game.getActivePlayer();
                int playersTradeResources[] = tradeResources.get(player);
                for (int i = 0; i < cityTradeResources.length; i++) {
                    playersTradeResources[i] += cityTradeResources[i];
                    game.post(new TradeResourceEvent(player, TradeResource.values()[i], cityTradeResources[i]));
                }
View Full Code Here

TOP

Related Classes of com.jcloisterzone.Player

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.