Package megamek.common

Examples of megamek.common.CriticalSlot


        // ItemListener
        //
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getItemSelectable() == m_chMode) {
                Mounted m = getSelectedEquipment();
                CriticalSlot cs = getSelectedCritical();
                if ((m != null) && m.getType().hasModes()) {
                    int nMode = m_chMode.getSelectedIndex();
                    if (nMode >= 0) {

                        if ((m.getType() instanceof MiscType)
                                && ((MiscType) m.getType()).isShield()
                                && (clientgui.getClient().game.getPhase() != IGame.Phase.PHASE_FIRING)) {
                            clientgui.systemMessage(Messages.getString(
                                    "MechDisplay.ShieldModePhase", null));//$NON-NLS-1$
                            return;
                        }

                        if ((m.getType() instanceof MiscType)
                                && ((MiscType) m.getType()).isVibroblade()
                                && (clientgui.getClient().game.getPhase() != IGame.Phase.PHASE_PHYSICAL)) {
                            clientgui.systemMessage(Messages.getString(
                                    "MechDisplay.VibrobladeModePhase", null));//$NON-NLS-1$
                            return;
                        }

                        if ((m.getType() instanceof MiscType)
                                && ((MiscType) m.getType())
                                        .hasSubType(MiscType.S_RETRACTABLE_BLADE)
                                && (clientgui.getClient().game.getPhase() != IGame.Phase.PHASE_MOVEMENT)) {
                            clientgui
                                    .systemMessage(Messages
                                            .getString(
                                                    "MechDisplay.RetractableBladeModePhase", null));//$NON-NLS-1$
                            return;
                        }

                        // Can only charge a capacitor if the weapon has not
                        // been fired.
                        if ((m.getType() instanceof MiscType)
                                && (m.getLinked() != null)
                                && ((MiscType) m.getType())
                                        .hasFlag(MiscType.F_PPC_CAPACITOR)
                                && m.getLinked().isUsedThisRound()
                                && (nMode == 1)) {
                            clientgui.systemMessage(Messages.getString(
                                    "MechDisplay.CapacitorCharging", null));//$NON-NLS-1$
                            return;
                        }
                        m.setMode(nMode);
                        // send the event to the server
                        clientgui.getClient().sendModeChange(en.getId(),
                                en.getEquipmentNum(m), nMode);

                        // notify the player
                        if (m.canInstantSwitch(nMode)) {
                            clientgui
                                    .systemMessage(Messages
                                            .getString(
                                                    "MechDisplay.switched", new Object[] { m.getName(), m.curMode().getDisplayableName() }));//$NON-NLS-1$
                        } else {
                            if (IGame.Phase.PHASE_DEPLOYMENT == clientgui
                                    .getClient().game.getPhase()) {
                                clientgui
                                        .systemMessage(Messages
                                                .getString(
                                                        "MechDisplay.willSwitchAtStart", new Object[] { m.getName(), m.pendingMode().getDisplayableName() }));//$NON-NLS-1$
                            } else {
                                clientgui
                                        .systemMessage(Messages
                                                .getString(
                                                        "MechDisplay.willSwitchAtEnd", new Object[] { m.getName(), m.pendingMode().getDisplayableName() }));//$NON-NLS-1$
                            }
                        }
                    }
                } else if ((cs != null)
                        && (cs.getType() == CriticalSlot.TYPE_SYSTEM)) {
                    int nMode = m_chMode.getSelectedIndex();
                    if (nMode >= 0) {
                        if ((cs.getIndex() == Mech.SYSTEM_COCKPIT)
                                && en.hasEiCockpit() && (en instanceof Mech)) {
                            Mech mech = (Mech) en;
                            mech.setCockpitStatus(nMode);
                            clientgui.getClient().sendSystemModeChange(
                                    en.getId(), Mech.SYSTEM_COCKPIT, nMode);
View Full Code Here


                        EquipmentMode em = e.nextElement();
                        m_chMode.addItem(em.getDisplayableName());
                    }
                    m_chMode.setSelectedItem(m.curMode().getDisplayableName());
                } else {
                    CriticalSlot cs = getSelectedCritical();
                    if ((cs != null) && (cs.getType() == CriticalSlot.TYPE_SYSTEM)) {
                        if ((cs.getIndex() == Mech.SYSTEM_COCKPIT)
                                && en.hasEiCockpit() && (en instanceof Mech)) {
                            ((DefaultComboBoxModel) m_chMode.getModel())
                                    .removeAllElements();
                            m_chMode.setEnabled(true);
                            m_chMode.addItem("EI Off");
View Full Code Here

            for (int i = 0; i < equipData.length; i++) {
                String eqName = new String(equipData[i]);
                eqName = eqName.substring(5, 28).trim();

                if (eqName.equals("No Lower Right Arm")) {
                    mech.removeCriticals(Mech.LOC_RARM, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_ARM));
                    mech.removeCriticals(Mech.LOC_RARM, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND));
                } else if (eqName.equals("No Lower Left Arm")) {
                    mech.removeCriticals(Mech.LOC_LARM, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_ARM));
                    mech.removeCriticals(Mech.LOC_LARM, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND));
                } else if (eqName.equals("No Right Hand")) {
                    mech.removeCriticals(Mech.LOC_RARM, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND));
                } else if (eqName.equals("No Left Hand")) {
                    mech.removeCriticals(Mech.LOC_LARM, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND));
                }
            }

            // hmm, what to do with the rest of equipment list... I dunno.

            // prefix is "Clan " or "IS "
            String prefix;
            if (mech.getTechLevel() == TechConstants.T_CLAN_TW) {
                prefix = "Clan ";
            } else {
                prefix = "IS ";
            }

            // parse the critical hit slots
            for (int i = 0; i < critData.length; i++) {
                int loc = mech.getLocationFromAbbr(critData[i].substring(3, 5));
                int slot = Integer.parseInt(critData[i].substring(5, 7));
                boolean rearMounted = false;
                String critName = critData[i].substring(7).trim();

                // if the slot's full already, skip it.
                if (mech.getCritical(loc, slot) != null) {
                    continue;
                }

                if (critName.startsWith("(R)")) {
                    rearMounted = true;
                    critName = critName.substring(3).trim();
                }
                if (critName.equalsIgnoreCase("Armored Cowl")) {
                    mech.setCowl(5);
                }
                // this is a bit a kludge, but MEP is stupid
                if (critName.equals("Heat Sink") && dblSinks) {
                    critName = "Double Heat Sink";
                }

                EquipmentType etype = EquipmentType.get(prefix + critName);
                if (etype == null) {
                    // try w/o prefix
                    etype = EquipmentType.get(critName);
                }
                if (etype != null) {
                    try {
                        if (etype.isSpreadable()) {
                            // do we already have one of these? Key on Type
                            Mounted m = hSharedEquip.get(etype);
                            if (m != null) {
                                // use the existing one
                                mech.addCritical(loc, new CriticalSlot(
                                        CriticalSlot.TYPE_EQUIPMENT, mech
                                                .getEquipmentNum(m), etype
                                                .isHittable(), m));
                                continue;
                            }
View Full Code Here

        // check for removed arm actuators...

        // no lower right arm
        if (!dataFile.getDataAsString("ra criticals")[2].trim()
                .equalsIgnoreCase("Lower Arm Actuator"))
            mech.removeCriticals(Mech.LOC_RARM, new CriticalSlot(
                    CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_ARM));
        // no right hand
        if (!dataFile.getDataAsString("ra criticals")[3].trim()
                .equalsIgnoreCase("Hand Actuator"))
            mech.removeCriticals(Mech.LOC_RARM, new CriticalSlot(
                    CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND));

        // no lower left arm
        if (!dataFile.getDataAsString("la criticals")[2].trim()
                .equalsIgnoreCase("Lower Arm Actuator"))
            mech.removeCriticals(Mech.LOC_LARM, new CriticalSlot(
                    CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_ARM));
        // no left hand
        if (!dataFile.getDataAsString("la criticals")[3].trim()
                .equalsIgnoreCase("Hand Actuator"))
            mech.removeCriticals(Mech.LOC_LARM, new CriticalSlot(
                    CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_HAND));

        // load equipment stuff...
        Vector<String>[] criticals = new Vector[8];

        criticals[Mech.LOC_HEAD] = dataFile.getDataAsVector("hd criticals");
        criticals[Mech.LOC_LARM] = dataFile.getDataAsVector("la criticals");
        criticals[Mech.LOC_RARM] = dataFile.getDataAsVector("ra criticals");
        criticals[Mech.LOC_LLEG] = dataFile.getDataAsVector("ll criticals");
        criticals[Mech.LOC_RLEG] = dataFile.getDataAsVector("rl criticals");
        criticals[Mech.LOC_LT] = dataFile.getDataAsVector("lt criticals");
        criticals[Mech.LOC_RT] = dataFile.getDataAsVector("rt criticals");
        criticals[Mech.LOC_CT] = dataFile.getDataAsVector("ct criticals");

        // prefix is "Clan " or "IS "
        String prefix;
        if (mech.getTechLevel() == TechConstants.T_CLAN_TW) {
            prefix = "Clan ";
        } else {
            prefix = "IS ";
        }

        for (int loc = 0; loc < criticals.length; loc++) {
            for (int c = 0; c < criticals[loc].size(); c++) {
                String critName = criticals[loc].get(c).toString().trim();
                boolean rearMounted = false;

                if (critName.startsWith("(R) ")) {
                    rearMounted = true;
                    critName = critName.substring(4);
                }
                if (critName.equalsIgnoreCase("Armored Cowl")) {
                    mech.setCowl(5);
                }
                if (critName.indexOf("Engine") != -1) {
                    mech.setCritical(loc, c, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE));
                    continue;
                } else if (critName.equalsIgnoreCase("Life Support")) {
                    mech
                            .setCritical(loc, c, new CriticalSlot(
                                    CriticalSlot.TYPE_SYSTEM,
                                    Mech.SYSTEM_LIFE_SUPPORT));
                    continue;
                } else if (critName.equalsIgnoreCase("Sensors")) {
                    mech.setCritical(loc, c, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS));
                    continue;
                } else if (critName.equalsIgnoreCase("Cockpit")) {
                    mech.setCritical(loc, c, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_COCKPIT));
                    continue;
                } else if (critName.equalsIgnoreCase("Gyro")) {
                    mech.setCritical(loc, c, new CriticalSlot(
                            CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO));
                    continue;
                }

                EquipmentType etype = EquipmentType.get(critName);
View Full Code Here

            }
            if (critName.equalsIgnoreCase("Armored Cowl")) {
                mech.setCowl(5);
            }
            if (critName.indexOf("Engine") != -1) {
                mech.setCritical(loc, i, new CriticalSlot(
                        CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE));
                continue;
            }
            if (critName.indexOf("Gyro") != -1) {
                mech.setCritical(loc, i, new CriticalSlot(
                        CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_GYRO));
                continue;
            }
            if (critName.indexOf("Life Support") != -1) {
                mech.setCritical(loc, i, new CriticalSlot(
                        CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_LIFE_SUPPORT));
                continue;
            }
            if (critName.indexOf("Sensors") != -1) {
                mech.setCritical(loc, i, new CriticalSlot(
                        CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_SENSORS));
                continue;
            }
            if (critName.indexOf("Cockpit") != -1) {
                mech.setCritical(loc, i, new CriticalSlot(
                        CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_COCKPIT));
                continue;
            }
            if (critName.endsWith("[LRM]") || critName.endsWith("[SRM]")) {
                // This is a lame kludge for The Drawing Board, which
                // identifies which type of missle weapon an
                // Artemis IV system goes with.
                critName = critName.substring(0, 14);
            }
            if (critName.endsWith("- Artemis IV")) {
                // Ugh, another lame kludge to allow for loading of
                // The Drawing Board's specially marked Artemis IV
                // missle ammo. The only real game difference is
                // c-bill cost, which we don't care about anyway.
                critName = critName.substring(0, critName
                        .indexOf(" - Artemis IV"));
            }
            if (critName.endsWith("- Narc")) {
                // Yet another lame kludge to allow for loading of
                // The Drawing Board's specially marked Narc
                // missle ammo.
                critName = critName.substring(0, critName.indexOf(" - Narc"));
            }
            if (critName.equals("(C) Endosteel")) {
                // MegaMek determines whether Endo Steel is IS or Clan
                // type by techbase of mech.
                critName = critName.substring(4);
            }
            if (critName.equals("(C) Ferro-Fibrous Armor")) {
                // MegaMek determines whether FF Armor is IS or Clan
                // type by techbase of mech.
                critName = critName.substring(4);
            }
            try {
                String hashPrefix;
                if (critName.startsWith("(C)")) {
                    // equipment specifically marked as clan
                    hashPrefix = "Clan ";
                    critName = critName.substring(4);
                } else if (critName.startsWith("(IS)")) {
                    // equipment specifically marked as inner sphere
                    hashPrefix = "IS ";
                    critName = critName.substring(5);
                } else if (mech.isClan()) {
                    // assume equipment is clan because mech is clan
                    hashPrefix = "Clan ";
                } else {
                    // assume equipment is inner sphere
                    hashPrefix = "IS ";
                }
                EquipmentType etype = EquipmentType.get(hashPrefix + critName);
                if (etype == null) {
                    // try without prefix
                    etype = EquipmentType.get(critName);
                }
                if (etype != null) {
                    if (etype.isSpreadable()) {
                        // do we already have one of these? Key on Type
                        Mounted m = hSharedEquip.get(etype);
                        if (m != null) {
                            // use the existing one
                            mech.addCritical(loc, new CriticalSlot(
                                    CriticalSlot.TYPE_EQUIPMENT, mech
                                            .getEquipmentNum(m), etype
                                            .isHittable(), m));
                            continue;
                        }
View Full Code Here

TOP

Related Classes of megamek.common.CriticalSlot

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.