def __init__(self, load, base, mech): self.name = load.attributes["name"].value # Get production era prod_era = int(get_child_data(load, "loadout_productionera")) # Get year self.year = int(get_child_data(load, "loadout_year")) # Get BV. batt_val = int(get_child_data(load, "battle_value")) # Get cost cost = float(get_child_data(load, "cost")) # Sanity check for year year_era_test(self.year, prod_era, mech.name + " " + mech.model + self.name) # Get equipment self.equip = list(base.equip) for node in load.getElementsByTagName("equipment"): self.equip.append(Equip(node)) Load.__init__(self, load, mech, batt_val, prod_era, self.equip, cost) # These needs to be set after call to Load # Use base config heatsinks if not overriden self.heatsinks = base.heatsinks # Use base config jump-jets if not overriden self.jjets = base.jjets # Use base config partial wing (no over-ride cannot be pod-mounted) self.partw = base.partw # Get jumpjets for jets in load.getElementsByTagName("jumpjets"): self.jjets = JumpJets(jets, self.weight) # Get heat sinks for heat in load.getElementsByTagName("heatsinks"): self.heatsinks = Heatsinks(heat, self)
def __init__(self, xmldoc): Unit.__init__(self) # This is a combat vehicle self.type = "CV" # Get top-level structure data for cveh in xmldoc.getElementsByTagName('combatvehicle'): self.model = cveh.attributes["model"].value self.name = cveh.attributes["name"].value self.motive = cveh.attributes["motive"].value self.omni = cveh.attributes["omni"].value self.weight = int(cveh.attributes["tons"].value) # Get BV. Should give prime variant BV for Omni-vehicles # get first instance only to avoid problems with Omni-vehicles self.batt_val = int(get_child_data(cveh, 'battle_value')) # Motive for mot in cveh.getElementsByTagName('motive'): self.mot_type = mot.attributes["type"].value self.cruise = int(mot.attributes["cruise"].value) self.turret = mot.attributes["turret"].value # Get Cost. cost = float(get_child_data(cveh, 'cost')) # Get production era self.prod_era = int(get_child_data(cveh, 'productionera')) # Get techbase (IS, Clan) # get first instance only to avoid problems with Omni-vehicles self.techbase = get_child_data(cveh, 'techbase') # Get year self.year = int(get_child_data(cveh, 'year')) # Sanity check for year year_era_test(self.year, self.prod_era, self.name + " " + self.model) if (self.year < 2470): print self.name, self.model print "Combat Vehicles not available before 2470!" sys.exit(1) if (self.year < 2854 and self.omni == "TRUE"): print self.name, self.model print "OmniVehicles not available before 2854!" sys.exit(1) ### Components starts here ### self.structure = VehicleStructure(get_child(cveh, 'structure'), self.weight, self.mot_type, self.turret) self.engine = Engine(get_child(cveh, 'engine'), self) self.lift = LiftEquipment(self.weight, self.mot_type) if self.engine.etype == "No Engine": self.control = ControlSystems(0.0) else: self.control = ControlSystems(self.weight) self.armor = VehicleArmor(get_child(cveh, 'armor'), self.weight) ### Loadout stuff starts here ### # Get baseloadout blo = cveh.getElementsByTagName('baseloadout')[0] # Construct current loadout, empty name for base loadout self.load = Baseloadout(blo, self, self.batt_val, self.prod_era, cost) # Get omni loadouts self.loads = [] for load in cveh.getElementsByTagName('loadout'): # Construct current loadout current = Loadout(load, self.load, self) self.loads.append(current)
def __init__(self, xmldoc): Unit.__init__(self) # This is a mech self.type = "BM" # Set some data to zero that sometimes will not get set otherwise self.multi = Multi() # Get top-level structure data for mmech in xmldoc.getElementsByTagName('mech'): self.model = mmech.attributes["model"].value self.name = mmech.attributes["name"].value self.omni = mmech.attributes["omnimech"].value self.weight = int(mmech.attributes["tons"].value) # Get BV. Should give prime variant BV for Omni-mechs # get first instance only to avoid problems with Omni-mechs self.batt_val = int(get_child_data(mmech, 'battle_value')) # Get Cost. cost = float(get_child_data(mmech, 'cost')) # Get production era self.prod_era = int(get_child_data(mmech, 'productionera')) # Get mech type (battle, industrial) self.mechtype = get_child_data(mmech, 'mech_type') # Only support battlemechs if (self.mechtype != "BattleMech" and self.mechtype != "PrimitiveBattleMech"): print self.name, self.model print "Industrial Mechs not supported!" sys.exit(1) # Get techbase (IS, Clan) # get first instance only to avoid problems with Omni-mechs self.techbase = get_child_data(mmech, 'techbase') # Get year self.year = int(get_child_data(mmech, 'year')) # Sanity check for year year_era_test(self.year, self.prod_era, self.name + " " + self.model) if (self.year < 2439): print self.name, self.model print "Battlemech older than Mackie!" sys.exit(1) if (self.year < 2470 and self.mechtype == "BattleMech"): print self.name, self.model print "Non-primitive BattleMechs not available before 2470!" sys.exit(1) if (self.year < 2854 and self.omni == "TRUE"): print self.name, self.model print "OmniMechs not available before 2854!" sys.exit(1) # Get motive type (biped, quad) self.motive = get_child_data(mmech, 'motive_type') ### Components starts here ### # Get internal structure type self.structure = MechStructure(get_child(mmech, 'structure'), self.weight, self.motive) # Get engine data self.engine = Engine(get_child(mmech, 'engine'), self) # Get gyro self.gyro = Gyro(get_child(mmech, 'gyro'), self.engine.etype, self.engine.erating) # Get cockpit self.cockpit = Cockpit(get_child(mmech, 'cockpit'), self) # Get enhancement, needs for loop self.enhancement = Enhancement(None, self.weight, self.engine.erating) for enh in mmech.getElementsByTagName('enhancement'): self.enhancement = Enhancement(enh, self.weight, self.engine.erating) # Get armor. self.armor = MechArmor(get_child(mmech, 'armor'), self.weight, self.motive) ### Loadout stuff starts here ### # Get baseloadout blo = mmech.getElementsByTagName('baseloadout')[0] # Get multi-slot stuff for mlts in blo.getElementsByTagName('multislot'): slot = mlts.attributes["name"].value self.multi.add(slot) # Construct current loadout, empty name for base loadout self.load = Baseloadout(blo, self, self.batt_val, self.prod_era, cost) # HACK -- Apply modular armor if self.load.gear.has_mod_armor: self.armor.apply_modular(self.load.gear.mod_armor) # Get omni loadouts self.loads = [] for load in mmech.getElementsByTagName('loadout'): # Construct current loadout current = Loadout(load, self.load, self) self.loads.append(current)