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

📄 infantry.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    }    /**     * Infantry only have one hit location.     */    public HitData rollHitLocation(int table, int side, int aimedLocation, int aimingMode) {        return rollHitLocation(table, side);    }              public HitData rollHitLocation( int table, int side ) {        return new HitData( 0 );    }    /**     * Infantry only have one hit location.     */    public HitData getTransferLocation(HitData hit) {         return new HitData(Entity.LOC_DESTROYED);    }    /**     * Gets the location that is destroyed recursively.     */    public int getDependentLocation(int loc) {        return Entity.LOC_NONE;    }    /**     * Infantry have no rear armor.     */    public boolean hasRearArmor(int loc) {        return false;    }    /**     * Infantry platoons do wierd and wacky things with armor     * and internals, but not all Infantry objects are platoons.     *     * @see     megamek.common.BattleArmor#isPlatoon()     */    protected boolean isPlatoon() { return true; }    /**     * Returns the number of men left in the platoon, or IArmorState.ARMOR_DESTROYED.     */    public int getInternal( int loc ) {        if ( !this.isPlatoon() ) {            return super.getInternal( loc );        }        return ( this.men > 0 ? this.men : IArmorState.ARMOR_DESTROYED );    }    /**     * Returns the number of men originally the platoon.     */    public int getOInternal( int loc ) {        if ( !this.isPlatoon() ) {            return super.getOInternal( loc );        }        return this.menStarting;    }    /**     * Sets the amount of men remaining in the platoon.     */    public void setInternal(int val, int loc) {    super.setInternal( val, loc );        this.men = val;    }    /**     * Returns the percent of the men remaining in the platoon.     */    public double getInternalRemainingPercent() {        if ( !this.isPlatoon() ) {            return super.getInternalRemainingPercent();        }    int menTotal = this.men > 0 ? this.men : 0; // Handle "DESTROYED"        return ((double) menTotal / this.menStarting);    }    /**     * Initializes the number of men in the platoon. Sets the original and     * starting  point of the platoon to the same number.     */      public void initializeInternal(int val, int loc) {        this.menStarting = val;        this.menShooting = val;        super.initializeInternal( val, loc );      }          /**     * Set the men in the platoon to the appropriate value for the      * platoon's movement type.     */    public void autoSetInternal() {    // Clan platoons have 25 men.    if ( this.isClan() ) {        this.initializeInternal( INF_PLT_CLAN_MAX_MEN,                     LOC_INFANTRY );        return;    }    // IS platoon strength is based upon movement type.        switch (this.getMovementMode()) {        case IEntityMovementMode.INF_LEG:        case IEntityMovementMode.INF_MOTORIZED:            this.initializeInternal( INF_PLT_MAX_MEN, LOC_INFANTRY );            break;        case IEntityMovementMode.INF_JUMP:            this.initializeInternal( INF_PLT_JUMP_MAX_MEN, LOC_INFANTRY );            break;        default:            throw new IllegalArgumentException                ( "Unknown movement type: " + this.getMovementMode() );        }                if(hasWorkingMisc(MiscType.F_TOOLS, MiscType.S_HEAVY_ARMOR)) {            initializeArmor( getOInternal(LOC_INFANTRY), LOC_INFANTRY );        }        return;    }    /**     * Infantry weapons are dictated by their type.     */    protected void addEquipment( Mounted mounted,                                 int loc,                                 boolean rearMounted )        throws LocationFullException     {        EquipmentType equip = mounted.getType();        // If the infantry can swarm, they're anti-mek infantry.        if ( Infantry.SWARM_MEK.equals( equip.getInternalName() ) ) {            this.antiMek = true;        }        // N.B. Clan Undine BattleArmor can leg attack, but aren't        //          classified as "anti-mek" in the BMRr, pg. 155).        else if ( Infantry.LEG_ATTACK.equals( equip.getInternalName() ) ||                  Infantry.STOP_SWARM.equals( equip.getInternalName() ) ) {            // Do nothing.        }        // Handle infantry weapons.        else if ( (mounted.getType() instanceof WeaponType) &&                  equip.hasFlag(WeaponType.F_INFANTRY) ) {            // Infantry can only mount one kind of infantry weapon.            WeaponType weapon = (WeaponType) mounted.getType();            long weaponType;            if ( this.weapons != INF_UNKNOWN ) {                throw new LocationFullException                    ( "Unit is already equiped with an infantry weapon" +                      " and does not need a " + weapon.getName() );            }            // If the weapon uses ammo, then *that* is our weapon type,            // otherwise it's a laser or flamer (get from equipment flags).            if ( weapon.getAmmoType() != AmmoType.T_NA ) {                weaponType = weapon.getAmmoType();            }            else {                weaponType = weapon.getFlags() &                     (WeaponType.F_LASER + WeaponType.F_FLAMER );            }            this.weapons = weaponType;            // Update our damage profile.            this.setDamage( weaponType );            // Inferno SRMs do half damage (rounded down).            if ( weapon.hasFlag(WeaponType.F_INFERNO) ) {                for ( int loop = 1; loop < damage.length; loop++ ) {                    damage[loop] = (int) Math.floor( damage[loop] / 2.0 );                }            }        }/*        // Infantry platoons can't carry big equipment.        else if ( this.isPlatoon() ) {            throw new LocationFullException                ( "Infantry platoons can not be equiped with a " +                  mounted.getName() );        }*/        // Update our superclass.        super.addEquipment( mounted, loc, rearMounted );    }    /**     * Infantry can fire all around themselves.     * But field guns are set up to a facing     */    public int getWeaponArc(int wn) {         if(this instanceof BattleArmor && dugIn == DUG_IN_NONE)            return Compute.ARC_360;         Mounted mounted = getEquipment(wn);        WeaponType wtype = (WeaponType)mounted.getType();        if((wtype.hasFlag(WeaponType.F_INFANTRY)             || wtype.hasFlag(WeaponType.F_EXTINGUISHER)             || wtype.getInternalName() == LEG_ATTACK             || wtype.getInternalName() == SWARM_MEK             || wtype.getInternalName() == STOP_SWARM)             && dugIn == DUG_IN_NONE)            return Compute.ARC_360;		return Compute.ARC_FORWARD;    }    /**     * Infantry can fire all around themselves.     * But field guns act like turret mounted on a tank     */    public boolean isSecondaryArcWeapon(int wn) {         if (this instanceof BattleArmor)            return false;         Mounted mounted = getEquipment(wn);        WeaponType wtype = (WeaponType)mounted.getType();        if (wtype.hasFlag(WeaponType.F_INFANTRY))            return false;		return true;    }    /**     * Infantry build no heat.     */    public int getHeatCapacity() {        return 999;    }    /**     * Infantry build no heat.     */    public int getHeatCapacityWithWater() {        return getHeatCapacity();    }    /**     * Infantry build no heat.     */    public int getEngineCritHeat() {        return 0;    }    /**     * Infantry have no critical slots.     */    protected int[] getNoOfSlots() { return NUM_OF_SLOTS; }        /**     * Infantry criticals can't be hit.     */    public boolean hasHittableCriticals(int loc) { return false; }    /**     * Calculates the battle value of this platoon.     */    public int calculateBattleValue() {        double dBV = 0;        // BV is factor of anti-Mek training, movement type and weapon type.        if ( this.antiMek ) {            if (this.weapons == INF_RIFLE) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )                    dBV = 32;                else if ( IEntityMovementMode.INF_MOTORIZED == this.getMovementMode() )                    dBV = 42;                else if ( IEntityMovementMode.INF_JUMP == this.getMovementMode() )                    dBV = 46;                else throw new IllegalArgumentException                        ( "Unknown movement type: " + this.getMovementMode() );            } else if (this.weapons == INF_MG) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )                    dBV = 47;                else if ( IEntityMovementMode.INF_MOTORIZED == this.getMovementMode() )                    dBV = 63;                else if ( IEntityMovementMode.INF_JUMP == this.getMovementMode() )                    dBV = 62;                else throw new IllegalArgumentException                        ( "Unknown movement type: " + this.getMovementMode() );            } else if (this.weapons == INF_FLAMER) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )                    dBV = 41;                else if ( IEntityMovementMode.INF_MOTORIZED == this.getMovementMode() )                    dBV = 54;                else if ( IEntityMovementMode.INF_JUMP == this.getMovementMode() )                    dBV = 51;                else throw new IllegalArgumentException                        ( "Unknown movement type: " + this.getMovementMode() );            } else if (this.weapons == INF_LASER) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )                    dBV = 60;                else if ( IEntityMovementMode.INF_MOTORIZED == this.getMovementMode() )                    dBV = 70;                else if ( IEntityMovementMode.INF_JUMP == this.getMovementMode() )                    dBV = 71;                else throw new IllegalArgumentException                        ( "Unknown movement type: " + this.getMovementMode() );            } else if (this.weapons == INF_SRM) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )                    dBV = 60;                else if ( IEntityMovementMode.INF_MOTORIZED == this.getMovementMode() )                    dBV = 70;                else if ( IEntityMovementMode.INF_JUMP == this.getMovementMode() )                    dBV = 71;                else throw new IllegalArgumentException                        ( "Unknown movement type: " + this.getMovementMode() );            } else if (this.weapons == INF_LRM) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )                    dBV = 56;                else if ( IEntityMovementMode.INF_MOTORIZED == this.getMovementMode() )                    dBV = 75;                else if ( IEntityMovementMode.INF_JUMP == this.getMovementMode() )                    dBV = 87;                else throw new IllegalArgumentException                        ( "Unknown movement type: " + this.getMovementMode() );            } else throw new IllegalArgumentException                    ( "Unknown infantry weapon: " + this.weapons );        } // End anti-Mek-trained        else {            if (this.weapons == INF_RIFLE) {                if ( IEntityMovementMode.INF_LEG == this.getMovementMode() )

⌨️ 快捷键说明

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