def editIngreEffect(ingre, effects): print("Type \'list\' to list out effects, null to go back") while True: print("Current effects for [" + str(ingre.getID()) + "] :") strE1 = Fore.RED + str(effects[0]) + Fore.RESET strE2 = Fore.RED + str(effects[1]) + Fore.RESET strE3 = Fore.RED + str(effects[2]) + Fore.RESET for eff in helpers.InitEffects(): if eff.getID() == effects[0]: strE1 = str(effects[0]) if eff.getID() == effects[1]: strE2 = str(effects[1]) if eff.getID() == effects[2]: strE3 = str(effects[2]) print("Effect 1: " + strE1 + " | Effect 2: " + strE2 + " | Effect 3: " + strE3) selection = input("Select Effect to edit: ").upper() if selection == "": return effects if selection == "LIST": DevHelpers.printEffects(helpers.InitEffects()) else: if selection == "1" or selection == "EFFECT1" or selection == "EFFECT 1": effects[0] = changeEffect(ingre, effects[0]) if selection == "2" or selection == "EFFECT2" or selection == "EFFECT 2": effects[1] = changeEffect(ingre, effects[1]) if selection == "3" or selection == "EFFECT3" or selection == "EFFECT 3": effects[2] = changeEffect(ingre, effects[2]) print("Type \'list\' to list out effects, null to go back")
def changeEffect(ingre, effect): while True: print("\nEnter new effect for [" + str(ingre.getID()) + "]") print( "Type \'list\' to print out list of effects, type null to go back") print("Current effect: " + str(effect)) newEffect = input() if newEffect.upper() == "LIST" or newEffect.upper() == "L": DevHelpers.printEffects(helpers.InitEffects()) continue if newEffect == "": return effect newEffect = DevHelpers.IDFormat(newEffect) for i in helpers.InitEffects(): if i.getID() == newEffect: return newEffect opt = input( "This effect is not an existing effect, would you like to create a new one? (y|n)" ).upper() if opt == "Y" or opt == "YES": createEffect() continue return newEffect
def editEffect(): Effects = helpers.InitEffects() Effects.sort(key=lambda k: k.getID()) Running = True effect = None while Running: print("=====Edit Effects=====") while (Running): print("Type \'list\' to see all effects") print("Type q to quit") print("Select Effect 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.printEffects(Effects) else: setToBreak = False effectID = DevHelpers.IDFormat(option) for i in Effects: if i.getID() == effectID: effect = i setToBreak = True break if setToBreak: break if not Running: break #get vars ready ingName = effect.getIngName() potName = effect.getPotName() upName = effect.getUpName() editingIngredient = True while (editingIngredient): print("\nSelect Attribute to Edit for [" + str(effect.getID()) + "]") print("Type s to save and continue, q save and quit") print("Ingredient Name | Potion Name | Upgrade Name") attrib = input().upper() if attrib == "" or attrib == "Q" or attrib == "EXIT" or attrib == "QUIT" or attrib == "STOP" or attrib == "END": newEffect = helpers.Effect(effect.getID(), ingName, potName, upName) Effects.append(newEffect) helpers.saveEffects(Effects) Effects = helpers.InitEffects() print("Successfully saved") editingIngredient = False break if attrib == "INGREDIENTNAME" or attrib == "INGREDIENT NAME" or attrib == "IN": ingName = editEffectIngName(effect, ingName) if attrib == "POTIONNAME" or attrib == "POTION NAME" or attrib == "PN": potName = editEffectIngName(effect, potName) if attrib == "UPGRADENAME" or attrib == "UPGRADE NAME" or attrib == "UN": upName = editEffectIngName(effect, upName) if attrib == "SAVE" or attrib == "S": newEffect = helpers.Effect(effect.getID(), ingName, potName, upName) Effects.append(newEffect) helpers.saveEffects(Effects) Effects = helpers.InitEffects() print("Successfully saved")