Package megamek.common

Examples of megamek.common.Minefield


            Coords coords = target.getPosition();

            Enumeration<Minefield> minefields = game.getMinefields(coords).elements();
            ArrayList<Minefield> mfRemoved = new ArrayList<Minefield>();
            while (minefields.hasMoreElements()) {
                Minefield mf = minefields.nextElement();
                if(server.clearMinefield(mf, ae, Minefield.CLEAR_NUMBER_WEAPON, vPhaseReport)) {
                    mfRemoved.add(mf);
                }
            }
            //we have to do it this way to avoid a concurrent error problem
View Full Code Here


                return;
            }
            Enumeration<?> mfs = client.game.getMinefields(coords).elements();
            ArrayList<Minefield> mfRemoved = new ArrayList<Minefield>();
            while (mfs.hasMoreElements()) {
                Minefield mf = (Minefield) mfs.nextElement();
                if (mf.getPlayerId() == client.getLocalPlayer().getId()) {
                    butDone.setEnabled(false);
                    mfRemoved.add(mf);
                    deployedMinefields.removeElement(mf);
                    if (mf.getType() == Minefield.TYPE_CONVENTIONAL) {
                        p.setNbrMFConventional(p.getNbrMFConventional() + 1);
                    } else if (mf.getType() == Minefield.TYPE_COMMAND_DETONATED) {
                        p.setNbrMFCommand(p.getNbrMFCommand() + 1);
                    } else if (mf.getType() == Minefield.TYPE_VIBRABOMB) {
                        p.setNbrMFVibra(p.getNbrMFVibra() + 1);
                    } else if (mf.getType() == Minefield.TYPE_ACTIVE) {
                        p.setNbrMFActive(p.getNbrMFActive() + 1);
                    } else if (mf.getType() == Minefield.TYPE_INFERNO) {
                        p.setNbrMFInferno(p.getNbrMFInferno() + 1);
                    }
                }
            }

            for (Minefield mf : mfRemoved) {
                client.game.removeMinefield(mf);
            }
        } else {
            // first check that there is not already a mine of this type
            // deployed
            Enumeration<?> mfs = client.game.getMinefields(coords).elements();
            while (mfs.hasMoreElements()) {
                Minefield mf = (Minefield) mfs.nextElement();
                if ((deployM && mf.getType() == Minefield.TYPE_CONVENTIONAL)
                        || (deployC && mf.getType() == Minefield.TYPE_COMMAND_DETONATED)
                        || (deployV && mf.getType() == Minefield.TYPE_VIBRABOMB)
                        || (deployA && mf.getType() == Minefield.TYPE_ACTIVE)
                        || (deployI && mf.getType() == Minefield.TYPE_INFERNO)) {
                    clientgui
                            .doAlertDialog(
                                    Messages
                                            .getString("DeployMinefieldDisplay.IllegalPlacement"), Messages.getString("DeployMinefieldDisplay.DuplicateMinefield")); //$NON-NLS-1$ //$NON-NLS-2$
                    return;
                }
            }

            Minefield mf;
            if (sea && !(deployM || deployI)) {
                clientgui
                        .doAlertDialog(
                                Messages
                                        .getString("DeployMinefieldDisplay.IllegalPlacement"), Messages.getString("DeployMinefieldDisplay.WaterPlacement")); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

            vPhaseReport.addElement(r);
            Coords coords = target.getPosition();
            Enumeration<Minefield> minefields = game.getMinefields(coords).elements();
            ArrayList<Minefield> mfRemoved = new ArrayList<Minefield>();
            while (minefields.hasMoreElements()) {
                Minefield mf = minefields.nextElement();
                if(server.clearMinefield(mf, ae, Minefield.CLEAR_NUMBER_WEAPON, vPhaseReport)) {
                    mfRemoved.add(mf);
                }
            }
            //we have to do it this way to avoid a concurrent error problem
View Full Code Here

            if (!client.game.containsMinefield(coords))
                return;
            Enumeration<?> mfs = client.game.getMinefields(coords).elements();
            ArrayList<Minefield> mfRemoved = new ArrayList<Minefield>();
            while(mfs.hasMoreElements()) {
                Minefield mf = (Minefield)mfs.nextElement()
                if (mf.getPlayerId() == client.getLocalPlayer().getId()) {
                    butDone.setEnabled(false);
                    mfRemoved.add(mf);
                    deployedMinefields.removeElement(mf);
                    if(mf.getType() == Minefield.TYPE_CONVENTIONAL) {
                        p.setNbrMFConventional(p.getNbrMFConventional() + 1);
                    }
                    else if (mf.getType() == Minefield.TYPE_COMMAND_DETONATED) {
                         p.setNbrMFCommand(p.getNbrMFCommand() + 1);
                    }
                    else if (mf.getType() == Minefield.TYPE_VIBRABOMB) {
                         p.setNbrMFVibra(p.getNbrMFVibra() + 1);
                    }
                    else if (mf.getType() == Minefield.TYPE_ACTIVE) {
                         p.setNbrMFActive(p.getNbrMFActive() + 1);
                    }
                    else if (mf.getType() == Minefield.TYPE_INFERNO) {
                         p.setNbrMFInferno(p.getNbrMFInferno() + 1);
                    }
                }
            }
            for(Minefield mf : mfRemoved) {
                client.game.removeMinefield(mf);
            }
        } else {
            //first check that there is not already a mine of this type deployed
            Enumeration<?> mfs = client.game.getMinefields(coords).elements();
            while(mfs.hasMoreElements()) {
                Minefield mf = (Minefield)mfs.nextElement();
                if((deployM && mf.getType() == Minefield.TYPE_CONVENTIONAL) ||
                        (deployC && mf.getType() == Minefield.TYPE_COMMAND_DETONATED) ||
                        (deployV && mf.getType() == Minefield.TYPE_VIBRABOMB) ||
                        (deployA && mf.getType() == Minefield.TYPE_ACTIVE) ||
                        (deployI && mf.getType() == Minefield.TYPE_INFERNO)) {
                    new AlertDialog(
                            clientgui.frame,
                            Messages
                                    .getString("DeployMinefieldDisplay.IllegalPlacement"), Messages.getString("DeployMinefieldDisplay.DuplicateMinefield")).setVisible(true); //$NON-NLS-1$ //$NON-NLS-2$
                    return;
                }
            }
           
            Minefield mf;
            if(sea && !(deployM || deployI)) {
                new AlertDialog(
                        clientgui.frame,
                        Messages
                                .getString("DeployMinefieldDisplay.IllegalPlacement"), Messages.getString("DeployMinefieldDisplay.WaterPlacement")).setVisible(true); //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

        for (int i = 0; i < number; i++) {
            Coords coords = new Coords(Compute.randomInt(game.getBoard().getWidth()), Compute
                    .randomInt(game.getBoard().getHeight()));

            if (game.containsMinefield(coords)) {
                Minefield mf = game.getMinefields(coords).get(0);
                if (mf.getPlayerId() == getLocalPlayer().getId()) {
                    i--;
                    continue;
                }
            } else {
                Minefield mf = null;

                if (type == 0) {
                    mf = Minefield.createMinefield(coords, getLocalPlayer().getId(),
                            Minefield.TYPE_CONVENTIONAL, 10);
                } else if (type == 1) {
View Full Code Here

        }

        if (game.containsMinefield(coords)) {
            Vector<Minefield> minefields = game.getMinefields(coords);
            for (int i = 0; i < minefields.size(); i++){
                Minefield mf =  minefields.elementAt(i);
                String owner =  " (" + game.getPlayer(mf.getPlayerId()).getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$

                switch (mf.getType()) {
                case (Minefield.TYPE_CONVENTIONAL) :
                    out.add(mf.getName()+Messages.getString("BoardView1.minefield") + " " + owner); //$NON-NLS-1$ //$NON-NLS-2$
                    break;
                case (Minefield.TYPE_COMMAND_DETONATED) :
                    out.add(mf.getName()+Messages.getString("BoardView1.minefield") + " " + owner); //$NON-NLS-1$ //$NON-NLS-2$
                    break;
                case (Minefield.TYPE_VIBRABOMB) :
                    if (mf.getPlayerId() == localPlayer.getId()) {
                        out.add(mf.getName()+Messages.getString("BoardView1.minefield")+"(" + mf.getSetting() + ") " + owner); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    } else {
                        out.add(mf.getName()+Messages.getString("BoardView1.minefield") + " " + owner); //$NON-NLS-1$ //$NON-NLS-2$
                    }
                    break;
                case (Minefield.TYPE_ACTIVE) :
                    out.add(mf.getName()+Messages.getString("BoardView1.minefield")+"(" + mf.getDensity() + ")" + owner); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    break;
                case (Minefield.TYPE_INFERNO) :
                    out.add(mf.getName()+Messages.getString("BoardView1.minefield")+"(" + mf.getDensity() + ")" + owner); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                    break;
                }
            }
        }
View Full Code Here

       
        // mine fields
        if (game.containsMinefield((Coords)getUserData())){
            Coords c = (Coords)getUserData();
            Minefield mf = game.getMinefields(c).elementAt(0);

            addChild(tileManager.getMinefieldSign());

            int nbrMfs = game.getNbrMinefields(c);
            if (nbrMfs > 1) {
                addText(Messages.getString("BoardView1.Multiple"), col); //$NON-NLS-1$
            } else if (nbrMfs == 1) {
                switch (mf.getType()) {
                case Minefield.TYPE_CONVENTIONAL:
                    addText(Messages.getString("BoardView1.Conventional"), col); //$NON-NLS-1$
                    break;
                case Minefield.TYPE_INFERNO:
                    addText(Messages.getString("BoardView1.Thunder-Inf") + mf.getDensity() + ")",  col); //$NON-NLS-1$ //$NON-NLS-2$
                    break;
                case Minefield.TYPE_ACTIVE:
                    addText(Messages.getString("BoardView1.Thunder-Actv") + mf.getDensity() + ")", col); //$NON-NLS-1$ //$NON-NLS-2$
                    break;
                case Minefield.TYPE_COMMAND_DETONATED:
                    addText(Messages.getString("BoardView1.detonated"), col); //$NON-NLS-1$
                    addText(Messages.getString("BoardView1.Command-"), col); //$NON-NLS-1$
                    break;
                case Minefield.TYPE_VIBRABOMB:
                    if (localPlayer != null && mf.getPlayerId() == localPlayer.getId())
                        addText(Messages.getString("BoardView1.Vibrabomb")+" (" + mf.getSetting() + ")", col); //$NON-NLS-1$ //$NON-NLS-2$
                    else
                        addText(Messages.getString("BoardView1.Vibrabomb"), col); //$NON-NLS-1$
                    break;
                }
            }
View Full Code Here

TOP

Related Classes of megamek.common.Minefield

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.