Package megamek.common

Examples of megamek.common.Player


        final boolean useBv = chkBV.getState();
        final boolean useCost = chkCost.getState();

        lisBVs.removeAll();
        for (Enumeration<Player> i = client.getPlayers(); i.hasMoreElements();) {
            final Player player = i.nextElement();
            if (player == null) {
                continue;
            }
            float playerValue = 0;
            for (Enumeration<Entity> j = client.getEntities(); j
                    .hasMoreElements();) {
                Entity entity = j.nextElement();
                if (entity.getOwner().equals(player)) {
                    if (useBv) {
                        playerValue += entity.calculateBattleValue();
                    } else if (useCost) {
                        playerValue += entity.getCost();
                    } else {
                        playerValue += entity.getWeight();
                    }
                }
            }
            if (client.game.getOptions().booleanOption("real_blind_drop")
                    && (player.getId() != client.getLocalPlayer().getId())) {
                playerValue = playerValue > 0 ? 9999 : 0;
            }
            if (useBv) {
                lisBVs
                        .add(player.getName()
                                + Messages.getString("ChatLounge.BV") + (int) playerValue + " (FM:" + (int) (playerValue * player.getForceSizeBVMod()) + ")"); //$NON-NLS-1$
            } else if (useCost) {
                lisBVs.add(player.getName()
                        + Messages.getString("ChatLounge.Cost")
                        + (int) playerValue);
            } else {
                lisBVs.add(player.getName()
                        + Messages.getString("ChatLounge.Tons") + playerValue); //$NON-NLS-1$
            }
        }
    }
View Full Code Here


     * Refreshes the starting positions
     */
    private void refreshStarts() {
        lisStarts.removeAll();
        for (Enumeration<Player> i = client.getPlayers(); i.hasMoreElements();) {
            Player player = i.nextElement();
            if (player != null) {
                StringBuffer ssb = new StringBuffer();
                ssb.append(player.getName()).append(" : "); //$NON-NLS-1$
                ssb.append(IStartingPositions.START_LOCATION_NAMES[player
                        .getStartingPos()]);
                lisStarts.add(ssb.toString());
            }
        }
    }
