def editTool(): Tools = helpers.InitTools() Ingredients = helpers.InitIngredients() Ingredients.sort(key=lambda k: k.getName()) Running = True tool = None while Running: print("=====Edit Tools=====") print("Type \'list\' to see all tools") print("Type q to quit") while (Running): print("Select Tool ID to Edit:") entry = input() option = entry.upper() if option == "" or option == "Q" or option == "EXIT" or option == "QUIT" or option == "STOP" or option == "END": Running = False break if option.upper() == "LIST": DevHelpers.printTools(Tools) else: setToBreak = False toolID = DevHelpers.IDFormat(option) for i in Tools: if i.getID() == toolID: tool = i setToBreak = True break if setToBreak: break print("Invalid Tool ID [" + toolID + "]\n") print("Type \'list\' to see all tools") if not Running: break # get vars ready name = tool.getName() img = tool.getImgLoc() use = tool.getUse() inSlots = tool.getInSlots() outSlots = tool.getOutSlots() unlocked = tool.getUnlocked() editingIngredient = True while (editingIngredient): print("\nSelect Attribute to Edit for [" + str(tool.getID()) + "]") print("Type s to save and continue, q save and quit") print("Name | ImageLocation | Use | InSlots | OutSlots | Unlocked") attrib = input().upper() if attrib == "" or attrib == "Q" or attrib == "EXIT" or attrib == "QUIT" or attrib == "STOP" or attrib == "END": newTool = helpers.Tool(tool.getID(), name, img, use, inSlots, outSlots, unlocked) Tools.append(newTool) helpers.saveTools(Tools) Tools = helpers.InitTools() print("Successfully saved") editingIngredient = False break if attrib == "NAME" or attrib == "N": name = editToolName(tool, name) if attrib == "IMAGELOCATION" or attrib == "IMAGE" or attrib == "IM" or attrib == "IMG": img = editToolImgLoc(tool, img) if attrib == "USE": use = editToolUse(tool, use) if attrib == "INSLOTS" or attrib == "IN" or attrib == "I": inSlots = editToolInSlots(tool, inSlots) if attrib == "OUTSLOTS" or attrib == "OUT" or attrib == "O": outSlots = editToolOutSlots(tool, inSlots) if attrib == "UNLOCKED" or attrib == "U": unlocked = editToolUnlocked(tool, unlocked) newTool = helpers.Tool(tool.getID(), name, img, use, inSlots, outSlots, unlocked) Tools.append(newTool) helpers.saveTools(Tools) Tools = helpers.InitTools() print("Successfully saved")
def createRecipe(): Tools = helpers.InitTools() Ingredients = helpers.InitIngredients() Ingredients.sort(key=lambda k: k.getName()) Combinations = helpers.InitCreateRecipes() Extractions = helpers.InitExtractRecipes() Running = True print("=====Create Recipe=====") RecipeType = None while Running: while True: print("Type Q to quit") option = input( "Select Type of Recipe (Combination | Extraction): ").upper() option = option.upper() if option == "Q" or option == "EXIT" or option == "QUIT" or option == "STOP" or option == "END": Running = False break if option == "COMBINATION" or option == "C": RecipeType = "Combination" break if option == "EXTRACTION" or option == "E": RecipeType = "Extraction" break print("Invalid option\n") if RecipeType == None: print("How did you get here?") while True: # Select ID ID = input("Input ID: ") ID = DevHelpers.IDFormat(ID) for T in Tools: if T.getID() == ID: print("ID already taken") continue break # Select Name name = input("Input Name: ") name = DevHelpers.NameFormat(name) #Select Tool selectedTool = None while True: leave = False tool = input("Select Tool, Type \'List\' to list tools:") if tool.upper() == "LIST" or tool.upper() == "L": DevHelpers.printTools(Tools, RecipeType) continue tool = DevHelpers.IDFormat(tool) for i in Tools: if i.getID() == tool: if i.getUse() == RecipeType: leave = True selectedTool = i break else: break if leave == True: break print("Invalid Tool [" + str(tool) + "]\n") #Select Requrement(s) reqs = [] print("\nType \'List\' to list out ingredients") for i in range(selectedTool.getInSlots()): while True: leave = False ingre = input("Input Ingredient requirement #" + str(i + 1) + ": ") if ingre.upper() == "LIST" or ingre.upper() == "L": DevHelpers.printIngredients(Ingredients) continue ingre = DevHelpers.IDFormat(ingre) for ing in Ingredients: if ing.getID() == ingre: reqs.append(ingre) leave = True break if leave: break print("Invalid Ingredient: [" + ingre + "]\n") print("Type \'List\' to list out ingredients") # Select Results(s) results = [] print("\nType \'List\' to list out ingredients") for i in range(selectedTool.getOutSlots()): while True: leave = False ingre = input("Input Ingredient results #" + str(i + 1) + ": ") if ingre.upper() == "LIST" or ingre.upper() == "L": DevHelpers.printIngredients(Ingredients) continue ingre = DevHelpers.IDFormat(ingre) for ing in Ingredients: if ing.getID() == ingre: results.append(ingre) leave = True break if leave: break print("Invalid Ingredient: [" + ingre + "]\n") print("Type \'List\' to list out ingredients") # Select Unlocked status unlocked = input("Select unlocked status (True | False): ").upper() if unlocked == "TRUE" or unlocked == "T": unlocked = True elif unlocked == "FALSE" or unlocked == "F": unlocked = False else: print("Invalid input, setting to True") unlocked = True # Create Recipe if RecipeType == "Extraction": newRecipe = helpers.ExtractRecipe(ID, name, tool, reqs, results, unlocked) Extractions.append(newRecipe) elif RecipeType == "Combination": newRecipe = helpers.CombineRecipe(ID, name, tool, reqs, results, unlocked) Combinations.append(newRecipe) ans = input("Sucessfully added to list, continue? (y/n): ") if ans.upper() != 'Y': Running = False helpers.saveExtractRecipes(Extractions) helpers.saveCreateRecipes(Combinations)