Advertisement
Kovitikus

Untitled

Nov 30th, 2020 (edited)
520
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.33 KB | None | 0 0
  1. # npc_prototypes.py module
  2. BASIC_SUPPLIES = {
  3.     'prototype_parent': 'merchant',
  4.     'key': 'basic supplies merchant',
  5.     'stock': ['CRUDELY_MADE_TORCH', 'FOUL_SMELLING_BAIT']
  6. }
  7.  
  8.  
  9.  
  10.  
  11. # merchant_handler.py module
  12. from world.items import item_prototypes
  13. from evennia.prototypes.prototypes import search_prototype
  14.  
  15. class MerchantHandler:
  16.     def __init__(self, owner):
  17.         self.owner = owner
  18.  
  19.     def return_stock(self):
  20.         """
  21.        =========[Stock]===============
  22.        a poorly-crafted torch
  23.        an unappetizing food ration
  24.        a dirty flask of oil
  25.        a crude iron lantern
  26.        a make-shift fishing rod
  27.        a piece of foul-smelling bait
  28.        ===============================
  29.        """
  30.         owner = self.owner
  31.         if owner.attributes.has('stock'):
  32.             stocked_items = owner.attributes.get('stock')
  33.  
  34.         header = "=========[Stock]==============="
  35.         body = []
  36.         footer = "==============================="
  37.         item = None
  38.         name = None
  39.         price = None
  40.  
  41.         for i in stocked_items:
  42.             item = search_prototype(i)
  43.             item = item[0]
  44.             name = item['key']
  45.             price = item['price']
  46.             body.append(f"{name}    {price}\n")
  47.  
  48.         msg = f"{header}\n{''.join(body)}{footer}"
  49.         return msg
  50.  
  51.  
  52. # item_prototypes.py module
  53. from evennia.utils.utils import random
  54.  
  55. """
  56. CONSUMABLE CATEGORY
  57. """
  58. # Food Category
  59. FOOD = {
  60.     'prototype_key': 'food',
  61.     'prototype_desc': 'Food items.',
  62.     'prototype_tags': 'food',
  63.     'typeclass': 'typeclasses.objects.Object',
  64.     'tags': ('food', 'consumable')
  65. }
  66.  
  67. RASPBERRY_CAKE = {
  68.     'prototype_parent': 'food',
  69.     'key': 'raspberry cake',
  70.     'price': 10,
  71.     'hunger': 10
  72. }
  73.  
  74. BEEF_STEAK = {
  75.     'prototype_parent': 'food',
  76.     'key': 'beef steak',
  77.     'price': 50,
  78.     'hunger': 25
  79. }
  80.  
  81. MILLET_PORRIDGE = {
  82.     'prototype_parent': 'food',
  83.     'key': 'millet porridge',
  84.     'price': 4,
  85.     'hunger': 15
  86. }
  87.  
  88. BARLEY_PORRIDGE = {
  89.     'prototype_parent': 'food',
  90.     'key': 'barley porridge',
  91.     'price': 4,
  92.     'hunger': 15
  93. }
  94.  
  95. STEWED_BEETROOT = {
  96.     'prototype_parent': 'food',
  97.     'key': 'stewed beetroot',
  98.     'price': 4,
  99.     'hunger': 15
  100. }
  101.  
  102. BOILED_MUTTON_AND_PEAS = {
  103.     'prototype_parent': 'food',
  104.     'key': 'boiled mutton and peas',
  105.     'price': 11,
  106.     'hunger': 25
  107. }
  108.  
  109. # Drink Category
  110. DRINK = {
  111.     'prototype_key': 'drink',
  112.     'prototype_desc': 'Drink items.',
  113.     'prototype_tags': 'drink',
  114.     'typeclass': 'typeclasses.objects.Object',
  115.     'tags': ('drink', 'consumable')
  116. }
  117.  
  118. BLACK_TEA = {
  119.     'prototype_parent': 'drink',
  120.     'key': 'black tea',
  121.     'price': 3,
  122.     'thirst': 5
  123. }
  124.  
  125. WATER = {
  126.     'prototype_parent': 'drink',
  127.     'key': 'water',
  128.     'price': 1,
  129.     'thirst': 5
  130. }
  131.  
  132.  
  133.  
  134.  
  135.  
  136. """
  137. LIGHTING CATEGORY
  138. """
  139. LIGHTING = {
  140.     'prototype_key': 'lighting',
  141.     'key': 'lighting',
  142.     'typeclass': 'typeclasses.objects.Lighting'
  143. }
  144.  
  145. TORCH = {
  146.     'prototype_parent': 'lighting',
  147.     'key': 'torch',
  148.     'typeclass': 'typeclasses.objects.Torch'
  149. }
  150.  
  151. CRUDELY_MADE_TORCH = {
  152.     'prototype_parent': 'lighting',
  153.     'prototype_key': 'crudely-made torch',
  154.     'key': 'crudely-made torch',
  155.     'typeclass': 'typeclasses.objects.Torch',
  156.     'price': 10,
  157.     'fuel': 90,
  158.     'burn_rate': 30
  159. }
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166. INVENTORY_CONTAINER = {
  167.     'prototype_key': 'inventory_container',
  168.     'key': 'inventory_container',
  169.     'typeclass': 'typeclasses.objects.InventoryContainer'
  170. }
  171.  
  172.  
  173. INVENTORY_BAG = {
  174.     'prototype_parent': 'inventory_container',
  175.     'key': lambda: generate_random_bag_key()
  176. }
  177.  
  178. def generate_random_bag_key():
  179.     color = ('red', 'blue', 'green', 'yellow', 'black')
  180.     adjective = ('tattered', 'worn', 'pristine', 'well-crafted', 'frayed')
  181.     # a tattered red bag
  182.     # a pristine yellow bag
  183.     bag_key = f"a {random.choice(adjective)} {random.choice(color)} bag"
  184.     return bag_key
  185.  
  186. # Bags
  187. # Satchels
  188. # Sacks
  189. # Backpacks
  190.  
  191. BAIT = {
  192.     'prototype_key': 'bait',
  193.     'prototype_desc': 'Fishing bait',
  194.     'prototype_tags': 'bait',
  195.     'typeclass': 'typeclasses.objects.Object',
  196.     'tags': ('bait', 'fishing')
  197. }
  198.  
  199.  
  200. FOUL_SMELLING_BAIT = {
  201.     'prototype_parent': 'bait',
  202.     'prototype_key': 'foul-smelling bait',
  203.     'key': 'foul-smelling bait',
  204.     'lure': 1,
  205.     'price': 2,
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement