コード例 #1
0
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")
コード例 #2
0
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")
コード例 #3
0
def editLocIngreRemove(loc, ingres, dropRates):
    while True:
        cont = True
        print("\nInput ingredient to remove")
        print("Type \'list\' to list current 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
        ingre = DevHelpers.IDFormat(ingre)
        for i in range(len(ingres)):
            if ingre == loc.getIngredients()[i]:
                choice = input("Are you sure you want to delete [" + ingre +
                               "]? (y/n) :")
                if choice.upper() == "Y":
                    ingres.pop(i)
                    dropRates.pop(i)

                cont = False
                break
        if cont:
            print("Ingredient could not be found")
コード例 #4
0
ファイル: EditTool.py プロジェクト: djlamber/Alchemy-Shop
def editToolName(tool, name):
    print("Current name for ["+str(tool.getID())+"] : " + str(name))
    newName = input("Input new name or null to go back: ")
    if newName == "":
        return name
    else:
        return DevHelpers.NameFormat(newName)
コード例 #5
0
def editIngreCategory(ingre, categoryList):
    while (True):
        print("\nCurrent categories for [" + str(ingre.getID()) + "] : \n" +
              str(categoryList))
        print("Type null to go back, select an option:")
        selection = input("Add | Remove\n").upper()
        if selection == "" or selection == "Q" or selection == "EXIT" or selection == "QUIT" or selection == "STOP" or selection == "END":
            return categoryList
        if selection == "ADD" or selection == "A":
            cat = DevHelpers.IDFormat(input("Type in new category:\n"))
            categoryList.append(cat)
        if selection == "REMOVE" or selection == "R" or selection == "DELETE" or selection == "D":
            cat = DevHelpers.IDFormat(input("Type in category to delete:\n"))
            try:
                categoryList.remove(cat)
            except:
                print("Category does not exist")
コード例 #6
0
ファイル: EditEffect.py プロジェクト: djlamber/Alchemy-Shop
def editEffectIngName(effect, name):
    print("Current Ingredient name for [" + str(effect.getID()) + "] : " +
          str(name))
    newName = input("Input new name or null to go back: ")
    if newName == "":
        return name
    else:
        return DevHelpers.NameFormat(newName)
コード例 #7
0
def changePrereq(ingre, prereq):
    print("\nSelect what to change the prerequisite to [" +
          str(ingre.getID()) + "]")
    print("Gold | Potion | None | Current prereq: " + str(prereq))
    print("Type null to go back")
    newReq = input().upper()
    if newReq == "":
        return prereq
    if newReq == "G" or newReq == "GOLD":
        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
        prereq = {"Gold": Value}
    if newReq == "P" or newReq == "POTION":
        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
            }
        }

    if newReq == "N" or newReq == "NONE":
        prereq = "None"
    print(prereq)
    return prereq
コード例 #8
0
def editIngreColor(ingre, color):
    while True:
        print("Current Color for [" + str(ingre.getID()) + "] : " + str(color))
        newColor = input("Input new Color or null to go back: ")
        if newColor == "":
            return color
        else:
            colorCheck = DevHelpers.checkColor(newColor)
            if colorCheck == None:
                print("Color is not valid")
            else:
                return colorCheck
コード例 #9
0
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
コード例 #10
0
def editLocDropRates(loc, value):
    print(value)
    while True:
        leaveFirst = True
        locIngs = loc.getIngredients()
        locDrops = loc.getDropRates()
        rate = None
        index = -1
        while leaveFirst:
            print("Current Drop rates for for [" + str(loc.getID()) + "]")
            for i in range(len(loc.getIngredients())):
                rate = locDrops[i]
                print("[" + str(locIngs[i]) + "] : [" + str(value[i][0]) +
                      "|" + str(value[i][1]) + "]")
            ingre = input("Select ingredient to edit or null to go back: ")
            if ingre == "":
                return value
            for i in range(len(loc.getIngredients())):
                if DevHelpers.IDFormat(ingre) == loc.getIngredients()[i]:
                    leaveFirst = False
                    index = i
                    break
        print("Select \'rate\' dropped or \'amount\' dropped for [" +
              str(locIngs[index]) + "] : [" + str(value[index][0]) + "|" +
              str(value[index][1]) + "]")
        print("Type null to go back: ")
        opt = input().upper()
        if opt == "":
            continue
        #TODO add int and float checks
        if opt == "RATE" or opt == "R":
            r = float(input("Input new rate: "))
            if r < 0:
                r = 0
            value[index][0] = r
        if opt == "AMOUNT" or opt == "A":
            a = int(input("Input new amount: "))
            if a < 0:
                a = 0
            value[index][1] = a
コード例 #11
0
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)
コード例 #12
0
ファイル: EditTool.py プロジェクト: djlamber/Alchemy-Shop
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")
コード例 #13
0
ファイル: EditEffect.py プロジェクト: djlamber/Alchemy-Shop
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")
コード例 #14
0
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")
コード例 #15
0
ファイル: CreateRecipe.py プロジェクト: djlamber/Alchemy-Shop
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)
コード例 #16
0
ファイル: CreateTool.py プロジェクト: djlamber/Alchemy-Shop
def createTool():
    Tools = helpers.InitTools()
    Running = True
    print("=====Create Tool=====")
    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 T in Tools:
            if T.getID() == ID:
                print("ID already taken")
                setContinue = True
                break
        if setContinue:
            continue

        # Select Name
        name = input("Input Name: ")
        name = DevHelpers.NameFormat(name)

        # Select Image Dir
        img = input("Input Image directory: ")
        if not os.path.exists(img):
            print("Path does not exist, setting default")
            img = "sprites/UnknownWhite.png"

        # Select Use
        while True:
            use = input("Input usage for tool (Extraction | Combination): ")
            if use.upper() == "EXTRACTION" or use.upper() == "Combination":
                use = DevHelpers.NameFormat(use)
                break
            if use.upper() == "E":
                use = "Extraction"
                break
            if use.upper() == "C":
                use = "Combination"
                break
            print("Invalid Input\n")

        # Select Inslots
        while True:
            inSlots = input("Input number of input slots (1-5): ")
            if inSlots == "":
                inSlots = 1
                break
            try:
                inSlots = int(inSlots)
            except ValueError:
                print("That is not a integer")
            if type(inSlots) == int:
                if inSlots < 0:
                    inSlots = 1
                if inSlots > 5:
                    inSlots = 5
                break

        # Select OutSlots
        while True:
            outSlots = input("Input number of output slots (1-5): ")
            if outSlots == "":
                outSlots = 1
                break
            try:
                outSlots = int(outSlots)
            except ValueError:
                print("That is not a integer")
            if type(outSlots) == int:
                if outSlots < 0:
                    outSlots = 1
                if outSlots > 5:
                    outSlots = 5
                break

        # Select Unlocked status
        while True:
            unlocked = input("Input unlocked status: ")
            if unlocked.upper() == "TRUE" or unlocked.upper() == "T":
                unlocked = True
                break
            if unlocked.upper() == "FALSE" or unlocked.upper() == "F":
                unlocked = False
                break
            print("Invalid input\n")

        # Create Tool
        newTool = helpers.Tool(ID, name, img, use, inSlots, outSlots, unlocked)
        Tools.append(newTool)
        ans = input("Sucessfully added to list, continue? (y/n): ")
        if ans.upper() != 'Y':
            Running = False
    helpers.saveTools(Tools)
コード例 #17
0
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")
コード例 #18
0
ファイル: EditRecipe.py プロジェクト: djlamber/Alchemy-Shop
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")