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 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 editLocation(): Locations = helpers.InitLocations() config.Ingredients = helpers.InitIngredients() config.Ingredients.sort(key=lambda k: k.getName()) Running = True while Running: print("\n=====Edit Location=====") while (Running): print("Type q to quit") print("Select Location ID to Edit:") DevHelpers.printLocations(Locations) entry = input() option = entry.upper() if option == "Q" or option == "EXIT" or option == "QUIT" or option == "STOP" or option == "END" or option == "": Running = False break setToBreak = False locID = DevHelpers.IDFormat(option) for i in Locations: if i.getID() == locID: loc = i setToBreak = True break if setToBreak: break print("Location not found") if not Running: break #get vars ready name = loc.getName() img = loc.getImgLoc() color = loc.getColor() locIngre = loc.getIngredients() dropRates = loc.getDropRates() prereq = [loc.getPrereq1(), loc.getPrereq2(), loc.getPrereq3()] editingLoc = True while (editingLoc): print("\nSelect Attribute to Edit for [" + str(loc.getID()) + "]") print("Type s to save and continue, q to save and quit") print( "Name | ImageLocation | Color | Ingredients | Drop Rate | Prerequisite" ) attrib = input().upper() if attrib == "" or attrib == "Q" or attrib == "EXIT" or attrib == "QUIT" or attrib == "STOP" or attrib == "END": newLoc = helpers.Location(loc.getID(), name, img, color, locIngre, dropRates, prereq[0], prereq[1], prereq[2]) Locations.append(newLoc) helpers.saveLocations(Locations) Locations = helpers.InitLocations() print("Successfully saved") editingLoc = False break if attrib == "NAME" or attrib == "N": name = editLocName(loc, name) if attrib == "IMAGELOCATION" or attrib == "IMAGE" or attrib == "IMG": img = editLocImgLoc(loc, img) if attrib == "COLOR" or attrib == "C": color = editLocColor(loc, color) if attrib == "INGREDIENTS" or attrib == "INGRE" or attrib == "ING": locIngre = editLocIngre(loc, locIngre, dropRates) if attrib == "DROPRATE" or attrib == "DROP RATE" or attrib == "DROP" or attrib == "D": dropRates = editLocDropRates(loc, dropRates) if attrib == "PREREQUISITE" or attrib == "PREREQ" or attrib == "PRE" or attrib == "P": prereq = editLocPrereq(loc, prereq) print(prereq) if attrib == "SAVE" or attrib == "S": newLoc = helpers.Location(loc.getID(), name, img, color, locIngre, dropRates, prereq[0], prereq[1], prereq[2]) Locations.append(newLoc) helpers.saveLocations(Locations) Locations = helpers.InitLocations() print("Successfully saved")
def editRecipe(): Tools = helpers.InitTools() Ingredients = helpers.InitIngredients() Ingredients.sort(key=lambda k: k.getName()) Combinations = helpers.InitCreateRecipes() Extractions = helpers.InitExtractRecipes() Running = True RecipeType = None recipe = None while Running: print("=====Edit Recipes=====") print("Type q to quit") while True: option = input( "Select type of recipe to edit (Combination|Extraction): " ).upper() if option == "" or 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") while (Running): print("Type \'list\' to see all recipes") print("Select Recipe ID to Edit:") entry = input() option = entry.upper() if option.upper() == "LIST": if RecipeType == "Combination": DevHelpers.printRecipes(Combinations) elif RecipeType == "Extraction": DevHelpers.printRecipes(Extractions) else: print('How did you get here?') 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 Recipe 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 = editRecipeName(tool, name) if attrib == "TOOL": use = editRecipeTool(tool, use) if attrib == "INSLOTS" or attrib == "IN" or attrib == "I": inSlots = editRecipeRequirements(tool, inSlots) if attrib == "OUTSLOTS" or attrib == "OUT" or attrib == "O": outSlots = editRecipeResults(tool, inSlots) if attrib == "UNLOCKED" or attrib == "U": unlocked = editRecipeUnlocked(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 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)