Advertisement
Aquashift108

AIDungeon script

Aug 7th, 2024 (edited)
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.84 KB | Gaming | 0 0
  1.  
  2. class Recipes:
  3.    def __init__(self, ingredients, crafted_item):
  4.         self.ingredients = ingredients
  5.         self.crafted_item = crafted_item
  6.  
  7.  
  8. class Ingredient:
  9.  
  10.     def __init__(self, name, description):
  11.         self.name = name
  12.         self.description = description
  13.         # add any other relevant attributes, like rarity or cost
  14.  
  15.     def __str__(self):
  16.         return f"{self.name}: {self.description}"
  17.     def __repr__(self):
  18.         return f"{self.name}"
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26. # create an ingredient instance
  27. mandrake_root = Ingredient(
  28.     "mandrake root", "A rare and powerful herb with magical properties.")
  29. phoenix_feather = Ingredient("phoenix feather",
  30.                              "Taken from the plumage of the Fire Bird.")
  31. coal = Ingredient(
  32.     "coal",
  33.     "Slow-burned wood - contains a lot of potential combustible energy.")
  34. burnt_wood = Ingredient("burnt wood", "An inferior product compared to coal.")
  35. basilisk_talon = Ingredient(
  36.     "basilisk talon",
  37.     "A claw that was harvested from a perished Basilisk creature.")
  38. water = Ingredient(
  39.     "water",
  40.     "The most basic composite of life.  Can be obtained anywhere there is life."
  41. )
  42. elemental_leaf = Ingredient(
  43.     "elemental leaf",
  44.     "An otherwise ordinary leaf, imbued with a unique type of magic.")
  45. oil = Ingredient("oil",
  46.                  "Rendered fat from an animal, usually a mammal or bird.")
  47. red_herb = Ingredient(
  48.     "red herb",
  49.     "Any herb that is pigmented dark red, and native to the high-elevation plateau in the North continent."
  50. )
  51. chimera_claw = Ingredient("chimera claw", "Hardened keratin product obtained fromh harvesting the paw of a chimera monster.")
  52. #next ingredient us both ingredient and finished crafted item
  53. dragons_breath = Ingredient("Dragon's Breath", "A common way to preserve the attributes of an elemental leaf; by soaking it in oil immediately after imbued with elemental magic, an alchemist can expect a week more of potency versus no oil treatment.")
  54. dandelion_milk = Ingredient("dandelion milk", "Procured by macerating the thicker roots of the dandelion plant.")
  55.  
  56. #create Recipe instances
  57. phoenix_ashes_recipe = Recipes({"phoenix feather":4, "alterative ingredients":[{"coal":1}, {"burnt wood": 2}]},"phoenix ashes")
  58. basilisk_blood_recipe = Recipes({"basilisk talon":3,"water":1}, "basilisk blood")
  59. dragons_breath_recipe = Recipes({"elemental leaf":1,"oil":1}, "dragon's breath")
  60. health_potion_recipe = Recipes({"red herb":3,"water":1},"health potion")
  61. imbued_chimera_claw_recipe = Recipes({"chimera claw":1,"dragon's breath":1,"dandelion milk":1},"imbued chimera claw")
  62.  
  63. # Define items and recipes
  64. inventory = {}
  65. recipes = [
  66. phoenix_ashes_recipe, basilisk_blood_recipe, dragons_breath_recipe, health_potion_recipe, imbued_chimera_claw_recipe
  67.    
  68.       ]
  69.  
  70.  
  71. # Check player inventory for item (in general)
  72. def has_item(item):
  73.     return item in inventory
  74.  
  75.  
  76. # Function to add items to the player's inventory
  77. def add_item(item):
  78.     if has_item(item):
  79.         inventory[item] += 1
  80.     else:
  81.         inventory[item] = 1
  82.  
  83.  
  84. # Function to remove items from inventory
  85. def remove_items(item):
  86.     if has_item(item):
  87.         inventory[item] -= item
  88.  
  89.  
  90. # Check if player has required items in correct amounts for crafting
  91. def has_recipe_items(required_items):
  92.     for item, amount in required_items.items():
  93.         if item not in inventory or inventory[item] < amount:
  94.             return False
  95.     return True
  96.  
  97.  
  98. # Function to craft an item
  99. def craft_item(craftable_item):
  100.     if craftable_item in recipes and has_recipe_items(recipes[craftable_item]):
  101.         # If the recipe exists and the player has the required recipe items
  102.         # Remove the used items from inventory
  103.         for material, amount in recipes[craftable_item].items():
  104.             if material != "alternative_ingredients":
  105.                 remove_items(amount)
Tags: Script
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement