Package monopoly.model.gamefield

Examples of monopoly.model.gamefield.CompanyCell


     */
    public void start(int playerCount) {
        _field.clear();

        _field.addCell(new EmptyCell());
        _field.addCell(new CompanyCell(
                "Bacardi", 16000, (int) (16000 * 0.6), 3500));
        _field.addCell(new PenaltyCell());
        _field.addCell(new CompanyCell(
                "Smirnoff", 16000, (int) (16000 * 0.6), 2500));
        _field.addCell(new PenaltyCell());
        _field.addCell(new CompanyCell(
                "Absolut Vodka", 16000, (int) (16000 * 0.6), 4000));
        _field.addCell(new GiftCell());
        _field.addCell(new CompanyCell(
                "Microsoft", 88000, (int) (88000 * 0.6), 38000));
        _field.addCell(new CompanyCell(
                "Marlboro", 20000, (int) (20000 * 0.6), 1500));
        _field.addCell(new EmptyCell());
        _field.addCell(new CompanyCell(
                "Kent", 20000, (int) (20000 * 0.6), 1500));
        _field.addCell(new CompanyCell(
                "Parlament", 20000, (int) (20000 * 0.6), 2000));
        _field.addCell(new CompanyCell(
                "Nike", 28000, (int) (28000 * 0.6), 4000));
        _field.addCell(new CompanyCell(
                "Adidas", 28000, (int) (28000 * 0.6), 6300));
        _field.addCell(new CompanyCell(
                "Puma", 28000, (int) (28000 * 0.6), 4900));
        _field.addCell(new GiftCell());
        _field.addCell(new CompanyCell(
                "IBM", 50000, (int) (50000 * 0.6), 15900));
        _field.addCell(new CompanyCell(
                "Scania", 35000, (int) (35000 * 0.6), 10000));
        _field.addCell(new EmptyCell());
        _field.addCell(new CompanyCell(
                "Man", 40000, (int) (40000 * 0.6), 12000));
        _field.addCell(new GiftCell());
        _field.addCell(new CompanyCell(
                "Nokia", 48000, (int) (48000 * 0.6), 16000));
        _field.addCell(new CompanyCell(
                "Samsung", 48000, (int) (48000 * 0.6), 17000));
        _field.addCell(new CompanyCell(
                "Panasonic", 48000, (int) (48000 * 0.6), 17000));
        _field.addCell(new CompanyCell(
                "Apple", 90000, (int) (90000 * 0.6), 40000));
        _field.addCell(new CompanyCell(
                "Beeline", 52000, (int) (52000 * 0.6), 25000));
        _field.addCell(new CompanyCell(
                "Megafon", 52000, (int) (52000 * 0.6), 27000));
        _field.addCell(new PenaltyCell());
        _field.addCell(new CompanyCell(
                "Gucci", 64000, (int) (64000 * 0.6), 29900));
        _field.addCell(new CompanyCell(
                "Cannel", 65000, (int) (65000 * 0.6), 28000));
        _field.addCell(new PenaltyCell());
        _field.addCell(new CompanyCell(
                "Dell", 68000, (int) (68000 * 0.6), 30000));
        _field.addCell(new GiftCell());
        _field.addCell(new CompanyCell(
                "Pepsi", 80000, (int) (80000 * 0.6), 36000));
        _field.addCell(new PenaltyCell());
        _field.addCell(new CompanyCell(
                "Coca-cola", 85000, (int) (85000 * 0.6), 38100));

        List<GameFieldCellBase> cells = _field.cells();
        for (int i = 0; i < cells.size() - 1; i++) {
            cells.get(i).setNext(cells.get(i + 1));
View Full Code Here


                    + "</html>");

            GameViewEvent event = new GameViewEvent(this, p, penalty);
            fireMadePlayerPenalty(event);
        } else if (cell instanceof CompanyCell) {
            final CompanyCell companyCell = (CompanyCell) cell;

            if (companyCell.owner() == _gameModel.bank()) {
                _canPlayerBuyLand = true;

                final Dialog dialog = new JDialog();
                dialog.setModal(true);
                dialog.setTitle("Фирма \"" + companyCell.name() + "\"");
                dialog.setLayout(new GridBagLayout());
                GridBagConstraints c = new GridBagConstraints();
                c.fill = GridBagConstraints.BOTH;
                c.insets = new Insets(5, 5, 5, 5);

                c.gridx = 0;
                c.gridy = 0;
                dialog.add(new JLabel("<html>"
                        + "Игрок <font color=" + HTMLColors.getName(p.color()) + ">"
                        + "\"" + p.name() + "\"</font>" + "остановился на ячейки"
                        + " являющейся фирмой <u>\"" + companyCell.name() + "\"</u>"
                        + " принадлежащей Банку.<br>"
                        + "Желаете приобрести указанную фирму за ее номинальную"
                        + " цену <i>" + companyCell.cost() + "$?</i>"
                        + "</html>"), c);

                JButton ybttn = new JButton("Да");
                ybttn.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        _canPlayerBuyLand = false;

                        GameViewEvent event = new GameViewEvent(this, p,
                                companyCell, companyCell.cost());
                        fireMadePlayerBuyLand(event);

                        dialog.dispose();
                    }
                });

                c.fill = GridBagConstraints.VERTICAL;
                c.gridy = 1;
                dialog.add(ybttn, c);

                JButton nbttn = new JButton("Нет");
                nbttn.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        dialog.dispose();
                    }
                });

                c.gridy = 2;
                dialog.add(nbttn, c);

                dialog.pack();
                dialog.setLocationRelativeTo(this);
                dialog.setResizable(false);
                dialog.setVisible(true);

                if (_canPlayerBuyLand == false) {
                    showSimpleDialogMessage("Недостаточно денежных средств",
                            "<html>"
                            + "Игроку <font color=" + HTMLColors.getName(p.color())
                            + ">\"" + p.name() + "\"</font> не хватило денежных "
                            + "средств для покупки фирмы <u>\"" + companyCell.name()
                            + "\"</u>.<br>Необходмо: <i>" + companyCell.cost()
                            + "$.</i><br>Имеется: <i>" + p.money() + "$.</i>"
                            + "</html>");
                }
            } else if (companyCell.owner() != p) {
                final Dialog infoDialog = new JDialog();
                infoDialog.setModal(true);
                infoDialog.setTitle("Фирма \"" + companyCell.name() + "\"");
                infoDialog.setLayout(new GridBagLayout());
                GridBagConstraints c = new GridBagConstraints();
                c.fill = GridBagConstraints.BOTH;
                c.insets = new Insets(5, 5, 5, 5);

                c.gridx = 0;
                c.gridy = 0;

                Color color = HTMLColors.black;
                final ILandOwner owner = companyCell.owner();
                if (owner instanceof Player) {
                    color = ((Player) owner).color();
                }

                infoDialog.add(new JLabel("<html>"
                        + "Игрок <font color=" + HTMLColors.getName(p.color()) + ">"
                        + "\"" + p.name() + "\"</font>" + "остановился на ячейки"
                        + " являющейся фирмой <u>\"" + companyCell.name() + "\"</u>"
                        + " и принадлежащей игроку <font color="
                        + HTMLColors.getName(color) + ">\"" + owner.name()
                        + "\"</font>.<br>"
                        + "Оплатите арендную плату в размере <i>"
                        + companyCell.rent() + "$.</i>"
                        + "</html>"), c);

                JButton okbttn = new JButton("OK");
                okbttn.setAlignmentX(JComponent.CENTER_ALIGNMENT);
                okbttn.addActionListener(new ActionListener() {

                    public void actionPerformed(ActionEvent e) {
                        _canPlayerPaidRent = false;

                        GameViewEvent event = new GameViewEvent(this, p,
                                companyCell);
                        fireMadePlayerPayRent(event);

                        infoDialog.dispose();
                    }
                });

                c.fill = GridBagConstraints.NONE;
                c.gridy = 1;
                infoDialog.add(okbttn, c);

                infoDialog.pack();
                infoDialog.setLocationRelativeTo(this);
                infoDialog.setResizable(false);
                infoDialog.setVisible(true);

                if (_canPlayerPaidRent == true) {
                    final Dialog dialog = new JDialog();
                    dialog.setModal(true);
                    dialog.setTitle("Игрок \"" + p.name() + "\"");
                    dialog.setLayout(new GridBagLayout());

                    c = new GridBagConstraints();
                    c.fill = GridBagConstraints.BOTH;
                    c.insets = new Insets(5, 5, 5, 5);

                    final JLabel questionLbl = new JLabel();
                    final JLabel amountLbl = new JLabel();
                    final JSpinner amountSpr = new JSpinner();
                    final JButton ybttn = new JButton("Да");
                    ybttn.setAlignmentX(JComponent.CENTER_ALIGNMENT);
                    final JButton nbttn = new JButton("Нет");
                    nbttn.setAlignmentX(JComponent.CENTER_ALIGNMENT);

                    c.gridx = 0;
                    c.gridy = 0;
                    dialog.add(questionLbl, c);

                    c.gridx = 0;
                    c.gridy = 1;
                    dialog.add(amountLbl, c);

                    c.gridx = 0;
                    c.gridy = 2;
                    dialog.add(amountSpr, c);

                    c.gridx = 0;
                    c.gridy = 3;
                    c.fill = GridBagConstraints.NONE;
                    dialog.add(ybttn, c);

                    c.gridx = 0;
                    c.gridy = 4;
                    dialog.add(nbttn, c);

                    questionLbl.setText("<html>"
                            + "Желаете попробывать перекупить у игрока <font color="
                            + HTMLColors.getName(color) + ">\"" + owner.name()
                            + "\"</font> фирму <u>\"" + companyCell.name()
                            + "\"</u>?"
                            + "</html>");

                    amountLbl.setText("Предложить сумму ($):");

                    SpinnerModel sprModel = new SpinnerNumberModel(
                            companyCell.cost(), companyCell.cost(),
                            companyCell.cost() * 10, 1000);
                    amountSpr.setModel(sprModel);

                    ybttn.setActionCommand("P1");
                    ybttn.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            String actionCommand = e.getActionCommand();
                            if ("P1".equals(actionCommand)) {
                                dialog.setTitle("Игрок \"" + owner.name() + "\"");

                                questionLbl.setText("<html>"
                                        + "Игрок <font color="
                                        + HTMLColors.getName(p.color()) + ">\""
                                        + p.name() + "\"</font> предложил вам "
                                        + "продать свою фирму <u>\""
                                        + companyCell.name() + "\"</u>. Вы согласны?"
                                        + "</html>");
                                amountLbl.setText("Предложенная сумма ($):");

                                amountSpr.setEnabled(false);

                                ybttn.setActionCommand("P2");

                                dialog.pack();
                            } else if ("P2".equals(actionCommand)) {
                                _canPlayerBuyLand = false;
                                GameViewEvent event = new GameViewEvent(this, p,
                                        companyCell, (Integer) amountSpr.getValue());
                                fireMadePlayerBuyLand(event);

                                dialog.dispose();
                            }
                        }
                    });

                    nbttn.addActionListener(new ActionListener() {

                        public void actionPerformed(ActionEvent e) {
                            _canPlayerBuyLand = true;
                            dialog.dispose();
                        }
                    });

                    dialog.pack();
                    dialog.setLocationRelativeTo(this);
                    dialog.setResizable(false);
                    dialog.setVisible(true);

                    if (_canPlayerBuyLand == false) {
                        showSimpleDialogMessage("Недостаточно денежных средств",
                                "<html>"
                                + "Игроку <font color=" + HTMLColors.getName(p.color())
                                + ">\"" + p.name() + "\"</font> не хватило денежных "
                                + "средств для покупки фирмы <u>\"" + companyCell.name()
                                + "\"</u>.<br>Необходмо: <i>" + companyCell.cost()
                                + "$.</i><br>Имеется: <i>" + p.money() + "$.</i>"
                                + "</html>");
                    }
                }
            }
