Examples of IBoard


Examples of megamek.common.IBoard

        secondLOSCursor.hide();
        if (s == null) {
            return;
        }

        IBoard gboard = game.getBoard();
        IHex sh = gboard.getHex(s);

        firstLOSCursor.move(s, sh);
        firstLOSCursor.setColor(new Color3f(sc));

        if (e == null) {
            return;
        }

        IHex eh = gboard.getHex(e);

        ruler = new ConnectionModel(s, e, sh.surface() + 1, eh.surface() + 1, null,
                new Color3f(ec), 0.5f);
        secondLOSCursor.move(e, eh);
        secondLOSCursor.setColor(new Color3f(ec));
View Full Code Here

Examples of megamek.common.IBoard

    public void gameNewAction(GameNewActionEvent e) {
    }

    public void gameBoardNew(GameBoardNewEvent e) {
        IBoard b = e.getOldBoard();
        if (b != null) {
            b.removeBoardListener(BoardView3D.this);
        }
        b = e.getNewBoard();
        if (b != null) {
            b.addBoardListener(BoardView3D.this);
        }
        updateBoard();
        if (b != null) {
            centerOnHex(new Coords(0, 0));
        }
View Full Code Here

Examples of megamek.common.IBoard

     * this turn are marked as "burning" for next turn. What turn the fire startd on is no
     * longer determined by level but is rather a characteristic of the hex.
     * Level now denotes standard and inferno fires.
     */
    private void resolveFire() {
        IBoard board = game.getBoard();
        int width = board.getWidth();
        int height = board.getHeight();
        int windDirection = game.getPlanetaryConditions().getWindDirection();
        int windStrength = game.getPlanetaryConditions().getWindStrength();
        Report r;

        // Get the position map of all entities in the game.
        Hashtable<Coords, Vector<Entity>> positionMap = game.getPositionMap();

        // process smoke FIRST, before any fires spread or
        // smoke is produced.
        resolveSmoke();

        // Cycle through all buildings, checking for fire.
        // ASSUMPTION: buildings don't lose 2 CF on the turn a fire starts.
        // ASSUMPTION: multi-hex buildings lose 2 CF in each burning hex
        Enumeration<Building> buildings = game.getBoard().getBuildings();
        while (buildings.hasMoreElements()) {
            Building bldg = buildings.nextElement();
            Enumeration<Coords> bldgCoords = bldg.getCoords();
            while (bldgCoords.hasMoreElements()) {
                Coords coords = bldgCoords.nextElement();
                if (bldg.isBurning(coords)) {
                    int cf = Math.max(bldg.getCurrentCF(coords) - 2, 0);
                    bldg.setCurrentCF(cf, coords);

                    // Does the building burn down?
                    if (cf == 0) {
                        r = new Report(5120, Report.PUBLIC);
                        r.add(bldg.getName());
                        vPhaseReport.addElement(r);
                    }

                    // If it doesn't collapse under its load, mark it for update.
                    else if (!server.checkForCollapse(bldg, positionMap, coords, false)) {
                        bldg.setPhaseCF(cf, coords);
                    }
                }

            }
         }

        debugTime("resolve fire 1", true);

        // Cycle through all hexes, checking for fire and the spread of fire
        for (int currentXCoord = 0; currentXCoord < width; currentXCoord++) {
            for (int currentYCoord = 0; currentYCoord < height; currentYCoord++) {
                Coords currentCoords = new Coords(currentXCoord, currentYCoord);
                IHex currentHex = board.getHex(currentXCoord, currentYCoord);

                if(currentHex.containsTerrain(Terrains.FIRE)) {
                    //If the woods has been cleared, or the building
                    // has collapsed put non-inferno fires out.
                    if ((currentHex.terrainLevel(Terrains.FIRE) == 1) && !currentHex.isIgnitable()) {
                        server.removeFire(currentCoords, "lack of fuel");
                        continue;
                    }

                    //only check spread for fires that didn't start this turn
                    if(currentHex.getFireTurn() > 0) {
                        //optional rule, woods burn down
                        if ((currentHex.containsTerrain(Terrains.WOODS) || currentHex
                                .containsTerrain(Terrains.JUNGLE))
                                && game.getOptions().booleanOption("woods_burn_down")) {
                            burnDownWoods(currentCoords);
                        }
                        //report and check for fire spread
                        r = new Report(5125, Report.PUBLIC);
                        if (currentHex.terrainLevel(Terrains.FIRE) == 2) {
                            r.messageId = 5130;
                        }
                        r.add(currentCoords.getBoardNum());
                        vPhaseReport.addElement(r);
                        spreadFire(currentXCoord, currentYCoord, windDirection, windStrength);
                    }
                }
            }
        }

        //Cycle through all hexes again, reporting new fires, spreading smoke, and incrementing the fire turn.
        //Can't do this in first loop because new fires may be spread
        for (int currentXCoord = 0; currentXCoord < width; currentXCoord++) {
            for (int currentYCoord = 0; currentYCoord < height; currentYCoord++) {
                Coords currentCoords = new Coords(currentXCoord, currentYCoord);
                IHex currentHex = board.getHex(currentXCoord, currentYCoord);

                if(currentHex.containsTerrain(Terrains.FIRE)) {
                    //was the fire started this turn?
                    if(currentHex.getFireTurn() == 0) {
                        //report fire started this round
                        r = new Report(5135, Report.PUBLIC);
                        r.add(currentCoords.getBoardNum());
                        vPhaseReport.addElement(r);

                        // If the hex contains a building, set it on fire.
                        Building bldg = game.getBoard().getBuildingAt(
                                currentCoords);
                        if (bldg != null) {
                            bldg.setBurning(true, currentCoords);
                        }
                    }

                    //check for any explosions
                    server.checkExplodeIndustrialZone(currentCoords, vPhaseReport);

                    //Add smoke (unless we are in a tornado)
                    boolean bInferno = currentHex.terrainLevel(Terrains.FIRE) == 2;
                    if (game.getPlanetaryConditions().getWindStrength() < PlanetaryConditions.WI_TORNADO_F13) {
                        ArrayList<Coords> smokeList = new ArrayList<Coords>();

                        smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, windDirection), Coords.yInDir(currentXCoord, currentYCoord, windDirection)));
                        smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, (windDirection+1)%6), Coords.yInDir(currentXCoord, currentYCoord, (windDirection+1)%6)));
                        smokeList.add(new Coords(Coords.xInDir(currentXCoord, currentYCoord, (windDirection+5)%6), Coords.yInDir(currentXCoord, currentYCoord, (windDirection+5)%6)));

                        server.addSmoke(smokeList, windDirection, bInferno);
                        board.initializeAround(currentXCoord, currentYCoord);
                    }
                    //increment the fire turn counter
                    currentHex.incrementFireTurn();
                    server.sendChangedHex(currentCoords);
                }