View Full Code Here

                                    "In Double Blind play, you cannot choose 'Any' as starting position.");
                    return;
                }
                for (Enumeration<Player> e = client.game.getPlayers(); e
                        .hasMoreElements();) {
                    Player player = e.nextElement();
                    if (player.getStartingPos() == 0) {
                        continue;
                    }
                    // CTR and EDG don't overlap
                    if (((player.getStartingPos() == 9) && (i == 10))
                        || ((player.getStartingPos() == 10) && (i == 9))) {
                        continue;
                    }
                    // check for overlapping starting directions
                    if (((player.getStartingPos() == i)
                            || (player.getStartingPos() + 1 == i) || (player
                            .getStartingPos() - 1 == i))
                            && (player.getId() != client.getLocalPlayer()
                                    .getId())) {
                        clientgui
                                .doAlertDialog(
                                        "Must choose exclusive deployment zone",
                                        "When using double blind, each player needs to have an exclusive deployment zone.");
View Full Code Here

     * Refreshes the minefield
     */
    private void refreshMinefield() {
        ((DefaultListModel) lisMinefield.getModel()).removeAllElements();
        for (Enumeration<Player> i = client.getPlayers(); i.hasMoreElements();) {
            final Player player = i.nextElement();
            if (player != null) {
                StringBuffer pi = new StringBuffer();
                pi.append(player.getName()).append(" : "); //$NON-NLS-1$
                pi.append(player.getNbrMFConventional()).append("/"); //$NON-NLS-1$
                pi.append(player.getNbrMFCommand()).append("/"); //$NON-NLS-1$
                pi.append(player.getNbrMFVibra()).append("/"); //$NON-NLS-1$
                pi.append(player.getNbrMFActive()).append("/"); //$NON-NLS-1$
                pi.append(player.getNbrMFInferno());

                ((DefaultListModel) lisMinefield.getModel()).addElement(pi
                        .toString());
            }
        }
View Full Code Here

        final boolean useBv = chkBV.isSelected();
        final boolean useCost = chkCost.isSelected();

        ((DefaultListModel) lisBVs.getModel()).removeAllElements();
        for (Enumeration<Player> i = client.getPlayers(); i.hasMoreElements();) {
            final Player player = i.nextElement();
            if (player == null) {
                continue;
            }
            float playerValue = 0;
            for (Enumeration<Entity> j = client.getEntities(); j
                    .hasMoreElements();) {
                Entity entity = j.nextElement();
                if (entity.getOwner().equals(player)) {
                    if (useBv) {
                        playerValue += entity.calculateBattleValue();
                    } else if (useCost) {
                        playerValue += entity.getCost();
                    } else {
                        playerValue += entity.getWeight();
                    }
                }
            }
            if (client.game.getOptions().booleanOption("real_blind_drop")
                    && (player.getId() != client.getLocalPlayer().getId())) {
                playerValue = playerValue > 0 ? 9999 : 0;
            }
            if (useBv) {
                ((DefaultListModel) lisBVs.getModel())
                        .addElement(player.getName()
                                + Messages.getString("ChatLounge.BV") + (int) (playerValue) + " (FM: " + (int) (playerValue * player.getForceSizeBVMod()) + ")"); //$NON-NLS-1$
            } else if (useCost) {
                ((DefaultListModel) lisBVs.getModel())
                        .addElement(player.getName()
                                + Messages.getString("ChatLounge.Cost") + (int) playerValue); //$NON-NLS-1$
            } else {
                ((DefaultListModel) lisBVs.getModel()).addElement(player
                        .getName()
                        + Messages.getString("ChatLounge.Tons") + playerValue); //$NON-NLS-1$
            }
        }
    }
View Full Code Here

     * Refreshes the starting positions
     */
    private void refreshStarts() {
        ((DefaultListModel) lisStarts.getModel()).removeAllElements();
        for (Enumeration<Player> i = client.getPlayers(); i.hasMoreElements();) {
            Player player = i.nextElement();
            if (player != null) {
                StringBuffer ssb = new StringBuffer();
                ssb.append(player.getName()).append(" : "); //$NON-NLS-1$
                ssb.append(IStartingPositions.START_LOCATION_NAMES[player
                        .getStartingPos()]);
                ((DefaultListModel) lisStarts.getModel()).addElement(ssb
                        .toString());
            }
        }
View Full Code Here

                                    "In Double Blind play, you cannot choose 'Any' as starting position.");
                    return;
                }
                for (Enumeration<Player> e = client.game.getPlayers(); e
                        .hasMoreElements();) {
                    Player player = e.nextElement();
                    if (player.getStartingPos() == 0) {
                        continue;
                    }
                    // CTR and EDG don't overlap
                    if (((player.getStartingPos() == 9) && (i == 10))
                        || ((player.getStartingPos() == 10) && (i == 9))) {
                        continue;
                    }
                    // check for overlapping starting directions
                    if (((player.getStartingPos() == i)
                            || (player.getStartingPos() + 1 == i) || (player
                            .getStartingPos() - 1 == i))
                            && (player.getId() != client.getLocalPlayer()
                                    .getId())) {
                        clientgui
                                .doAlertDialog(
                                        "Must choose exclusive deployment zone",
                                        "When using double blind, each player needs to have an exclusive deployment zone.");
View Full Code Here

    /**
     * Sets up the player info (team, camo) panel
     */
    private void setupPlayerInfo() {
        Player player = client.getLocalPlayer();

        panPlayerInfo = new JPanel();

        labPlayerInfo = new JLabel(Messages
                .getString("ChatLounge.labPlayerInfo")); //$NON-NLS-1$

        lisPlayerInfo = new JList(new DefaultListModel());
        lisPlayerInfo.addListSelectionListener(this);

        butAddBot = new JButton(Messages.getString("ChatLounge.butAddBot")); //$NON-NLS-1$
        butAddBot.setActionCommand("add_bot"); //$NON-NLS-1$
        butAddBot.addActionListener(this);

        butRemoveBot = new JButton(Messages
                .getString("ChatLounge.butRemoveBot")); //$NON-NLS-1$
        butRemoveBot.setEnabled(false);
        butRemoveBot.setActionCommand("remove_bot"); //$NON-NLS-1$
        butRemoveBot.addActionListener(this);

        labTeam = new JLabel(
                Messages.getString("ChatLounge.labTeam"), SwingConstants.RIGHT); //$NON-NLS-1$
        labCamo = new JLabel(
                Messages.getString("ChatLounge.labCamo"), SwingConstants.RIGHT); //$NON-NLS-1$

        choTeam = new JComboBox();
        setupTeams();
        choTeam.addItemListener(this);

        butCamo = new JButton();
        butCamo.setPreferredSize(new Dimension(84, 72));
        butCamo.setActionCommand("camo"); //$NON-NLS-1$
        butCamo.addActionListener(this);
        camoDialog.addItemListener(new CamoChoiceListener(camoDialog, butCamo,
                this));
        refreshCamos();

        // If we have a camo pattern, use it. Otherwise set a background.
        Image[] images = (Image[]) camoDialog.getSelectedObjects();
        if (images != null) {
            butCamo.setIcon(new ImageIcon(images[0]));
        } else {
            BufferedImage tempImage = new BufferedImage(84, 72, BufferedImage.TYPE_INT_RGB);
            Graphics2D graphics = tempImage.createGraphics();
            graphics.setColor(PlayerColors.getColor(player.getColorIndex()));
            graphics.fillRect(0, 0, 84, 72);
            butCamo.setIcon(new ImageIcon(tempImage));
        }

        butInit = new JButton(Messages.getString("ChatLounge.butInit")); //$NON-NLS-1$
View Full Code Here

            Entity entity = i.nextElement();
            sortedEntities.add(entity);
        }
        Collections.sort(sortedEntities, new Comparator<Entity>() {
            public int compare(final Entity a, final Entity b) {
                final Player p_a = a.getOwner();
                final Player p_b = b.getOwner();
                final int t_a = p_a.getTeam();
                final int t_b = p_b.getTeam();
                if (p_a.equals(client.getLocalPlayer())
                        && !p_b.equals(client.getLocalPlayer())) {
                    return -1;
                } else if (p_b.equals(client.getLocalPlayer())
                        && !p_a.equals(client.getLocalPlayer())) {
                    return 1;
                } else if ((t_a == client.getLocalPlayer().getTeam())
                        && (t_b != client.getLocalPlayer().getTeam())) {
                    return -1;
                } else if ((t_b == client.getLocalPlayer().getTeam())
                        && (t_a != client.getLocalPlayer().getTeam())) {
                    return 1;
                } else if (t_a != t_b) {
                    return t_a - t_b;
                } else if (!p_a.equals(p_b)) {
                    return p_a.getName().compareTo(p_b.getName());
                } else {
                    return a.getId() - b.getId();
                }
            }
        });
View Full Code Here

     * Refreshes the player info
     */
    private void refreshPlayerInfo() {
        ((DefaultListModel) lisPlayerInfo.getModel()).removeAllElements();
        for (Enumeration<Player> i = client.getPlayers(); i.hasMoreElements();) {
            final Player player = i.nextElement();
            if (player != null) {
                StringBuffer pi = new StringBuffer();
                pi.append(player.getName()).append(" : "); //$NON-NLS-1$
                pi.append(Player.teamNames[player.getTeam()]);

                String plyrCamo = player.getCamoFileName();

                if ((plyrCamo == null) || Player.NO_CAMO.equals(plyrCamo)) {
                    pi
                            .append(", ").append(Player.colorNames[player.getColorIndex()]); //$NON-NLS-1$
                } else {
                    pi.append(", ").append(player.getCamoFileName()); //$NON-NLS-1$
                }

                pi.append(", INIT: ");
                if (player.getConstantInitBonus() >= 0) {
                    pi.append(" +").append(
                            Integer.toString(player.getConstantInitBonus()));
                } else {
                    pi.append(" ").append(
                            Integer.toString(player.getConstantInitBonus()));
                }

                ((DefaultListModel) lisPlayerInfo.getModel()).addElement(pi
                        .toString());
            }
View Full Code Here

TOP

Related Classes of megamek.common.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.