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

📄 entity.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
            return 0;        }        if(movementMode == IEntityMovementMode.VTOL) {            return hex.surface() + elevation;        } else if (((movementMode == IEntityMovementMode.HOVER)                ||  (movementMode == IEntityMovementMode.NAVAL)                ||  (movementMode == IEntityMovementMode.HYDROFOIL)                ||  hex.containsTerrain(Terrains.ICE))                && hex.containsTerrain(Terrains.WATER)) {            return hex.surface();        } else {            return hex.floor();        }    }    /**     * Returns true if the specified hex contains some sort of prohibited     * terrain.     */    public boolean isHexProhibited(IHex hex) {        if(hex.containsTerrain(Terrains.IMPASSABLE)) return true;        return false;    }    /**     * Returns the name of the type of movement used.     */    public abstract String getMovementString(int mtype);    /**     * Returns the abbreviation of the name of the type of movement used.     */    public abstract String getMovementAbbr(int mtype);    /**     * Returns the name of the location specified.     */    public String getLocationName(HitData hit) {        return getLocationName(hit.getLocation());    }    protected abstract String[] getLocationNames();    /**     * Returns the name of the location specified.     */    public String getLocationName(int loc) {        String[] locationNames = getLocationNames();        if ( (null == locationNames) || (loc >= locationNames.length) )            return "";        return locationNames[loc];    }    protected abstract String[] getLocationAbbrs();    /**     * Returns the abbreviated name of the location specified.     */    public String getLocationAbbr(HitData hit) {        return getLocationAbbr(hit.getLocation()) + (hit.isRear() && hasRearArmor(hit.getLocation()) ? "R" : "") + (hit.getEffect() == HitData.EFFECT_CRITICAL ? " (critical)" : "");    }    /**     * Returns the abbreviated name of the location specified.     */    public String getLocationAbbr(int loc) {        String[] locationAbbrs = getLocationAbbrs();        if ( (null == locationAbbrs) || (loc >= locationAbbrs.length) )            return "";        return locationAbbrs[loc];    }    /**     * Returns the location that the specified abbreviation indicates     */    public int getLocationFromAbbr(String abbr) {        for (int i = 0; i < locations(); i++) {            if (getLocationAbbr(i).equalsIgnoreCase(abbr)) {                return i;            }        }        return Entity.LOC_NONE;    }    /**     * Rolls the to-hit number     */    public abstract HitData rollHitLocation(int table, int side, int aimedLocation, int aimingMode);    public abstract HitData rollHitLocation(int table, int side);    /**     * Gets the location that excess damage transfers to.  That is, one     * location inwards.     */    public abstract HitData getTransferLocation(HitData hit);    /** int version */    public int getTransferLocation(int loc) {        return getTransferLocation(new HitData(loc)).getLocation();    }    /**     * Gets the location that is destroyed recursively.  That is, one location     * outwards.     */    public abstract int getDependentLocation(int loc);    /**     * Does this location have rear armor?     */    public abstract boolean hasRearArmor(int loc);    /**     * Returns the amount of armor in the location specified,     * or ARMOR_NA, or ARMOR_DESTROYED.  Only works on front locations.     */    public int getArmor(int loc) {        return getArmor(loc, false);    }    /**     * Returns the amount of armor in the location hit,     * or IArmorState.ARMOR_NA, or IArmorState.ARMOR_DESTROYED.     */    public int getArmor(HitData hit) {        return getArmor(hit.getLocation(), hit.isRear());    }    /**     * Returns the amount of armor in the location specified,     * or IArmorState.ARMOR_NA, or IArmorState.ARMOR_DESTROYED.     */    public int getArmor(int loc, boolean rear) {        return armor[loc];    }    /**     * Returns the original amount of armor in the location specified.     * Only works on front locations.     */    public int getOArmor(int loc) {        return getOArmor(loc, false);    }    /**     * Returns the original amount of armor in the location hit.     */    public int getOArmor(HitData hit) {        return getOArmor(hit.getLocation(), hit.isRear());    }    /**     * Returns the original amount of armor in the location specified,     * or ARMOR_NA, or ARMOR_DESTROYED.     */    public int getOArmor(int loc, boolean rear) {        return orig_armor[loc];    }    /**     * Sets the amount of armor in the location specified.     */    public void setArmor(int val, HitData hit) {        setArmor(val, hit.getLocation(), hit.isRear());    }    /**     * Sets the amount of armor in the front location specified.     */    public void setArmor(int val, int loc) {        setArmor(val, loc, false);    }    /**     * Sets the amount of armor in the location specified.     */    public void setArmor(int val, int loc, boolean rear) {        armor[loc] = val;    }    public void refreshLocations() {        this.armor = new int[locations()];        this.internal = new int[locations()];        this.orig_armor = new int[locations()];        this.orig_internal = new int[locations()];        this.crits = new CriticalSlot[locations()][];        this.exposure = new int[locations()];        for (int i = 0; i < locations(); i++) {            this.crits[i] = new CriticalSlot[getNumberOfCriticals(i)];        }    }    /**     * Initializes the armor on the unit. Sets the original and starting point     * of the armor to the same number.     */    public void initializeArmor(int val, int loc) {        orig_armor[loc] = val;        setArmor(val, loc);    }    /**    * Returns the total amount of armor on the entity.    */    public int getTotalArmor() {        int totalArmor = 0;        for (int i = 0; i < locations(); i++) {            if (getArmor(i) > 0) {                totalArmor += getArmor(i);            }            if (hasRearArmor(i) && getArmor(i, true) > 0) {                totalArmor += getArmor(i, true);            }        }        return totalArmor;    }    /**    * Returns the total amount of armor on the entity.    */    public int getTotalOArmor() {        int totalArmor = 0;        for (int i = 0; i < locations(); i++) {            if (getOArmor(i) > 0) {                totalArmor += getOArmor(i);            }            if (hasRearArmor(i) && getOArmor(i, true) > 0) {                totalArmor += getOArmor(i, true);            }        }        return totalArmor;    }    /**     * Returns the percent of the armor remaining     */    public double getArmorRemainingPercent() {        if(getTotalOArmor() == 0)            return IArmorState.ARMOR_NA;        return ((double)getTotalArmor() / (double)getTotalOArmor());    }    /**     * Returns the amount of internal structure in the location hit.     */    public int getInternal(HitData hit) {        return getInternal(hit.getLocation());    }    /**     * Returns the amount of internal structure in the     * location specified, or ARMOR_NA, or ARMOR_DESTROYED.     */    public int getInternal(int loc) {        return internal[loc];    }    /**     * Returns the original amount of internal structure in the location hit.     */    public int getOInternal(HitData hit) {        return getOInternal(hit.getLocation());    }    /**     * Returns the original amount of internal structure in the     * location specified, or ARMOR_NA, or ARMOR_DESTROYED.     */    public int getOInternal(int loc) {        return orig_internal[loc];    }    /**     * Sets the amount of armor in the location specified.     */    public void setInternal(int val, HitData hit) {        setInternal(val, hit.getLocation());    }    /**     * Sets the amount of armor in the location specified.     */    public void setInternal(int val, int loc) {        internal[loc] = val;    }    /**     * Initializes the internal structure on the unit. Sets the original and starting point     * of the internal structure to the same number.     */    public void initializeInternal(int val, int loc) {        orig_internal[loc] = val;        setInternal(val, loc);    }    /**     * Set the internal structure to the appropriate value for the mech's     * weight class     */    public abstract void autoSetInternal();    /**     * Returns the total amount of internal structure on the entity.     */    public int getTotalInternal() {        int totalInternal = 0;        for (int i = 0; i < locations(); i++) {            if (getInternal(i) > 0) {                totalInternal += getInternal(i);            }        }        return totalInternal;    }    /**     * Returns the total original amount of internal structure on the entity.     */    public int getTotalOInternal() {        int totalInternal = 0;        for (int i = 0; i < locations(); i++) {            if (getOInternal(i) > 0) {                totalInternal += getOInternal(i);            }        }        return totalInternal;    }    /**     * Returns the percent of the armor remaining     */    public double getInternalRemainingPercent() {        return ((double)getTotalInternal() / (double)getTotalOInternal());    }    /**    * Is this location destroyed or breached?    */    public boolean isLocationBad(int loc) {        return getInternal(loc) == IArmorState.ARMOR_DESTROYED;    }    /**     * returns exposure or breached flag for location     */    public int getLocationStatus(int loc) {        return exposure[loc];    }    /**     * sets location exposure     * @param loc    the location who's exposure is to be set      * @param status the status to set     */    public void setLocationStatus(int loc, int status) {        if (exposure[loc] > ILocationExposureStatus.BREACHED) { //can't change BREACHED status            exposure[loc] = status;        }    }    /**     * Returns true is the location is a leg     */    public boolean locationIsLeg(int loc) {        return false;    }    /**     * Returns a string representing the armor in the location     */    public String getArmorString(int loc) {        return getArmorString(loc, false);    }    /**     * Returns a string representing the armor in the location     */    public String getArmorString(int loc, boolean rear) {        return armorStringFor(getArmor(loc, rear));    }    /**     * Returns a string representing the internal structure in the location     */    public String getInternalString(int loc) {        return armorStringFor(getInternal(loc));    }    /**     * Parses the game's internal armor representation into a human-readable     * string.     */    public static String armorStringFor(int value) {        if (value == IArmorState.ARMOR_NA) {            return "N/A";        } else if (value == IArmorState.ARMOR_DOOMED || value == IArmorState.ARMOR_DESTROYED) {            return "***";        } else {            return Integer.toString(value);        }    }    /**     * Returns the modifier to weapons fire due to heat.     */    public int getHeatFiringModifier() {        int mod = 0;        if (heat >= 8) {            mod++;        }        if (heat >= 13) {            mod++;        }        if (heat >= 17) {            mod++;        }        if (heat >= 24) {            mod++;        }        boolean mtHeat = game.getOptions().booleanOption("maxtech_heat");        if (mtHeat && heat >= 33) {            mod++;        }        if (mtHeat && heat >= 41) {            mod++;        }

⌨️ 快捷键说明

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