View Full Code Here

Examples of megamek.common.IBoard

     * cloud has drifted that turn. This method creates the class SmokeDrift to
     * store hex and size data for the smoke clouds. This method calls functions
     * driftAddSmoke, driftSmokeDissipate, driftSmokeReport
     */
    private void resolveSmoke() {
        IBoard board = game.getBoard();
        int windDir = game.getPlanetaryConditions().getWindDirection();
        int windStr = game.getPlanetaryConditions().getWindStrength();

        ArrayList<Coords> smokeToAdd;
        HashMap<SmokeCloud, ArrayList<Coords>> smokeCloudData = new HashMap<SmokeCloud, ArrayList<Coords>>();

        // Cycle through all smokeclouds

        for ( SmokeCloud cloud : server.getSmokeCloudList() ){
            smokeToAdd = new ArrayList<Coords>();
            for ( Coords currentCoords : cloud.getCoordsList() ){

                Coords smokeCoords = driftAddSmoke(currentCoords, windDir, windStr);
                //Smoke has Dissipated by moving into a hex with a greater then 4 elevation drop.
                if ( smokeCoords == null ){
                    Report r = new Report(5220, Report.PUBLIC);
                    r.add(currentCoords.getBoardNum());
                    vPhaseReport.addElement(r);
                    r = new Report(5222,Report.PUBLIC);
                    vPhaseReport.addElement(r);
                }
                else if (board.contains(smokeCoords) && !currentCoords.equals(smokeCoords) ) {
                    // don't add it to the vector if it's not on board!
                    smokeToAdd.add(smokeCoords);
                    cloud.setDrift(true);
                } else if ( !board.contains(smokeCoords) ) {
                    // report that the smoke has blown off the map
                    Report r = new Report(5230, Report.PUBLIC);
                    r.add(currentCoords.getBoardNum());
                    vPhaseReport.addElement(r);
                }
View Full Code Here

Examples of megamek.common.IBoard

     * @return
     */
    public Coords driftAddSmoke(Coords src, int windDir, int windStr, int directionChanges) {
        //Coords src = new Coords(x, y);
        Coords nextCoords = src.translated(windDir);
        IBoard board = game.getBoard();

        //if the wind conditions are calm, then don't drift it
        if(windStr == PlanetaryConditions.WI_NONE) {
            return src;
        }

        //if it is no longer on the board then return it now to avoid getting null arguments later
        if(!board.contains(nextCoords)) {
            return nextCoords;
        }

        int hexElevation = board.getHex(src).getElevation();
        int nextElevation = board.getHex(nextCoords).getElevation();

        if ( board.getHex(nextCoords).containsTerrain(Terrains.BUILDING) ) {
            nextElevation += board.getHex(nextCoords).terrainLevel(Terrains.BLDG_ELEV);
        }

        if ( board.getHex(src).containsTerrain(Terrains.BUILDING) ) {
            hexElevation += board.getHex(src).terrainLevel(Terrains.BLDG_ELEV);
        }
        //If the smoke moves into a hex that has a greater then 4 elevation drop it dissipates.
        if ( hexElevation - nextElevation > 4 ) {
            return null;
        }
View Full Code Here

Examples of megamek.common.IBoard

    /**
     * Check to see if screen clears
     */
    private void resolveScreen() {
        IBoard board = game.getBoard();
        int width = board.getWidth();
        int height = board.getHeight();
        // Cycle through all hexes, checking for screens
        debugTime("resolve screen 1", true);

        for (int currentXCoord = 0; currentXCoord < width; currentXCoord++ ) {

            for (int currentYCoord = 0; currentYCoord < height; currentYCoord++) {
                Coords currentCoords = new Coords(currentXCoord, currentYCoord);
                IHex currentHex = board.getHex(currentXCoord, currentYCoord);

                // check for existence of screen
                if (currentHex.containsTerrain(Terrains.SCREEN)){

                    if(Compute.d6(2)>6) {
View Full Code Here

Examples of megamek.common.IBoard

            } else {
                sheetBoards[i].load(name + ".board");
                BoardUtilities.flip(sheetBoards[i], isRotated, isRotated);
            }
        }
        IBoard newBoard = BoardUtilities.combine(mapSettings.getBoardWidth(), mapSettings.getBoardHeight(), mapSettings.getMapWidth(), mapSettings.getMapHeight(), sheetBoards, mapSettings.getMedium());
        if (game.getOptions().getOption("bridgeCF").intValue() > 0) {
            newBoard.setBridgeCF(game.getOptions().getOption("bridgeCF").intValue());
        }
        BoardUtilities.addWeatherConditions(newBoard, game.getPlanetaryConditions().getWeather(), game.getPlanetaryConditions().getWindStrength());
        game.setBoard(newBoard);
    }
View Full Code Here

Examples of megamek.common.IBoard

        int drawX = view.x / (int) (HEX_WC * scale) - 1;
        int drawY = view.y / (int) (HEX_H * scale) - 1;

        int drawWidth = view.width / (int) (HEX_WC * scale) + 3;
        int drawHeight = view.height / (int) (HEX_H * scale) + 3;
        IBoard board = game.getBoard();
        // loop through the hexes
        for (int i = 0; i < drawHeight; i++) {
            for (int j = 0; j < drawWidth; j++) {
                Coords c = new Coords(j + drawX, i + drawY);
                Point p = getHexLocation(c);
                if (board.isLegalDeployment(c, m_plDeployer)) {
                    g.setColor(Color.yellow);
                    int[] xcoords = { p.x + (int) (21 * scale), p.x + (int) (62 * scale),
                            p.x + (int) (83 * scale), p.x + (int) (83 * scale),
                            p.x + (int) (62 * scale), p.x + (int) (21 * scale), p.x, p.x };
                    int[] ycoords = { p.y, p.y, p.y + (int) (35 * scale), p.y + (int) (36 * scale),
 
View Full Code Here

Examples of megamek.common.IBoard

        int drawY = view.y / (int) (HEX_H * scale) - 1;

        int drawWidth = view.width / (int) (HEX_WC * scale) + 3;
        int drawHeight = view.height / (int) (HEX_H * scale) + 3;

        IBoard board = game.getBoard();
        Image scaledImage;

        // loop through the hexes
        for (int i = 0; i < drawHeight; i++) {
            for (int j = 0; j < drawWidth; j++) {
                Coords c = new Coords(j + drawX, i + drawY);
                Point p = getHexLocation(c);

                if (!board.contains(c)) {
                    continue;
                }

                if (weapon != null) {
                    // process targetted hexes
View Full Code Here

Examples of megamek.common.IBoard

        int drawY = view.y / (int) (HEX_H * scale) - 1;

        int drawWidth = view.width / (int) (HEX_WC * scale) + 3;
        int drawHeight = view.height / (int) (HEX_H * scale) + 3;

        IBoard board = game.getBoard();
        // loop through the hexes
        for (int i = 0; i < drawHeight; i++) {
            for (int j = 0; j < drawWidth; j++) {
                Coords c = new Coords(j + drawX, i + drawY);
                Point p = getHexLocation(c);

                if (!board.contains(c)) {
                    continue;
                }
                if (!game.containsMinefield(c)) {
                    continue;
                }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.