View Full Code Here

     * @param e аргументы события.
     */
    public void gameLandChangedOwner(GameModelEvent e) {
        ILand land = e.getLand();
        if (land instanceof CompanyCell) {
            CompanyCell company = (CompanyCell) land;
            CompanyCellPanel panel =
                    (CompanyCellPanel) _fieldPanel.cellPanel(company);

            panel.repaint();
        }
View Full Code Here

    /**
     * Показать подробную информацию о компаниию.
     */
    public void showCompanyInformation() {
        CompanyCell company = (CompanyCell) _cell;

        final Dialog infoDialog = new JDialog();
        infoDialog.setModal(true);
        infoDialog.setTitle("Компания " + company.name());

        infoDialog.setLayout(new GridBagLayout());
        GridBagConstraints c = new GridBagConstraints();

        c.fill = GridBagConstraints.BOTH;
        c.insets = new Insets(5, 5, 5, 5);
        c.ipady = 5;
        c.ipadx = 5;

        c.gridx = 0;
        c.gridy = 0;
        infoDialog.add(new JLabel("<html>"
                + "Наименование: <u>" + company.name()
                + "</u></html>"), c);

        c.gridy = 1;
        infoDialog.add(new JLabel("<html>"
                + "Цена: <i>" + company.cost() + " $</i>"
                + "</html>"), c);

        c.gridy = 2;
        infoDialog.add(new JLabel("<html>"
                + "Компенсация в случаи конфискации: <i>"
                + company.confiscationCost() + " $</i>"
                + "</html>"), c);

        c.gridy = 3;
        infoDialog.add(new JLabel("<html>"
                + "Арендная плата (рента): <i>"
                + company.rent() + " $</i>"
                + "</html>"), c);

        c.gridy = 4;
        Color color = HTMLColors.black;
        ILandOwner owner = company.owner();
        if (owner instanceof Player) {
            color = ((Player) owner).color();
        }

        infoDialog.add(new JLabel("<html>"
                + "Владелец: <font color="
                + HTMLColors.getName(color) + ">"
                + company.owner().name() + "</font>"
                + "</html>"), c);

        JButton bttn = new JButton("OK");
        bttn.setAlignmentX(JComponent.CENTER_ALIGNMENT);
        bttn.addActionListener(new ActionListener() {
View Full Code Here

     */
    @Override
    public void paint(Graphics g) {
        super.paint(g);

        CompanyCell company = (CompanyCell) _cell;

        int x = CELL_WIDTH / 3, y = CELL_HEIGHT - CELL_HEIGHT / 3;
       
        int indent = company.name().length();
       
        g.setColor(HTMLColors.black);
       
        g.setFont(new Font("Arial", Font.BOLD, 12));
        g.drawString(company.name(), x - indent, y - 15);
       
        g.setFont(new Font("Arial", Font.ITALIC, 12));
        g.drawString(company.cost() + "$", x - indent, y + 5);

        x = 0;
        y = CELL_HEIGHT - CELL_HEIGHT / 5;

        g.drawRect(x, y, CELL_WIDTH, CELL_HEIGHT - y);

        ILandOwner owner = company.owner();
        if (owner instanceof Player) {
            Player p = (Player) owner;

            Graphics2D g2d = (Graphics2D) g;
            GradientPaint gp = new GradientPaint(x, y, Color.WHITE,
View Full Code Here

TOP

Related Classes of monopoly.model.gamefield.CompanyCell

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.