📄 tdbfile.java
字号:
engineType = ((ParsedXML)children.nextElement()).getContent(); engineRating = Integer.parseInt(node.getAttribute(RATING)); } else if (node.getName().equals(STRUCTURE)) { structureType = ((ParsedXML)children.nextElement()).getContent(); } else if (node.getName().equals(GYRO)) { gyroType = ((ParsedXML)children.nextElement()).getContent(); } else if (node.getName().equals(COCKPIT)) { cockpitType = ((ParsedXML)children.nextElement()).getContent(); } else if (node.getName().equals(TARGSYS)) { targSysStr = ((ParsedXML)children.nextElement()).getContent().trim(); if ((targSysStr.length() >= 3) && (targSysStr.substring(0,3).equals("(C)"))) { clanTC = true; } } else if (children != null) { // Use recursion to process all the children while (children.hasMoreElements()) { parseBasicsNode((ParsedXML)children.nextElement()); } } // Other tags (that don't match any if blocks above) // are simply ignored. } private void parseMountedNode(ParsedXML node) throws EntityLoadingException { if (!node.getTypeName().equals("tag")) { // We only want to parse element nodes, text nodes // are directly parsed below. return; } Enumeration children = node.elements(); if (node.getName().equals(MOUNTED_ITEM)) { if (node.getAttribute(REAR_MOUNTED).equals(TRUE)) { isRearMounted[Integer.parseInt(node.getAttribute(ITEM_INDEX))] = true; } else { isRearMounted[Integer.parseInt(node.getAttribute(ITEM_INDEX))] = false; } if (node.getAttribute(IS_SPREAD).equals(TRUE)) { isSplit[Integer.parseInt(node.getAttribute(ITEM_INDEX))] = true; } else { isSplit[Integer.parseInt(node.getAttribute(ITEM_INDEX))] = false; } } else if (children != null) { // Use recursion to process all the children while (children.hasMoreElements()) { parseMountedNode((ParsedXML)children.nextElement()); } } // Other tags (that don't match any if blocks above) // are simply ignored. } private void parseCritNode(ParsedXML node) throws EntityLoadingException { if (!node.getTypeName().equals("tag")) { // We only want to parse element nodes, text nodes // are directly parsed below. return; } Enumeration children = node.elements(); if (node.getName().equals(LOCATION)) { int loc = -1; int i = 0; int armor = -1; int rearArmor = -1; if (node.getAttribute(ARMOR) != null) { armor = Integer.parseInt(node.getAttribute(ARMOR)); } if (node.getAttribute(REAR_ARMOR) != null) { rearArmor = Integer.parseInt(node.getAttribute(REAR_ARMOR)); } if (node.getAttribute(NAME).equals("LA") || node.getAttribute(NAME).equals("FLL")) { loc = Mech.LOC_LARM; larmArmor = armor; } else if (node.getAttribute(NAME).equals("RA") || node.getAttribute(NAME).equals("FRL")) { loc = Mech.LOC_RARM; rarmArmor = armor; } else if (node.getAttribute(NAME).equals("LT")) { loc = Mech.LOC_LT; ltArmor = armor; ltrArmor = rearArmor; } else if (node.getAttribute(NAME).equals("RT")) { loc = Mech.LOC_RT; rtArmor = armor; rtrArmor = rearArmor; } else if (node.getAttribute(NAME).equals("CT")) { loc = Mech.LOC_CT; ctArmor = armor; ctrArmor = rearArmor; } else if (node.getAttribute(NAME).equals("H")) { loc = Mech.LOC_HEAD; headArmor = armor; } else if (node.getAttribute(NAME).equals("LL") || node.getAttribute(NAME).equals("RLL")) { loc = Mech.LOC_LLEG; llegArmor = armor; } else if (node.getAttribute(NAME).equals("RL") || node.getAttribute(NAME).equals("RRL")) { loc = Mech.LOC_RLEG; rlegArmor = armor; } if (loc == -1) { throw new EntityLoadingException(" Bad Mech location: " + node.getAttribute(NAME)); } while (children.hasMoreElements()) { ParsedXML critSlotNode = (ParsedXML)children.nextElement(); critData[loc][i][0] = ((ParsedXML)critSlotNode.elements().nextElement()).getContent(); if (clanTC && critData[loc][i][0].equals("Targeting Computer")) { critData[loc][i][0] = "(C) "+critData[loc][i][0]; } critData[loc][i++][1] = critSlotNode.getAttribute(ITEM_INDEX); } } else if (children != null) { // Use recursion to process all the children while (children.hasMoreElements()) { parseCritNode((ParsedXML)children.nextElement()); } } // Other tags (that don't match any if blocks above) // are simply ignored. } public Entity getEntity() throws EntityLoadingException { try { Mech mech; if (creatorName == "Unknown" || !creatorName.equals("The Drawing Board") || Integer.parseInt(creatorVersion) != 2) { // MegaMek no longer supports older versions of The // Drawing Board (pre 2.0.23) due to incomplete xml // file information in those versions. throw new EntityLoadingException("This xml file is not a valid Drawing Board mech. Make sure you are using version 2.0.23 or later of The Drawing Board."); } if (gyroType.equals("Extra-Light")) gyroType = "XL"; else if (gyroType.equals("Heavy-Duty")) gyroType = "Heavy Duty"; if (cockpitType.equals("Torso-Mounted")) cockpitType = "Torso Mounted"; if (chassisConfig.equals("Quad")) { mech = new QuadMech(gyroType, cockpitType); } else { mech = new BipedMech(gyroType, cockpitType); } // aarg! those stupid sub-names in parenthesis screw everything up // we may do something different in the future, but for now, I'm // going to strip them out int pindex = name.indexOf("("); if (pindex == -1) { mech.setChassis(name); } else { mech.setChassis(name.substring(0, pindex - 1)); } if (variant != null) { mech.setModel(variant); } else if (model != null) { mech.setModel(model); } else { // Do mechs need a model? mech.setModel(""); } mech.setYear(Integer.parseInt(techYear)); mech.setOmni(isOmni); if (structureType.substring(0,3).equals("(C)")) { structureType = structureType.substring(4); } mech.setStructureType(structureType); if (armorType.substring(0,3).equals("(C)")) { armorType = armorType.substring(4); } mech.setArmorType(armorType); if (LAMTonnage != null) { throw new EntityLoadingException("Unsupported tech: LAM?"); } if (techBase.equals("Inner Sphere")) { switch (Integer.parseInt(rulesLevel)) { case 1 : mech.setTechLevel(TechConstants.T_IS_LEVEL_1); break; case 2 : mech.setTechLevel(TechConstants.T_IS_LEVEL_2); break; case 3 : mech.setTechLevel(TechConstants.T_IS_LEVEL_3); break; default : throw new EntityLoadingException("Unsupported tech level: " + rulesLevel); } } else if (techBase.equals("Clan")) { switch (Integer.parseInt(rulesLevel)) { case 2 : mech.setTechLevel(TechConstants.T_CLAN_LEVEL_2); break; case 3 : mech.setTechLevel(TechConstants.T_CLAN_LEVEL_3); break; default : throw new EntityLoadingException("Unsupported tech level: " + rulesLevel); } } else if (techBase.equals("Mixed (IS Chassis)") || techBase.equals("Inner Sphere 'C'")) { mech.setTechLevel(TechConstants.T_IS_LEVEL_3); mech.setMixedTech(true); } else if (techBase.equals("Mixed (Clan Chassis)")) { mech.setTechLevel(TechConstants.T_CLAN_LEVEL_3); mech.setMixedTech(true); } else { throw new EntityLoadingException("Unsupported tech base: " + techBase); } mech.setWeight(Integer.parseInt(tonnage)); if (jumpMP != null) mech.setOriginalJumpMP(Integer.parseInt(jumpMP)); int engineFlags = 0; if ((mech.isClan() && !mech.isMixedTech()) || (mech.isMixedTech() && mech.isClan() && !mech.itemOppositeTech(engineType))) { engineFlags = Engine.CLAN_ENGINE; } mech.setEngine(new Engine(engineRating, Engine.getEngineTypeByString(engineType), engineFlags)); int expectedSinks = Integer.parseInt(heatSinks); mech.autoSetInternal(); mech.initializeArmor(larmArmor, Mech.LOC_LARM); mech.initializeArmor(rarmArmor, Mech.LOC_RARM); mech.initializeArmor(ltArmor, Mech.LOC_LT); mech.initializeArmor(rtArmor, Mech.LOC_RT); mech.initializeArmor(ctArmor, Mech.LOC_CT); mech.initializeArmor(headArmor, Mech.LOC_HEAD); mech.initializeArmor(llegArmor, Mech.LOC_LLEG); mech.initializeArmor(rlegArmor, Mech.LOC_RLEG); mech.initializeRearArmor(ltrArmor, Mech.LOC_LT); mech.initializeRearArmor(rtrArmor, Mech.LOC_RT); mech.initializeRearArmor(ctrArmor, Mech.LOC_CT); // oog, crits. compactCriticals(mech); // we do these in reverse order to get the outermost // locations first, which is necessary for split crits to work for (int i = mech.locations() - 1; i >= 0; i--) { parseCrits(mech, i); } if (mech.isClan()) { mech.addClanCase(); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -