⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapsettings.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
    public void setBoardSize(int boardWidth, int boardHeight) {        if (boardWidth <= 0 || boardHeight <= 0) {            throw new IllegalArgumentException("Total board area must be positive");        }                // change only if actually different        if (this.boardWidth != boardWidth || this.boardHeight != boardHeight) {            this.boardWidth = boardWidth;            this.boardHeight = boardHeight;            boardsAvailable.removeAllElements();        }    }    public String getTheme() {        return theme;    }        public void setTheme(String th) {        theme = th;    }        public int getMapWidth() {        return mapWidth;    }    public int getMapHeight() {        return mapHeight;    }    public void setMapSize(int mapWidth, int mapHeight) {        if (mapWidth <= 0 || mapHeight <= 0) {            throw new IllegalArgumentException("Total map area must be positive");        }                this.mapWidth = mapWidth;        this.mapHeight = mapHeight;                boardsSelected.setSize(mapWidth * mapHeight);    }        public Enumeration getBoardsSelected() {        return boardsSelected.elements();    }    public Vector getBoardsSelectedVector() {        return boardsSelected;    }        public void setBoardsSelectedVector(Vector boardsSelected) {        this.boardsSelected = boardsSelected;    }        /**     * Fills in all nulls in the boards selected list with the specified board     */    public void setNullBoards(String board) {        for (int i = 0; i < boardsSelected.size(); i++) {            if (boardsSelected.elementAt(i) == null) {                boardsSelected.setElementAt(board, i);            }        }    }        public Vector getBoardBuildings(){        return boardBuildings;    }        public void setBoardBuildings(Vector buildings) {        this.boardBuildings = buildings;    }    /**     * Replaces the specified type of board with random boards     */    public void replaceBoardWithRandom(String board) {        for (int i = 0; i < boardsSelected.size(); i++) {            if (boardsSelected.elementAt(i).equals(board)) {                int rindex = Compute.randomInt(boardsAvailable.size() - 3) + 3;                // Do a one pi rotation half of the time.                if ( 0 == Compute.randomInt(2) ) {                    boardsSelected.setElementAt                        (Board.BOARD_REQUEST_ROTATION +                         boardsAvailable.elementAt(rindex), i);                } else {                    boardsSelected.setElementAt                        (boardsAvailable.elementAt(rindex), i);                }            }        }    }        /**     * Removes selected boards that aren't listed in the available boards     */    public void removeUnavailable() {        for (int i = 0; i < boardsSelected.size(); i++) {            if (boardsSelected.elementAt(i) == null || boardsAvailable.size() == 0             || boardsAvailable.indexOf(boardsSelected.elementAt(i)) == -1) {                boardsSelected.setElementAt(null, i);            }        }    }        public Enumeration getBoardsAvailable() {        return boardsAvailable.elements();    }    public Vector getBoardsAvailableVector() {        return boardsAvailable;    }        public void setBoardsAvailableVector(Vector boardsAvailable) {        this.boardsAvailable = boardsAvailable;    }        /**       Checks, if the Mapgenerator parameters are all valid. If not        they are changed to valid values.    */    public void validateMapGenParameters() {    if (hilliness < 0) {        hilliness = 0;    }    if (hilliness > 99) {        hilliness = 99;    }    if (cliffs < 0) {        cliffs = 0;    }    if (cliffs > 100) {        cliffs = 100;    }    if (range < 0 ) {        range = 0;    }       if (minWaterSpots < 0) {        minWaterSpots = 0;    }    if (maxWaterSpots < minWaterSpots) {        maxWaterSpots = minWaterSpots;    }    if (minWaterSize < 0) {        minWaterSize = 0;    }    if (maxWaterSize < minWaterSize) {        maxWaterSize = minWaterSize;    }    if (probDeep < 0) {        probDeep = 0;    }    if (probDeep > 100) {        probDeep = 100;    }    if (minForestSpots < 0) {        minForestSpots = 0;    }    if (maxForestSpots < minForestSpots) {        maxForestSpots = minForestSpots;    }    if (minForestSize < 0) {        minForestSize = 0;    }    if (maxForestSize < minForestSize) {        maxForestSize = minForestSize;    }    if (probHeavy < 0) {        probHeavy = 0;    }    if (probHeavy > 100) {        probHeavy = 100;    }    if (minRoughSpots < 0) {        minRoughSpots = 0;    }    if (maxRoughSpots < minRoughSpots) {        maxRoughSpots = minRoughSpots;    }    if (minRoughSize < 0) {        minRoughSize = 0;    }    if (maxRoughSize < minRoughSize) {        maxRoughSize = minRoughSize;    }    if (minSwampSpots < 0) {        minSwampSpots = 0;    }    if (maxSwampSpots < minSwampSpots) {        maxSwampSpots = minSwampSpots;    }    if (minSwampSize < 0) {        minSwampSize = 0;    }    if (maxSwampSize < minSwampSize) {        maxSwampSize = minSwampSize;    }    if (minPavementSpots < 0) {        minPavementSpots = 0;    }    if (maxPavementSpots < minPavementSpots) {        maxPavementSpots = minPavementSpots;    }    if (minPavementSize < 0) {        minPavementSize = 0;    }    if (maxPavementSize < minPavementSize) {        maxPavementSize = minPavementSize;    }    if (minRubbleSpots < 0) {        minRubbleSpots = 0;    }    if (maxRubbleSpots < minRubbleSpots) {        maxRubbleSpots = minRubbleSpots;    }    if (minRubbleSize < 0) {        minRubbleSize = 0;    }    if (maxRubbleSize < minRubbleSize) {        maxRubbleSize = minRubbleSize;    }    if (minFortifiedSpots < 0) {        minFortifiedSpots = 0;    }    if (maxFortifiedSpots < minFortifiedSpots) {        maxFortifiedSpots = minFortifiedSpots;    }    if (minFortifiedSize < 0) {        minFortifiedSize = 0;    }    if (maxFortifiedSize < minFortifiedSize) {        maxFortifiedSize = minFortifiedSize;    }    if (minIceSpots < 0) {        minIceSpots = 0;    }    if (maxIceSpots < minIceSpots) {        maxIceSpots = minIceSpots;    }    if (minIceSize < 0) {        minIceSize = 0;    }    if (maxIceSize < minIceSize) {        maxIceSize = minIceSize;    }    if (probRoad < 0) {        probRoad = 0;    }    if (probRoad > 100) {        probRoad = 100;    }    if (probInvert < 0) {        probInvert = 0;    }    if (probInvert > 100) {        probInvert = 100;    }    if (probRiver < 0) {        probRiver = 0;    }    if (probRiver > 100) {        probRiver = 100;    }    if (probCrater < 0) {        probCrater = 0;    }    if (probCrater > 100) {        probCrater = 100;    }    if (minRadius < 0) {        minRadius = 0;    }    if (maxRadius < minRadius) {        maxRadius = minRadius;    }    if (minCraters < 0 ) {        minCraters = 0;    }    if (maxCraters < minCraters) {        maxCraters = minCraters;    }    if (algorithmToUse < 0) {        algorithmToUse = 0;    }    if (algorithmToUse > 2) {        algorithmToUse = 2;    }    } /* validateMapGenParameters */        /**        Returns true if the this Mapsetting has the same mapgenerator        settings and size  as the parameter.        @param other The Mapsetting to which compare.        @return True if settings are the same.    */    public boolean equalMapGenParameters(MapSettings other) {        if ((this.boardWidth != other.getBoardWidth()) ||            (this.boardHeight != other.getBoardHeight()) ||            (this.mapWidth != other.getMapWidth()) ||            (this.mapHeight != other.getMapHeight()) ||            (this.invertNegativeTerrain != other.getInvertNegativeTerrain()) ||            (this.hilliness != other.getHilliness()) ||            (this.cliffs != other.getCliffs()) ||

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -