Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def input_check(prompt, checkType, choices = [], listReturnType = str, choicesStr = None):
- while True:
- try:
- if checkType is list:
- print("Choices: ")
- if choicesStr is None:
- print(*choices, sep=',')
- else:
- print(choicesStr)
- userInput = input(prompt)
- if checkType is float:
- return float(userInput)
- elif checkType is int:
- return int(userInput)
- elif checkType is list:
- if userInput.upper() in choices: return listReturnType(userInput.upper())
- except ValueError:
- if checkType is float:
- print("Please enter numbers only!")
- elif checkType is int:
- print("Please enter whole numbers only!")
- elif checkType is list:
- print("Please select a valid choice!")
- machines={"A": {"name": "Assembling Machine Mk.I", "speed": 0.75},
- "A2": {"name": "Assembling Machine Mk.II", "speed": 1},
- "A3": {"name": "Assembling Machine Mk.III", "speed": 1.5},
- "C": {"name": "Chemical Plant", "speed": 1},
- "P": {"name": "Plane Smelter", "speed": 2},
- "Q": {"name": "Quantum Chemical Plant", "speed": 2},
- "S": {"name": "Arc Smelter", "speed": 1}}
- machineChoices=', '.join(f"{info['name']}({letter})" for letter,info in machines.items())
- proliferators={"B": {"color": "Blue", "boost": 2},
- "G": {"color": "Green", "boost": 1.5},
- "Y": {"color": "Yellow", "boost": 1.25}}
- proliferatorChoices=', '.join(f"{info['color']}({letter})" for letter,info in proliferators.items())
- while True:
- itemsPS=input_check("Belt items/s: ", int)
- stackLevel=input_check("Stack research level: ", list, ["0","1","2","3"], int)
- stackLevel += 1
- craftTime=input_check("Recipe craft time: ", float)
- itemsCrafted=input_check("Number of items crafted: ", int)
- highestResource=input_check("Highest resource number required for recipe: ", int)
- machine=input_check("Machine: ", list, ["A", "A2", "A3", "C", "P", "Q", "S"], str, machineChoices)
- proliferatorColor=input_check("Proliferator Color: ", list, ["B","G","Y"], str, proliferatorChoices)
- machineSpeed = machines[machine]['speed']
- proliferatorSpeed = proliferators[proliferatorColor]['boost']
- boost = machineSpeed*proliferatorSpeed
- machineOutput=(craftTime/boost)
- machineMax=(itemsPS*stackLevel)/((1/machineOutput)*highestResource)
- actualOutputPS=((1/machineOutput)*machineMax)*itemsCrafted
- actualOutputPM=actualOutputPS*60
- print("Max {:.0f} {}'s".format(machineMax,machines[machine]['name']))
- print("Produces {:.2f}({:.2f}each) item(s) per minute, {:.2f}({:.2f}each) a second.".format(actualOutputPM,
- (actualOutputPM/machineMax),
- actualOutputPS,
- (actualOutputPS/machineMax)))
Advertisement
Add Comment
Please, Sign In to add comment