def editLocIngreAdd(loc, ingres, dropRates): while True: cont = False print("\nInput ingredient to add") print("Type \'list\' to list current ingredients | " "Type \'listAll\' to list all ingredients") print("Type null to go back") ingre = input().upper() if ingre == "": return if ingre == "LIST": lis = "" for i in ingres: lis = lis + "[" + str(i) + "]\n" print("\n" + lis) continue if ingre == "LISTALL" or ingre == "LIST ALL" or ingre == "LA": DevHelpers.printIngredients(config.Ingredients) continue ingre = DevHelpers.IDFormat(ingre) for i in ingres: if ingre == i: print("Ingredient already exists\n") cont = True break if cont: continue ingres.append(ingre) while True: dropRate = input(str(ingre) + "\'s drop rate (0-1): ") if dropRate == "": dropRate = 0.5 try: dropRate = float(dropRate) except ValueError: print("That is not a float") if type(dropRate) == float: if dropRate < 0: dropRate = 0.5 break # Select Drop Amounts for Ingredients while True: dropAmount = input(str(ingre) + "\'s drop amount: ") if dropAmount == "": dropAmount = 1 try: dropAmount = int(dropAmount) except ValueError: print("That is not a int") if type(dropAmount) == int: if dropAmount < 0: dropAmount = 1 break dropRates.append([dropRate, dropAmount]) print("Added " + str(ingre) + " to [" + str(loc.getID()) + "]\n")
def editIngredient(): Ingredients = helpers.InitIngredients() Ingredients.sort(key=lambda k: k.getName()) Running = True ingre = None while Running: print("=====Edit Ingredient=====") while (Running): print("Type \'list\' to see all ingredients") print("Type q to quit") print("Select Ingredient 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.printIngredients(Ingredients) else: setToBreak = False ingreID = DevHelpers.IDFormat(option) for i in Ingredients: if i.getID() == ingreID: ingre = i setToBreak = True break if setToBreak: break if not Running: break #get vars ready name = ingre.getName() img = ingre.getImgLoc() categoryList = ingre.getCategory() color = ingre.getColor() value = ingre.getValue() effects = [ingre.getEffect1(), ingre.getEffect2(), ingre.getEffect3()] editingIngredient = True while (editingIngredient): print("\nSelect Attribute to Edit for [" + str(ingre.getID()) + "]") print("Type s to save and continue, q save and quit") print("Name | ImageLocation | Category | Color | Value | Effect") attrib = input().upper() if attrib == "" or attrib == "Q" or attrib == "EXIT" or attrib == "QUIT" or attrib == "STOP" or attrib == "END": newIngre = helpers.Ingredient(ingre.getID(), name, img, categoryList, color, value, ingre.getAmount(), effects[0], effects[1], effects[2]) Ingredients.append(newIngre) helpers.saveIngredients(Ingredients) Ingredients = helpers.InitIngredients() print("Successfully saved") editingIngredient = False break if attrib == "NAME" or attrib == "N": name = editIngreName(ingre, name) if attrib == "IMAGELOCATION" or attrib == "IMAGE" or attrib == "I" or attrib == "IMG": img = editIngreImgLoc(ingre, img) if attrib == "CATEGORY" or attrib == "CAT" or attrib == "CA": categoryList = editIngreCategory(ingre, categoryList) if attrib == "COLOR" or attrib == "CO": color = editIngreColor(ingre, color) if attrib == "VALUE" or attrib == "VAL" or attrib == "V": value = editIngreValue(ingre, value) if attrib == "EFFECT" or attrib == "E": effects = editIngreEffect(ingre, effects) if attrib == "SAVE" or attrib == "S": newIngre = helpers.Ingredient(ingre.getID(), name, img, categoryList, color, value, ingre.getAmount(), effects[0], effects[1], effects[2]) Ingredients.append(newIngre) helpers.saveIngredients(Ingredients) Ingredients = helpers.InitIngredients() 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)
def createLocation(): Locations = helpers.InitLocations() Ingredients = helpers.InitIngredients() Ingredients.sort(key=lambda k: k.getName()) Running = True print("=====Create Location=====") while Running: print("Type q to quit") # Select ID ID = input("Input ID: ") ID = DevHelpers.IDFormat(ID) option = ID.upper() if option == "Q" or option == "EXIT" or option == "QUIT" or option == "STOP" or option == "END": Running = False break setContinue = False for I in Locations: if I.getID() == ID: print("ID already taken") setContinue = True break if setContinue: continue # Select Name name = input("Input Name:") name = DevHelpers.NameFormat(name) # Select ImgDir img = input("Input Image directory: ") if not os.path.exists(img): print("Path does not exist, setting default") img = "sprites/UnknownWhite.png" # Select Color color = input("Input Color: ") if DevHelpers.checkColor(color) == None: print("Color not recognized, setting to random") color = helpers.randCol() else: color = DevHelpers.checkColor(color) # Select Ingredients while True: ingredients = input( "Input Ingredients, separated by a comma - [ing1, ing2]\nType \"list\" for a list of ingredients: " ) if ingredients.upper() == "LIST": DevHelpers.printIngredients(Ingredients) else: break # Select Drop Rates for Ingredients dropRates = [] ingreList = ingredients.split(",") for i in range(len(ingreList)): ingreList[i] = DevHelpers.IDFormat(ingreList[i]) if ingreList[i] == "_": continue while True: dropRate = input(str(ingreList[i]) + "\'s drop rate (0-1): ") if dropRate == "": dropRate = 0.5 try: dropRate = float(dropRate) except ValueError: print("That is not a float") if type(dropRate) == float: if dropRate < 0: dropRate = 0.5 break # Select Drop Amounts for Ingredients while True: dropAmount = input(str(ingreList[i]) + "\'s drop amount: ") if dropAmount == "": dropAmount = 1 try: dropAmount = int(dropAmount) except ValueError: print("That is not a int") if type(dropAmount) == int: if dropAmount < 0: dropAmount = 1 break dropRates.append([dropRate, dropAmount]) # Select Prereqs prereqs = [] for i in range(3): Type = input("Input prerequisite " + str(i + 1) + " options:\n (Gold) (Potion) (None): ") # If prereq is gold if Type.upper() == "GOLD" or Type.upper() == "G": while (True): Value = input("Value: ") if Value == "": Value = 1 try: Value = int(Value) except ValueError: print("That is not a integer") if type(Value) == int: if Value < 0: Value = 1 break prereqs.append({"Gold": Value}) # If prereq is Potion elif Type.upper() == "POTION" or Type.upper() == "P" or Type.upper( ) == "POT": potName = input("Potion Name: ") potName = DevHelpers.NameFormat(potName) potCol = input("Potion Color: ") potCol = DevHelpers.checkColor(potCol) potEff = input("Potion Effect: ") # potEff = DevHelpers.checkEffect(potEff) prereq = { "Potion": { "Name": potName, "Color": potCol, "Effect": potEff } } else: prereqs.append("None") # Create Location newLoc = helpers.Location(ID, name, img, color, ingreList, dropRates, prereqs[0], prereqs[1], prereqs[2]) Locations.append(newLoc) ans = input("Sucessfully added to list, continue? (y/n): ") if ans.upper() != 'Y': Running = False helpers.saveLocations(Locations)