Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Results
- """
- =========[Stock]===============
- crudely-made torch 10
- foul-smelling bait 2
- ===============================
- """
- # MerchantHandler
- from world.items.item_prototypes import ITEMS
- class MerchantHandler:
- def __init__(self, owner):
- self.owner = owner
- def return_stock(self):
- owner = self.owner
- if owner.attributes.has('stock'):
- stocked_items = owner.attributes.get('stock')
- header = "=========[Stock]==============="
- body = []
- footer = "==============================="
- item = None
- name = None
- price = None
- for i in stocked_items:
- item = ITEMS[i]
- name = item['key']
- price = item['price']
- body.append(f"{name} {price}\n")
- msg = f"{header}\n{''.join(body)}{footer}"
- return msg
- # Stock Command
- class CmdStock(Command):
- key = 'stock'
- def func(self):
- room_contents = self.caller.location.contents
- for i in room_contents:
- if i.is_typeclass('typeclasses.characters.Merchant'):
- self.caller.msg(i.merch.return_stock())
- # NPC Prototypes
- MERCHANT = {
- 'prototype_key': 'merchant',
- 'key': 'merchant',
- 'typeclass': 'typeclasses.characters.Merchant',
- 'tags': ('merchant', 'npc')
- }
- BASIC_SUPPLIES = {
- 'prototype_parent': 'merchant',
- 'key': 'basic supplies merchant',
- 'stock': ['crudely_made_torch', 'foul_smelling_bait']
- }
- # Item Prototypes
- from evennia.utils.utils import random
- ITEMS = {
- 'food': {
- 'prototype_key': 'food',
- 'prototype_desc': 'Food items.',
- 'prototype_tags': 'food',
- 'typeclass': 'typeclasses.objects.Object',
- 'tags': ('food', 'consumable')
- },
- 'raspbery_cake': {
- 'prototype_parent': 'food',
- 'key': 'raspberry cake',
- 'price': 10,
- 'hunger': 10
- },
- 'beef_steak': {
- 'prototype_parent': 'food',
- 'key': 'beef steak',
- 'price': 50,
- 'hunger': 25
- },
- 'millet_porridge': {
- 'prototype_parent': 'food',
- 'key': 'millet porridge',
- 'price': 4,
- 'hunger': 15
- },
- 'barley_porridge': {
- 'prototype_parent': 'food',
- 'key': 'barley porridge',
- 'price': 4,
- 'hunger': 15
- },
- 'stewed_beetroot': {
- 'prototype_parent': 'food',
- 'key': 'stewed beetroot',
- 'price': 4,
- 'hunger': 15
- },
- 'boiled_mutton_and_peas': {
- 'prototype_parent': 'food',
- 'key': 'boiled mutton and peas',
- 'price': 11,
- 'hunger': 25
- },
- 'drink': {
- 'prototype_key': 'drink',
- 'prototype_desc': 'Drink items.',
- 'prototype_tags': 'drink',
- 'typeclass': 'typeclasses.objects.Object',
- 'tags': ('drink', 'consumable')
- },
- 'black_tea': {
- 'prototype_parent': 'drink',
- 'key': 'black tea',
- 'price': 3,
- 'thirst': 5
- },
- 'water': {
- 'prototype_parent': 'drink',
- 'key': 'water',
- 'price': 1,
- 'thirst': 5
- },
- 'lighting': {
- 'prototype_key': 'lighting',
- 'key': 'lighting',
- 'typeclass': 'typeclasses.objects.Lighting'
- },
- 'torch': {
- 'prototype_parent': 'lighting',
- 'key': 'torch',
- 'typeclass': 'typeclasses.objects.Torch'
- },
- 'crudely_made_torch': {
- 'prototype_parent': 'lighting',
- 'prototype_key': 'CRUDELY_MADE_TORCH',
- 'key': 'crudely-made torch',
- 'typeclass': 'typeclasses.objects.Torch',
- 'price': 10,
- 'fuel': 90,
- 'burn_rate': 30
- },
- 'inventory_container': {
- 'prototype_key': 'inventory_container',
- 'key': 'inventory_container',
- 'typeclass': 'typeclasses.objects.InventoryContainer'
- },
- 'inventory_bag': {
- 'prototype_parent': 'inventory_container',
- 'key': lambda: generate_random_bag_key()
- },
- 'bait': {
- 'prototype_key': 'bait',
- 'prototype_desc': 'Fishing bait',
- 'prototype_tags': 'bait',
- 'typeclass': 'typeclasses.objects.Object',
- 'tags': ('bait', 'fishing')
- },
- 'foul_smelling_bait': {
- 'prototype_parent': 'bait',
- 'prototype_key': 'FOUL_SMELLING_BAIT',
- 'key': 'foul-smelling bait',
- 'lure': 1,
- 'price': 2,
- }
- }
- def generate_random_bag_key():
- color = ('red', 'blue', 'green', 'yellow', 'black')
- adjective = ('tattered', 'worn', 'pristine', 'well-crafted', 'frayed')
- # a tattered red bag
- # a pristine yellow bag
- bag_key = f"a {random.choice(adjective)} {random.choice(color)} bag"
- return bag_key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement