evennia.contrib.tutorials.evadventure.shops

EvAdventure Shop system.

A shop is run by an NPC. It can provide one or more of several possible services:

  • Buy from a pre-set list of (possibly randomized) items. Cost is based on the item’s value, adjusted by how stingy the shopkeeper is. When bought this way, the item is generated on the fly and passed to the player character’s inventory. Inventory files are a list of prototypes, normally from a prototype-file. A random selection of items from each inventory file is available.

  • Sell items to the shop for a certain percent of their value. One could imagine being able to buy back items again, but we will instead _destroy_ sold items, so as to remove them from circulation. In-game we can say it’s because the merchants collect the best stuff to sell to collectors in the big city later. Each merchant buys a certain subset of items based on their tags.

  • Buy a service. For a cost, a certain action is performed for the character; this applies immediately when bought. The most notable services are healing and converting coin to XP.

  • Buy rumors - this is echoed to the player for a price. Different merchants could have different rumors (or randomized ones).

  • Quest - gain or hand in a quest for a merchant.

All shops are menu-driven. One starts talking to the npc and will then end up in their shop interface.

This is a series of menu nodes meant to be added as a mapping via EvAdventureShopKeeper.create(menudata={},…).

To make this pluggable, the shopkeeper start page will analyze the available nodes and auto-add options to all nodes in the three named node_start_*. The last part of the node name will be the name of the option capitalized, with underscores replaced by spaces, so node_start_sell_items will become a top-level option Sell items.

class evennia.contrib.tutorials.evadventure.shops.BuyItem[source]

Bases: object

Storage container for storing generic info about an item for sale. This means it can be used both for real objects and for prototypes without constantly having to track which is which.

key = ''
desc = ''
obj_type = 'gear'
size = 1
value = 0
use_slot = 'backpack'
uses = None
quality = None
attack_type = None
defense_type = None
damage_roll = None
obj = None
prototype = None
static create_from_obj(obj, shopkeeper)[source]

Build a new BuyItem container from a real db obj.

Parameters
Returns

BuyItem – A general representation of the original data.

static create_from_prototype(self, prototype_or_key, shopkeeper)[source]

Build a new BuyItem container from a prototype.

Parameters

prototype (dict or key) – An Evennia prototype dict or the key of one registered with the system. This is assumed to be a full prototype, including having parsed and included parentage.

Returns

BuyItem – A general representation of the original data.

get_detail()[source]

Get more info when looking at the item.

to_obj()[source]

Convert this into an actual database object that we can trade. This either means using the stored .prototype to spawn a new instance of the object, or to use the .obj reference to get the already existing object.

__init__() → None

Initialize self. See help(type(self)) for accurate signature.

evennia.contrib.tutorials.evadventure.shops.node_confirm_buy(caller, raw_string, **kwargs)[source]

Menu node reached when a user selects an item in the buy menu. The item passed along in **kwargs is the selected item (see _select_ware_to_buy, where this is injected).

evennia.contrib.tutorials.evadventure.shops.node_confirm_sell(caller, raw_string, **kwargs)[source]

In this node we confirm the sell by first investigating the item we are about to sell.

We have item and value available in kwargs here, added by _select_ware_to_sell earler.