Guest User

Untitled

a guest
Oct 13th, 2022
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 KB | None | 0 0
  1. def input_check(prompt, checkType, choices = [], listReturnType = str, choicesStr = None):
  2. while True:
  3. try:
  4. if checkType is list:
  5. print("Choices: ")
  6. if choicesStr is None:
  7. print(*choices, sep=',')
  8. else:
  9. print(choicesStr)
  10. userInput = input(prompt)
  11.  
  12. if checkType is float:
  13. return float(userInput)
  14. elif checkType is int:
  15. return int(userInput)
  16. elif checkType is list:
  17. if userInput.upper() in choices: return listReturnType(userInput.upper())
  18. except ValueError:
  19. if checkType is float:
  20. print("Please enter numbers only!")
  21. elif checkType is int:
  22. print("Please enter whole numbers only!")
  23. elif checkType is list:
  24. print("Please select a valid choice!")
  25.  
  26. machines={"A": {"name": "Assembling Machine Mk.I", "speed": 0.75},
  27. "A2": {"name": "Assembling Machine Mk.II", "speed": 1},
  28. "A3": {"name": "Assembling Machine Mk.III", "speed": 1.5},
  29. "C": {"name": "Chemical Plant", "speed": 1},
  30. "P": {"name": "Plane Smelter", "speed": 2},
  31. "Q": {"name": "Quantum Chemical Plant", "speed": 2},
  32. "S": {"name": "Arc Smelter", "speed": 1}}
  33. machineChoices=', '.join(f"{info['name']}({letter})" for letter,info in machines.items())
  34.  
  35. proliferators={"B": {"color": "Blue", "boost": 2},
  36. "G": {"color": "Green", "boost": 1.5},
  37. "Y": {"color": "Yellow", "boost": 1.25}}
  38. proliferatorChoices=', '.join(f"{info['color']}({letter})" for letter,info in proliferators.items())
  39.  
  40. while True:
  41. itemsPS=input_check("Belt items/s: ", int)
  42. stackLevel=input_check("Stack research level: ", list, ["0","1","2","3"], int)
  43. stackLevel += 1
  44. craftTime=input_check("Recipe craft time: ", float)
  45. itemsCrafted=input_check("Number of items crafted: ", int)
  46. highestResource=input_check("Highest resource number required for recipe: ", int)
  47. machine=input_check("Machine: ", list, ["A", "A2", "A3", "C", "P", "Q", "S"], str, machineChoices)
  48. proliferatorColor=input_check("Proliferator Color: ", list, ["B","G","Y"], str, proliferatorChoices)
  49.  
  50. machineSpeed = machines[machine]['speed']
  51. proliferatorSpeed = proliferators[proliferatorColor]['boost']
  52. boost = machineSpeed*proliferatorSpeed
  53. machineOutput=(craftTime/boost)
  54. machineMax=(itemsPS*stackLevel)/((1/machineOutput)*highestResource)
  55. actualOutputPS=((1/machineOutput)*machineMax)*itemsCrafted
  56. actualOutputPM=actualOutputPS*60
  57. print("Max {:.0f} {}'s".format(machineMax,machines[machine]['name']))
  58. print("Produces {:.2f}({:.2f}each) item(s) per minute, {:.2f}({:.2f}each) a second.".format(actualOutputPM,
  59. (actualOutputPM/machineMax),
  60. actualOutputPS,
  61. (actualOutputPS/machineMax)))
  62.  
Advertisement
Add Comment
Please, Sign In to add comment