<spanid="evennia-contrib-tutorials-evadventure-shops"></span><h1>evennia.contrib.tutorials.evadventure.shops<aclass="headerlink"href="#module-evennia.contrib.tutorials.evadventure.shops"title="Permalink to this headline">¶</a></h1>
<p>EvAdventure Shop system.</p>
<p>A shop is run by an NPC. It can provide one or more of several possible services:</p>
<ulclass="simple">
<li><p>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.</p></li>
<li><p>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.</p></li>
<li><p>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.</p></li>
<li><p>Buy rumors - this is echoed to the player for a price. Different merchants could have
different rumors (or randomized ones).</p></li>
<li><p>Quest - gain or hand in a quest for a merchant.</p></li>
</ul>
<p>All shops are menu-driven. One starts talking to the npc and will then end up in their shop
interface.</p>
<p>This is a series of menu nodes meant to be added as a mapping via
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.tutorials.evadventure.shops.</code><codeclass="sig-name descname">BuyItem</code><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#BuyItem"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = ''</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">desc</code><emclass="property"> = ''</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.desc"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">obj_type</code><emclass="property"> = 'gear'</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.obj_type"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">size</code><emclass="property"> = 1</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.size"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">value</code><emclass="property"> = 0</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.value"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">use_slot</code><emclass="property"> = 'backpack'</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.use_slot"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">uses</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.uses"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">quality</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.quality"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">attack_type</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.attack_type"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">defense_type</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.defense_type"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">damage_roll</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.damage_roll"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">obj</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.obj"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">prototype</code><emclass="property"> = None</em><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.prototype"title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><codeclass="sig-name descname">create_from_obj</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">obj</span></em>, <emclass="sig-param"><spanclass="n">shopkeeper</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#BuyItem.create_from_obj"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.create_from_obj"title="Permalink to this definition">¶</a></dt>
<dd><p>Build a new BuyItem container from a real db obj.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>obj</strong> (<aclass="reference internal"href="evennia.contrib.tutorials.evadventure.objects.html#evennia.contrib.tutorials.evadventure.objects.EvAdventureObject"title="evennia.contrib.tutorials.evadventure.objects.EvAdventureObject"><em>EvAdventureObject</em></a>) – An object to analyze.</p></li>
<li><p><strong>shopkeeper</strong> (<aclass="reference internal"href="evennia.contrib.tutorials.evadventure.npcs.html#evennia.contrib.tutorials.evadventure.npcs.EvAdventureShopKeeper"title="evennia.contrib.tutorials.evadventure.npcs.EvAdventureShopKeeper"><em>EvAdventureShopKeeper</em></a>) – The shopkeeper.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>BuyItem</em>– A general representation of the original data.</p>
<emclass="property">static </em><codeclass="sig-name descname">create_from_prototype</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">self</span></em>, <emclass="sig-param"><spanclass="n">prototype_or_key</span></em>, <emclass="sig-param"><spanclass="n">shopkeeper</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#BuyItem.create_from_prototype"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.create_from_prototype"title="Permalink to this definition">¶</a></dt>
<dd><p>Build a new BuyItem container from a prototype.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>prototype</strong> (<em>dict</em><em> or </em><em>key</em>) – 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.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>BuyItem</em>– A general representation of the original data.</p>
<codeclass="sig-name descname">get_detail</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#BuyItem.get_detail"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.get_detail"title="Permalink to this definition">¶</a></dt>
<dd><p>Get more info when looking at the item.</p>
<codeclass="sig-name descname">to_obj</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#BuyItem.to_obj"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.to_obj"title="Permalink to this definition">¶</a></dt>
<dd><p>Convert this into an actual database object that we can trade. This either means
using the stored <strong>.prototype</strong> to spawn a new instance of the object, or to
use the <strong>.obj</strong> reference to get the already existing object.</p>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span>→ None<aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.BuyItem.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<codeclass="sig-prename descclassname">evennia.contrib.tutorials.evadventure.shops.</code><codeclass="sig-name descname">node_confirm_buy</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">raw_string</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#node_confirm_buy"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.node_confirm_buy"title="Permalink to this definition">¶</a></dt>
<dd><p>Menu node reached when a user selects an item in the buy menu. The <strong>item</strong> passed
along in <strong>**kwargs</strong> is the selected item (see <strong>_select_ware_to_buy</strong>, where this is injected).</p>
<codeclass="sig-prename descclassname">evennia.contrib.tutorials.evadventure.shops.</code><codeclass="sig-name descname">node_confirm_sell</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">caller</span></em>, <emclass="sig-param"><spanclass="n">raw_string</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/tutorials/evadventure/shops.html#node_confirm_sell"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.tutorials.evadventure.shops.node_confirm_sell"title="Permalink to this definition">¶</a></dt>
<dd><p>In this node we confirm the sell by first investigating the item we are about to sell.</p>
<p>We have <strong>item</strong> and <strong>value</strong> available in kwargs here, added by <strong>_select_ware_to_sell</strong> earler.</p>