Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print("MechEngine Beta, 0.30.67");
- print("Build Date: 2018-05-21. Designed using Python 3.6.4 Stackless Shell");
- import math, os, sys, time, datetime, threading
- now = datetime.datetime.now()
- while now != datetime.datetime.now():
- now = datetime.datetime.now()
- print("Current Date:", now.strftime("%A, %Y-%m-%d, %H:%M:%S (local)"))
- print();
- #Development Goals:
- #Add options to restart program and/or export log upon completion.
- #Add engine descriptions to help the user make an informed decision.
- #Add example mechs to choose from
- def fib(n): # write Fibonacci series up to n
- """Print a Fibonacci series up to n."""
- a, b = 0, 1
- while a != n:
- print(a, end=" ");
- a, b = b, a+b
- print();
- def RoundUp5(x):
- return math.ceil(x / 5.0) * 5 #Round up to nearest multiple of 5
- def RoundUpHalf(x):
- return math.ceil(x*2.0)/2.0
- def RoundUpQuarter(x):
- return math.ceil(x*4.0)/4.0
- def RoundUpFractional(x):
- return math.ceil(x*1000.0)/1000.0
- def RoundDown5(x):
- return math.floor(x / 5.0) * 5
- def RoundDownHalf(x):
- return math.floor(x*2.0)/2.0
- def RoundDownQuarter(x):
- return math.floor(x*4.0)/4.0
- def RoundDownFractional(x):
- return math.floor(x*1000.0)/1000.0
- def roundNearest(f):
- return round(f + .00000000000001);
- #Deprecated
- def roundHalfUp(f): #deprecated!
- return RoundUpHalf(f) #round(f + 0.00000000000001)
- def roundEngine(x, base=5): #deprecated!
- return int(base * RoundUpHalf(float(x)/base));
- def roundTonnage(x, base=5): #deprecated!
- return int(base * RoundUpHalf(float(x)/base));
- #End Deprecation
- #HYN-DRN-5813 Core Input Dictionary:
- def clamp(min_value, max_value, x):
- """Returns x, limited to the range min_val to max_val."""
- return max(min(x, max_value), min_value)
- def RepresentsInt(s):
- try:
- int(s)
- return True
- except ValueError:
- return False
- def ask(question, min_val, max_val):
- x = ''
- while not RepresentsInt(x) or int(x) < min_val or int(x) > max_val:
- x = input(question + " (min %d, max %d)"%(min_val, max_val) + ": ")
- return clamp(min_val, max_val, int(x))
- MechType = ("Biped")
- #def PromptMechType()
- #NewMechType = PromptMechType()
- #MechType = NewMechType
- CurrentMechType = MechType
- Inputs = {"BattleMech’s Tonnage": {"min":2, "max":200, "value": None},
- "desired Walk MP" : {"min":1, "max":30 , "value": None},
- # "desired number of additional Heat Sinks": {"min:":0, "max":100, "value": None},
- }
- def load_inputs(inputs_dict):
- """Iterate over the given inputs dictionary, asking the user for each
- and setting their values"""
- for name in inputs_dict:
- #name takes each key in the dictionary, which in this case is names of inputs
- inputs_dict[name]["value"] = ask("Please provide your %s"%name,
- inputs_dict[name]["min"],
- inputs_dict[name]["max"])
- #"Load inputs"
- load_inputs(Inputs)
- SuspFact = 0 #SuspFact = (input("Suspension Factor: "))
- MechTonnage = (Inputs["BattleMech’s Tonnage"]["value"])
- if MechTonnage < 10:
- MechClass = ("ProtoMech")
- MechName = ("ProtoMech")
- elif 9 < MechTonnage < 20:
- MechClass = ("Ultralight")
- MechName = ("Ultralight BattleMech")
- elif 19 < MechTonnage < 36:
- MechClass = ("Light")
- MechName = ("Light BattleMech")
- elif 35 < MechTonnage < 56:
- MechClass = ("Medium")
- MechName = ("Medium BattleMech")
- elif 55 < MechTonnage < 76:
- MechClass = ("Heavy")
- MechName = ("Heavy BattleMech")
- elif 75 < MechTonnage < 101:
- MechClass = ("Assault")
- MechName = ("Assault BattleMech")
- elif 100 < MechTonnage:
- MechClass = ("SuperHeavy")
- MechName = ("SuperHeavy BattleMech")
- NewMechName = input("Name your BattleMech: ");
- if NewMechName != '': MechName = NewMechName
- print();
- CruisingSpeed = math.ceil(Inputs["desired Walk MP"]["value"]);
- def kph(s):
- return (math.ceil(s*108))/10
- def metersec(s):
- return (math.ceil(s*30))/10
- def mph(s):
- return (math.ceil(s*671))/100
- #UserHeatSinks = (#(Inputs["desired number of additional Heat Sinks"]["value"]);
- #"Do calculations"
- FlankingSpeed = math.ceil(CruisingSpeed * 1.5)
- if MechTonnage > 9:
- rating = max(10, RoundUp5((Inputs["BattleMech’s Tonnage"]["value"] * Inputs["desired Walk MP"]["value"]) - SuspFact));
- else:
- rating = max(2, (Inputs["BattleMech’s Tonnage"]["value"] * Inputs["desired Walk MP"]["value"]) - SuspFact);
- if rating >500:
- print ("WARNING! This engine rating is outside normal parameters, and the weight has been extrapolated through a polynomial function.",
- "Consent among all participating players must be reached before it can be used in an actual game.");
- #"Master Engine Table:"
- FusionEngineTable = {#See TechManual and Tactical Operations for more details
- 5: 0.5, 10: 0.5, 15: 0.5, 20: 0.5, 25: 0.5, 30: 1.0, 35: 1.0, 40: 1.0, 45: 1.0, 50: 1.5, 55: 1.5, 60: 1.5, 65: 2.0, 70: 2.0, 75: 2.0, 80: 2.5, 85: 2.5, 90: 3.0, 95: 3.0, 100: 3.0,#Standard Gyro: 1 Ton. Compact Gyro: 1.5 Tons. XL Gyro: 0.5 Tons. Heavy-Duty Gyro: 2 Tons.
- 105: 3.5, 110: 3.5, 115: 4.0, 120: 4.0, 125: 4.0, 130: 4.5, 135: 4.5, 140: 5.0, 145: 5.0, 150: 5.5, 155: 5.5, 160: 6.0, 165: 6.0, 170: 6.0, 175: 7.0, 180: 7.0, 185: 7.5, 190: 7.5, 195: 8.0, 200: 8.5,#Standard Gyro: 2 Tons. Compact Gyro: 3 Tons. XL Gyro: 1 Ton. Heavy-Duty/SuperHeavy Gyro: 4 Tons.
- 205: 8.5, 210: 9.0, 215: 9.5, 220: 10.0, 225: 10.0, 230: 10.5, 235: 11.0, 240: 11.5, 245: 12.0, 250: 12.5, 255: 13.0, 260: 13.5, 265: 14.0, 270: 14.5, 275: 15.5, 280: 16.0, 285: 16.5, 290: 17.5, 295: 18.0, 300: 19.0,#Standard Gyro: 3 Tons. Compact Gyro: 4.5 Tons. XL Gyro: 1.5 Tons. Heavy-Duty/SuperHeavy Gyro: 6 Tons.
- 305: 19.5, 310: 20.5, 315: 21.5, 320: 22.5, 325: 23.5, 330: 24.5, 335: 25.5, 340: 27.0, 345: 28.5, 350: 29.5, 355: 31.5, 360: 33.0, 365: 34.5, 370: 36.5, 375: 38.5, 380: 41.0, 385: 43.5, 390: 46.0, 395: 49.0, 400: 52.5,#Standard Gyro: 4 Tons. Compact Gyro: 6 Tons. XL Gyro: 2 Tons. Heavy-Duty/SuperHeavy Gyro: 8 Tons.
- 405: 56.5, 410: 61.0, 415: 66.5, 420: 72.5, 425: 79.5, 430: 87.5, 435: 97.0, 440: 107.5, 445: 119.5, 450: 133.5, 455: 150.0, 460: 168.5, 465: 190.0, 470: 214.5, 475: 243.0, 480: 275.5, 485: 313.0, 490: 356.0, 495: 405.5, 500: 462.5#Standard Gyro: 5 Tons. Compact Gyro: 7.5 Tons. XL Gyro: N/A. Heavy-Duty/SuperHeavy Gyro: 10 Tons.
- }
- ProtoMechEngineTable = {#ProtoMechs, for engine ratings below 40, multiply the engine rating by 0.025 to find the mass. Afterwards, they use Standard Fusion Engine weights.
- 1: .025, 2: .050, 3: .075, 4: .100, 5: .125, 6: .150, 7: .175, 8: .200, 9: .225, 10: .250,
- 11: .275, 12: .300, 13: .325, 14: .350, 15: .375, 16: .400, 17: .425, 18: .450, 19: .475, 20: .500,
- 21: .525, 22: .550, 23: .575, 24: .600, 25: .625, 26: .650, 27: .675, 28: .700, 29: .725, 30: .750,
- 31: .775, 32: .800, 33: .825, 34: .850, 35: .875, 36: .900, 37: .925, 38: .950, 39: .975, 40: 1.0,}
- def PromptEngineType():
- """Ask the user for their desired engine type, then return it."""
- #engine list:
- if 15 < MechTonnage < 101:
- if rating < 401:
- el = [#Basic Engine Types: 10 Heat Sinks each.
- "Standard Fusion Engine", "Light Fusion Engine", "XL Fusion Engine",
- #Advanced Engine Types: 10 Heat Sinks each, but XXL will produce double heat from all types of movement.
- "XXL Fusion Engine", "Compact Fusion Engine",
- #Non-Fusion Engines:
- "Internal Combustion Engine (ICE)", "Fuel Cell", "Fission Engine",
- #Primitive Engines:
- "Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell", "Primitive Fission Engine",
- #Special Engine Types:
- "Lithium-Fusion Engine", #ProtoMech Engine",
- ]
- print("Engine types:");
- for i in range(0, len(el)):
- print(" (%d) %s"%(i, el[i]));
- num = ask("Please select your desired Engine type", 0, len(el)-1);
- print();
- return el[num]
- else:
- el = [#Basic Engine Types: 10 Heat Sinks each.
- "Standard Fusion Engine", "Light Fusion Engine", "XL Fusion Engine",
- #Advanced Engine Types: 10 Heat Sinks each, but XXL will produce double heat from all types of movement.
- "XXL Fusion Engine",# "Compact Fusion Engine",
- #Non-Fusion Engines:
- "Internal Combustion Engine (ICE)", "Fuel Cell", "Fission Engine",
- #Primitive Engines:
- "Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell", "Primitive Fission Engine",
- #Special Engine Types:
- "Lithium-Fusion Engine", #ProtoMech Engine",
- ]
- print("Large Engine types:");
- for i in range(0, len(el)):
- print(" (%d) %s"%(i, el[i]));
- num = ask("Please select your Large Engine type", 0, len(el)-1);
- print();
- return el[num]
- elif MechTonnage < 16:
- if rating < 401:
- el = [#Basic Engine Types: 10 Heat Sinks each.
- "Standard Fusion Engine", "Light Fusion Engine", "XL Fusion Engine",
- #Advanced Engine Types: 10 Heat Sinks each, but XXL will produce double heat from all types of movement.
- "XXL Fusion Engine", "Compact Fusion Engine",
- #Non-Fusion Engines:
- "Internal Combustion Engine (ICE)", "Fuel Cell", "Fission Engine",
- #Primitive Engines:
- "Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell", "Primitive Fission Engine",
- #Special Engine Types:
- "Lithium-Fusion Engine", "ProtoMech Engine",
- ]
- print("Engine types:");
- for i in range(0, len(el)):
- print(" (%d) %s"%(i, el[i]));
- num = ask("Please select your desired Engine type", 0, len(el)-1);
- print();
- return el[num]
- else:
- el = [#Basic Engine Types: 10 Heat Sinks each.
- "Standard Fusion Engine", "Light Fusion Engine", "XL Fusion Engine",
- #Advanced Engine Types: 10 Heat Sinks each, but XXL will produce double heat from all types of movement.
- "XXL Fusion Engine",# "Compact Fusion Engine",
- #Non-Fusion Engines:
- "Internal Combustion Engine (ICE)", "Fuel Cell", "Fission Engine",
- #Primitive Engines:
- "Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell", "Primitive Fission Engine",
- #Special Engine Types:
- "Lithium-Fusion Engine", "ProtoMech Engine",
- ]
- print("Large Engine types:");
- for i in range(0, len(el)):
- print(" (%d) %s"%(i, el[i]));
- num = ask("Please select your desired Large Engine type", 0, len(el)-1);
- print();
- return el[num]
- else:
- if rating < 401:
- el = [#Basic Engine Types: 10 Heat Sinks each.
- "Standard Fusion Engine", "Light Fusion Engine", "XL Fusion Engine",
- #Advanced Engine Types: 10 Heat Sinks each, but XXL will produce double heat from all types of movement.
- "XXL Fusion Engine", "Compact Fusion Engine",
- #Non-Fusion Engines:
- #"Fuel Cell",
- "Fission Engine",
- #Special Engine Types:
- "Lithium-Fusion Engine",
- ]
- print("Engine types:")
- for i in range(0, len(el)):
- print(" (%d) %s"%(i, el[i]));
- num = ask("Please select your desired Engine type", 0, len(el)-1);
- print();
- return el[num]
- else:
- el = [#Basic Engine Types: 10 Heat Sinks each.
- "Standard Fusion Engine", "Light Fusion Engine", "XL Fusion Engine",
- #Advanced Engine Types: 10 Heat Sinks each, but XXL will produce double heat from all types of movement.
- "XXL Fusion Engine",# "Compact Fusion Engine",
- #Non-Fusion Engines:
- #"Fuel Cell",
- "Fission Engine",
- #Special Engine Types:
- "Lithium-Fusion Engine",
- ]
- print("Large Engine types:");
- for i in range(0, len(el)):
- print(" (%d) %s"%(i, el[i]));
- num = ask("Please select your desired Large Engine type", 0, len(el)-1);
- print();
- return el[num]
- if MechTonnage < 10:
- EngineType = ("ProtoMech Engine")
- else:
- EngineType = PromptEngineType()
- if EngineType in {"ProtoMech Engine"}:
- rating = (MechTonnage * FlankingSpeed)
- if MechClass in {"Ultralight"}:
- MechClass = ("UltraHeavy ProtoMech")
- else:
- rating = (MechTonnage * CruisingSpeed) - SuspFact
- if EngineType in {"Lithium-Fusion Engine"}:
- if CruisingSpeed < 2:
- CruisingSpeed = 2
- FlankingSpeed = math.ceil(CruisingSpeed * 1.5)
- elif CruisingSpeed > 1:
- CruisingSpeed = (Inputs["desired Walk MP"]["value"])
- FlankingSpeed = math.ceil(CruisingSpeed * 1.5)
- def FusionWeight(rating):
- if rating <501:
- return FusionEngineTable[RoundUp5(rating)]
- elif EngineType in {"ProtoMech Engine"}:
- if rating <41:
- return rating * (25.0/1000.0) #ProtoMechEngineTable[rating]
- else:
- return FusionEngineTable[RoundUp5(rating)]
- else: #Uses polynomial curves and floating-point math to extrapolate mass for engine ratings beyond 500. Experimental feature, not recommended for everyday use.
- x = RoundUp5(rating)
- coeff = [7.05283012941420e-23, -1.58264921514316e-19, 1.58814453473840e-16,
- -9.19203426420176e-14, 3.32942410135420e-11, -7.72438823285226e-09,
- 1.13925338769604e-06, -0.000102985669746005, 0.00538423547801741,
- -0.112116210954985, 1.24919663674987]
- icoeff = zip(range(0, len(coeff)), reversed(coeff))
- weight = 0.0
- for p,c in icoeff:
- weight += c * (x**p)
- weight = RoundUpFractional(roundNearest(weight * 1000.0)/1000.0)
- return weight
- print ("WARNING! This Engine Rating is outside normal Rating parameters, and its weight has been extrapolated. Do not use it in an actual game.");
- print();
- def FusionWeightPoly(rating): #Uses polynomial curves and floating-point math to extrapolate mass for engine ratings beyond 500. Experimental feature, not recommended for everyday use.
- x = RoundUp5(rating)
- coeff = [7.05283012941420e-23, -1.58264921514316e-19, 1.58814453473840e-16,
- -9.19203426420176e-14, 3.32942410135420e-11, -7.72438823285226e-09,
- 1.13925338769604e-06, -0.000102985669746005, 0.00538423547801741,
- -0.112116210954985, 1.24919663674987]
- icoeff = zip(range(0, len(coeff)), reversed(coeff))
- weight = 0.0
- for p,c in icoeff:
- weight += c * (x**p)
- weight = roundNearest(weight * 2.0)/2.0
- return weight
- #for k in FusionEngineTable:
- # t = FusionWeight(k)
- # p = FusionWeightPoly(k)
- # d = t - p
- # if d > .01:
- # print(k, t, p, d)
- def EngineWeight(engine_type, rating):
- #Using a dictionary to match engine name to a formula
- weight = FusionWeight(rating)
- primitive = FusionWeight(rating * 1.2)
- lithium = FusionWeight(max(MechTonnage, rating - MechTonnage))
- if rating < 40:
- proto = rating * (25.0/1000.0) #ProtoMechEngineTable[rating]
- lithium_proto = max(MechTonnage, rating - MechTonnage) * (25.0/1000.0)
- else:
- proto = weight
- lithium_proto = lithium
- ed = {"Standard Fusion Engine" : max(0.5, weight),
- "Light Fusion Engine" : max(0.5, RoundUpHalf(weight * .75)),
- "XL Fusion Engine" : max(0.5, RoundUpHalf(weight * .50)),
- "XXL Fusion Engine" : max(0.5, RoundUpHalf(weight / 3.0)),
- "Compact Fusion Engine" : max(1.0, RoundUpHalf(weight * 1.5)),
- "Internal Combustion Engine (ICE)" : max(1.0, RoundUpHalf(weight * 2.0)), #No Heat Sinks at all. Can't use energy weapons or Jump Jets. Don't forget fuel!
- "Fuel Cell" : max(1.0, RoundUpHalf((weight * 2.0) * 0.5)), #Only 1 Heat Sink. Can't use energy weapons or Jump Jets. Don't forget fuel!
- "Fission Engine" : max(5.0, RoundUpHalf(weight * float(7.0/4.0))), #Only 5 Heat Sinks. Illegal in the Inner Sphere, and expensive.
- "Lithium-Fusion Engine" : max(0.5, RoundUpHalf(lithium)), #Non-Canon. 10 Heat Sinks. Increases a mech's Walking Speed by 1.
- "Primitive Fusion Engine" : max(0.5, RoundUpHalf(primitive)), #Multiplies engine rating by 1.2, but does not increase performance.
- "Primitive Internal Combustion Engine (ICE)" : max(1.0, RoundUpHalf(primitive * 2.0)), #Multiplies engine rating by 1.2, but does not increase performance.
- "Primitive Fuel Cell" : max(1.0, RoundUpHalf(primitive * 1.2)), #Multiplies engine rating by 1.2, but does not increase performance.
- "Primitive Fission Engine" : max(5.0, RoundUpHalf(primitive * (7.0/4.0))), #Multiplies engine rating by 1.2, but does not increase performance.
- "ProtoMech Engine" : RoundUpFractional((proto * 1000.0)/1000.0),
- "ProtoMech XL Lithium-Fusion Engine" : RoundUpFractional(max(0.017, lithium_proto/3)),
- "No Engine" : 0.00,
- }
- return ed[engine_type]
- if EngineType in {"Lithium-Fusion Engine"}:
- LithiumBatteryRating = max(MechTonnage, rating - MechTonnage)
- elif EngineType in {"Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell," "Primitive Fission Engine"}:
- LithiumBatteryRating = RoundUp5(rating * 1.2)
- else:
- LithiumBatteryRating = rating
- #Cockpits
- def PromptCockpitType():
- """Ask the user for their desired cockpit type, then return it."""
- #cockpit list:
- if LithiumBatteryRating < 401:
- cl = ["Standard", "Small", "Armored", "Torso", "Interface", "Drone Operating System"]
- elif LithiumBatteryRating > 400:
- cl = ["Standard", "Small", "Armored", "Interface", "Drone Operating System"]
- print("Cockpit types:");
- for i in range(0, len(cl)):
- print(" (%d) %s"%(i, cl[i]));
- num = ask("Please select your desired Cockpit type", 0, len(cl)-1);
- print();
- return cl[num]
- def CockpitWeight(cockpit_type):
- #Using a dictionary to match cockpit name to a formula
- cd = {
- "ProtoMech": 0.5,
- "UltraHeavy ProtoMech": 0.75,
- "Drone Operating System": max(1.0, RoundUpHalf((MechTonnage/10.0) + 0.5)),
- "Small": 2.0,
- ("Standard", "AutoMech", "Industrial", "Armored Small"): 3.0,
- #"AutoMech": 3.0,
- ("Armored", "Torso", "Tripod", "Interface", "SuperHeavy"): 4.0,
- #"Torso": 4.0,
- #"Tripod": 4.0,
- #"Interface": 4.0,
- #"SuperHeavy": 4.0,
- ("Primitive", "Primitive Industrial", "SuperHeavy Tripod"): 5.0
- }
- # return ed[cockpit_type]
- for key in cd:
- if cockpit_type in key:
- return cd[key]
- #Skeletons
- def PromptInternalType():
- """Ask the user for their desired internal structure type, then return it."""
- #internal structure list:
- if MechTonnage < 101:
- il = ["Standard", "Endo Steel", "Composite", "Hybrid", "Reinforced", "Industrial"]
- elif MechTonnage > 100:
- il = ["SuperHeavy Standard", "SuperHeavy Hybrid", "SuperHeavy Endo Steel", "SuperHeavy Reinforced", "SuperHeavy Industrial"] #You have balls if you pick that last one.
- elif EngineType in {"Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell", "Primitive Fission Engine"}:
- il = ["Primitive Standard", "Primitive Industrial"]
- print("Internal Structure types:");
- for i in range(0, len(il)):
- print(" (%d) %s"%(i, il[i]))
- num = ask("Please select your desired Internal Structure type", 0, len(il)-1);
- print();
- return il[num]
- def InternalWeight(internal_type):
- #Using a dictionary to match internal structure name to a formula
- isd = {
- ("Standard", "Primitive Standard", "SuperHeavy Endo Steel", "ProtoMech"): RoundUpHalf(MechTonnage/10.0),
- ("Endo Steel", "Composite"): RoundUpHalf(MechTonnage/20.0),
- #"Composite": RoundUpHalf(MechTonnage/20.0),
- "Hybrid": RoundUpHalf(MechTonnage*7.5/100.0),
- #"Reinforced": RoundUpHalf(MechTonnage/5.0),
- #"Industrial": RoundUpHalf(MechTonnage/5.0),
- #"Primitive Standard": RoundUpHalf(MechTonnage/10.0),
- ("Reinforced", "Industrial", "Primitive Industrial", "SuperHeavy Standard") : RoundUpHalf(MechTonnage/5.0),
- #"SuperHeavy Standard": RoundUpHalf(MechTonnage/5.0),
- "SuperHeavy Hybrid": RoundUpHalf(MechTonnage*15.0/100.0),
- #"SuperHeavy Endo Steel": RoundUpHalf(MechTonnage/10.0),
- ("SuperHeavy Industrial", "SuperHeavy Reinforced"): RoundUpHalf(MechTonnage/2.5),
- #"SuperHeavy Reinforced": RoundUpHalf(MechTonnage/2.5),
- #"ProtoMech": RoundUpFractional(MechTonnage/10.0)}
- }
- # return ed[internal_type] #Trying to select keys from individual items out of a tuple, but the program is instead reading the entire tuple as a key.
- for key in isd:
- if internal_type in key:
- return isd[key]
- if MechTonnage > 100:
- InternalType = PromptInternalType()
- CockpitType = ("SuperHeavy")
- if MechType in ["Tripod"]:
- MechType = ("SuperHeavy Tripod")
- else:
- Mechtype = ("SuperHeavy" + CurrentMechType)
- elif EngineType in ["ProtoMech Engine"]:
- InternalType = ("ProtoMech")
- MechType = ("ProtoMech")
- if MechTonnage < 10:
- CockpitType = ("ProtoMech")
- elif MechTonnage > 9:
- CockpitType = ("UltraHeavy ProtoMech")
- else:
- InternalType = PromptInternalType()
- CockpitType = PromptCockpitType()
- MechType = CurrentMechType
- #Gyros
- def PromptGyroType():
- """Ask the user for their desired gyro type, then return it."""
- #gyro list:
- if LithiumBatteryRating < 401 or EngineType in ["Compact Fusion Engine"]:
- gl = ["Standard", "XL (Extra-Light)", "Compact", "Heavy-Duty",]
- elif EngineType in {"Lithium-Fusion Engine"} and rating < 501:
- gl = ["Standard", "XL (Extra-Light)", "Compact", "Heavy-Duty",]
- elif LithiumBatteryRating > 400 or CockpitType in ["Torso"]:
- if EngineType not in ["Compact Fusion Engine"]:
- gl = ["Standard", "Compact", "Heavy-Duty",]
- print("Gyro types:")
- for i in range(0, len(gl)):
- print(" (%d) %s"%(i, gl[i]))
- num = ask("Please select your desired Gyro type", 0, len(gl)-1)
- print();
- return gl[num]
- FinalRating = LithiumBatteryRating
- GyroRating = math.ceil(LithiumBatteryRating / 100)
- if MechTonnage > 100:
- GyroType = ("SuperHeavy")
- elif EngineType in ["Primitive Fusion Engine", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell", "Primitive Fission Engine"]:
- if MechTonnage < 101:
- GyroType = ("Primitive")
- elif MechTonnage > 100:
- GyroType = ("SuperHeavy Primitive")
- elif CockpitType in ["ProtoMech", "UltraHeavy ProtoMech", "Interface"]:
- GyroType = ("None")
- else:
- GyroType = PromptGyroType()
- def GyroWeight(gyro_type):
- #Using a dictionary to match gyro name to a formula
- gmass = GyroRating
- gd = {
- ("Standard", "Primitive Standard") : max(1.0, gmass*1.0),
- "XL (Extra-Light)" : max(1.0, RoundUpHalf(gmass/2.0)),
- "Compact" : max(1.5, RoundUpHalf(gmass*1.5)),
- ("Heavy-Duty", "SuperHeavy", "Primitive SuperHeavy") : max(2.0, math.ceil(gmass * 2.0)),
- #"SuperHeavy" : max(2.0, math.ceil(gmass*2.0)),
- #"Primitive" : max(1.0, gmass*1.0),
- #"Primitive SuperHeavy" : max(2.0, math.ceil(gmass*2.0)), #unused
- "None": (gmass*0.0),
- "Armored" : (gmass + 2.0),
- "Armored Compact" : 1.0 + RoundUpHalf(gmass*1.5),
- "Armored XL" : 3.0 + RoundUpHalf(gmass/2.0),
- "Armored Heavy-Duty" : 2.0 + (gmass*2.0),
- }
- # return ed[gyro_type]
- for key in gd:
- if gyro_type in key:
- return gd[key]
- #Heat Sinks
- def PromptHeatSinkType():
- """Ask the user for their desired heat sink type, then return it."""
- #heat sink list:
- hsl = ["Single", "Double (Inner Sphere)", "Double (Clan)", "Laser", "Compact"]
- print("Heat Sink types:");
- for i in range(0, len(hsl)):
- print(" (%d) %s"%(i, hsl[i]));
- num = ask("Please select your desired Heat Sink type", 0, len(hsl)-1);
- print();
- return hsl[num]
- if EngineType in {"Fission Engine", "Primitive Fission Engine"}:
- FreeHeatSinks = 5
- HeatSinkType = PromptHeatSinkType()
- elif EngineType in {"Fuel Cell", "Primitive Fuel Cell"}:
- FreeHeatSinks = 1
- HeatSinkType = PromptHeatSinkType()
- elif EngineType in {"Internal Combustion Engine (ICE)", "Primitive Internal Combustion Engine (ICE)"}:
- FreeHeatSinks = 0
- HeatSinkType = PromptHeatSinkType()
- elif EngineType in {"ProtoMech Engine"}:
- FreeHeatSinks = 0
- HeatSinkType = ("ProtoMech")
- else:
- FreeHeatSinks = 10
- HeatSinkType = PromptHeatSinkType()
- if EngineType in ["ProtoMech Engine"]:
- UserHeatSinks = ask("Please provide your desired quantity of ProtoMech Heat Sinks", 0, MechTonnage*4)
- else:
- print ("You currently have", int(FreeHeatSinks), HeatSinkType, "Heat Sinks.")
- UserHeatSinks = ask("If you wish to install additional Heat Sinks, enter the quantity you wish to add", 0, MechTonnage)
- TotalHeatSinks = UserHeatSinks + FreeHeatSinks
- if TotalHeatSinks > 0:
- print()
- if EngineType in {"ProtoMech Engine"}:
- HeatSinkWeight = RoundUpFractional(UserHeatSinks/4.0)
- IntegralHeatSinks = int(TotalHeatSinks)
- HeatSinkSlots = 0
- elif HeatSinkType in {"Compact"}:
- HeatSinkWeight = RoundUpHalf(UserHeatSinks * 1.5)
- IntegralHeatSinks = int(min(TotalHeatSinks, math.floor(LithiumBatteryRating/12.5)))
- else:
- HeatSinkWeight = UserHeatSinks * 1.0
- IntegralHeatSinks = int(min(TotalHeatSinks, math.floor(LithiumBatteryRating/25.0)))
- PodHeatSinks = TotalHeatSinks - IntegralHeatSinks
- if MechTonnage < 101:
- if HeatSinkType in ["Single", "Liquid Metal"]:
- HeatSinkSlots = PodHeatSinks
- elif HeatSinkType in ["Double (Inner Sphere)", "Double (ProtoType)"]:
- HeatSinkSlots = PodHeatSinks * 3
- elif HeatSinkType in ["Double (Clan)", "Double (Star Empire)", "Laser"]:
- HeatSinkSlots = PodHeatSinks * 2
- elif HeatSinkType in ["Compact"]:
- HeatSinkSlots = math.ceil(PodHeatSinks/2)
- elif HeatSinkType in ["ProtoMech"]:
- HeatSinkSlots = 0
- elif MechTonnage > 100:
- if HeatSinkType in ["Single"]:
- HeatSinkSlots = math.ceil(PodHeatSinks/2)
- elif HeatSinkType in ["Double (Inner Sphere)"]:
- HeatSinkSlots = math.ceil(PodHeatSinks * 1.5)
- elif HeatSinkType in ["Double (Clan)", "Laser"]:
- HeatSinkSlots = PodHeatSinks
- elif HeatSinkType in ["Compact"]:
- HeatSinkSlots = math.ceil(PodHeatSinks/4)
- #Podspace
- skeleton = InternalWeight(InternalType)
- tripod = RoundUpHalf(skeleton * 1.1)
- cockpit = CockpitWeight(CockpitType)
- gyro = GyroWeight(GyroType)
- EngineTonnage = EngineWeight(EngineType, rating)
- if MechType in ["Combat Vehicle", "Support Vehicle"]:
- if EngineType in ["Internal Combustion Engine (ICE)", "Fuel Cell", "Primitive Internal Combustion Engine (ICE)", "Primitive Fuel Cell"]:
- VehicleEngine = EngineTonnage
- else:
- if MechType in ["Combat Vehicle"]:
- VehicleEngine = RoundUpHalf(EngineTonnage * 1.5)
- elif MechType in ["Support Vehicle"]:
- VehicleEngine = RoundUpFractional(EngineTonnage * 1.5)
- else:
- VehicleEngine = EngineTonnage
- print()
- if MechType in ["Tripod", "SuperHeavy Tripod"]:
- podspace = RoundDownHalf(MechTonnage - EngineTonnage - tripod - gyro - cockpit - HeatSinkWeight)
- elif EngineType in ["ProtoMech Engine", "ProtoMech XL Lithium-Fusion Engine"] or MechType in ["ProtoMech", "Quad ProtoMech", "Glider ProtoMech"]:
- podspace = RoundDownFractional(MechTonnage - EngineTonnage - skeleton - gyro - cockpit - HeatSinkWeight)
- elif MechType in ["Combat Vehicle"]:
- podspace = RoundDownHalf(MechTonnage - VehicleEngine - skeleton - gyro - cockpit - HeatSinkWeight)
- elif MechType in ["Support Vehicle"]:
- podspace = RoundDownFractional(MechTonnage - VehicleEngine - skeleton - gyro - cockpit - HeatSinkWeight)
- else:
- podspace = RoundDownHalf(MechTonnage - EngineTonnage - skeleton - gyro - cockpit - HeatSinkWeight)
- if VehicleEngine > MechTonnage:
- print ("WARNING! Your engine is heavier than the mech!");
- if podspace <0.0:
- print ("WARNING! Your mech has negative podspace, and is Overweight!");
- #Finalize
- if MechName in {"BattleMech", "ProtoMech", "Ultralight BattleMech", "Light BattleMech", "Medium BattleMech", "Heavy BattleMech", "Assault BattleMech", "SuperHeavy BattleMech"}:
- if InternalType in {"Industrial"}:
- if MechClass in {"Ultralight", "Light", "Medium", "Heavy", "Assault", "SuperHeavy"}:
- MechName = (MechClass + "IndustrialMech")
- if InternalType in {"Primitive Standard"}:
- if MechClass in {"Ultralight", "Light", "Medium", "Heavy", "Assault", "SuperHeavy"}:
- MechName = ("Primitive" + MechClass + "BattleMech")
- if InternalType in {"Primitive Industrial"}:
- if MechClass in {"Ultralight", "Light", "Medium", "Heavy", "Assault", "SuperHeavy"}:
- MechName = ("Primitive" + MechClass + "Industrial")
- elif MechClass in {"ProtoMech", "UltraHeavy ProtoMech"}:
- MechName = MechClass
- elif CockpitType in {"AutoMech"}:
- MechName = (MechClass + "AutoMech")
- #Technical Readout
- print ("Your", MechName, "has a Cruising MP of", CruisingSpeed, "hexes per turn, and a Flanking MP of", FlankingSpeed, "hexes per turn.");
- print ("This speed is provided by a", FinalRating, "rated", EngineType, "weighing", EngineTonnage, "metric tons.");
- if EngineType in ["ProtoMech Engine", "ProtoMech XL Lithium-Fusion Engine"]:
- print("You have", TotalHeatSinks, HeatSinkType, "Heat Sinks weighing", HeatSinkWeight, "metric tons.")
- else:
- print("You have", TotalHeatSinks, HeatSinkType, "Heat Sinks weighing", HeatSinkWeight, "metric tons, of which", IntegralHeatSinks, "of them are Integral,")
- print ("and out of those", TotalHeatSinks, HeatSinkType, "Heat Sinks," + FreeHeatSinks, "of them come with the engine.")
- if PodHeatSinks > 0:
- print ("The remaining", HeatSinkType, "Heat Sinks occupy", HeatSinkSlots, "Critical Spaces in total.")
- print()
- if MechType in ["Tripod"]:
- print ("The Mech's weight is supported by a", InternalType, "Internal Structure with a mass of", tripod, "metric tons.");
- elif MechType in ["AutoMech"]:
- print ("The AutoMech’s weight is supported by a", InternalType, "Internal Structure with a mass of", skeleton, "metric tons.");
- elif MechType in ["ProtoMech"]:
- print ("The ProtoMech’s weight is supported by a", InternalType, "Internal Structure with a mass of", skeleton, "metric tons.");
- else:
- print ("The Mech’s weight is supported by a", InternalType, "Internal Structure with a mass of", skeleton, "metric tons.");
- if GyroType in ["None"] and MechTonnage > 9:
- print("The pilot is cocooned in an", CockpitType, "Cockpit, which weighs", cockpit, "metric tons.");
- elif GyroType in ["None"] and MechTonnage <10:
- print("The pilot is cocooned in a", CockpitType, "Cockpit, which weighs", cockpit, "metric tons.");
- elif GyroType in ["SuperHeavy"]:
- print ("and stopping your", MechName, "from toppling over is a monstrous", GyroType, "Gyro weighing", gyro, "metric tons.");
- print ("The pilots are huddled together in a", CockpitType, "Cockpit, weighing a massive", cockpit, "metric tons.");
- elif GyroType in ["XL (Extra-Light)"]:
- print ("and keeping the", MechName, "upright is an", GyroType, "Gyro weighing", gyro, "metric tons.");
- print ("The pilot sits ’comfortably’ in a", CockpitType, "Cockpit, which weighs", cockpit, "metric tons.");
- elif CockpitType in ["Drone Operating System", "AutoMech"]:
- if GyroType in ["XL (Extra-Light)"]:
- print ("and keeping the", MechName, "upright is an", GyroType, "Gyro weighing", gyro, "metric tons.")
- else:
- print ("and keeping the", MechName, "upright is a", GyroType, "Gyro weighing", gyro, "metric tons.")
- if CockpitType in ["Drone Operating System"]:
- print ("The brains of this machine consist of a", CockpitType, "weighing", cockpit, "metric tons.")
- elif CockpitType in ["AutoMech"]:
- print ("The brains of this machine consist of an", CockpitType, "weighing", cockpit, "metric tons.")
- else:
- print ("and keeping the", MechName, "upright is an", GyroType, "Gyro weighing", gyro, "metric tons.");
- print ("The pilot sits 'comfortably' in a", CockpitType, "Cockpit, which weighs", cockpit, "metric tons.");
- print()
- print ("The", MechName, "has an average walking speed of", kph(CruisingSpeed), "km/h, and a maximum running speed of", kph(FlankingSpeed), "km/h.");
- if podspace > 0.0:
- print ("The", MechName, "has", podspace, "tons of Pod Space available to mount weapons, armor and equipment.");
- print();
- else:
- print ("Oh, stravag! It would seem that the", MechName, "has", podspace, "tons of Pod Space left, and now it cannot mount any weapons, armor or equipment!");
- print();
- ## Closing sequence.
- print ("Please visit http://www.sarna.net for more information on these terms and components.");
- print ("If you have any questions or feedback about the software, such as feature requests or bug reports,");
- print ("if you need technical support, or would simply like to contribute to development, then please visit:");
- print ("https://tinyurl.com/Sarna-Forums-MechEngine");
- print();
- now = datetime.datetime.now()
- print("The current time and date is", now.strftime("%A, %Y-%m-%d, %H:%M:%S (local)"))
- input("Press ENTER to exit the program.") #Change this line to a menu option once Restart has been implemented.
- print ("Ejecting.")
- ## End of Line.
- #Contribution Links:
- # https://pastebin.com/dpMnWPjp
- # https://docs.google.com/document/d/1A6Y79pelpzdRg00DHcZNO3tyrdvthFSaU4tihSvGkE8/edit?usp=sharing
Add Comment
Please, Sign In to add comment