<spanid="evennia-contrib-game-systems-crafting-crafting"></span><h1>evennia.contrib.game_systems.crafting.crafting<aclass="headerlink"href="#module-evennia.contrib.game_systems.crafting.crafting"title="Permalink to this headline">¶</a></h1>
<p>Crafting - Griatch 2020</p>
<p>This is a general crafting engine. The basic functionality of crafting is to
combine any number of of items or tools in a ‘recipe’ to produce a new result.</p>
<spanclass="c1"># Pig iron is a high-carbon result of melting iron in a blast furnace.</span>
<spanclass="n">name</span><spanclass="o">=</span><spanclass="s2">"pig iron"</span><spanclass="c1"># this is what crafting.craft and CmdCraft uses</span>
<spanclass="p">{</span><spanclass="s2">"key"</span><spanclass="p">:</span><spanclass="s2">"Pig Iron ingot"</span><spanclass="p">,</span>
<spanclass="s2">"desc"</span><spanclass="p">:</span><spanclass="s2">"An ingot of crude pig iron."</span><spanclass="p">,</span>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">CraftingError</code><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingError"title="Permalink to this definition">¶</a></dt>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">CraftingValidationError</code><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingValidationError"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">CraftingRecipeBase</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafter</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">inputs</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">name</code><emclass="property"> = 'recipe base'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.name"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">allow_reuse</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.allow_reuse"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafter</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">inputs</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the recipe.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>crafter</strong> (<em>Object</em>) – The one doing the crafting.</p></li>
<li><p><strong>*inputs</strong> (<em>any</em>) – The ingredients of the recipe to use.</p></li>
<li><p><strong>**kwargs</strong> (<em>any</em>) – Any other parameters that are relevant for
<codeclass="sig-name descname">msg</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">message</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase.msg"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.msg"title="Permalink to this definition">¶</a></dt>
<dd><p>Send message to crafter. This is a central point to override if wanting
to change crafting return style in some way.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>message</strong> (<em>str</em>) – The message to send.</p></li>
<li><p><strong>**kwargs</strong>– Any optional properties relevant to this send.</p></li>
<codeclass="sig-name descname">pre_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase.pre_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.pre_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook to override.</p>
<p>This is called just before crafting operation and is normally
responsible for validating the inputs, storing data on
<strong>self.validated_inputs</strong>.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>**kwargs</strong>– Optional extra flags passed during initialization or</p></li>
<li><p><strong>**.craft</strong>–</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"title="evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"><strong>CraftingValidationError</strong></a>– If validation fails.</p>
<codeclass="sig-name descname">do_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase.do_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.do_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook to override.</p>
<p>This performs the actual crafting. At this point the inputs are
expected to have been verified already. If needed, the validated
inputs are available on this recipe instance.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>**kwargs</strong>– Any extra flags passed at initialization.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>any</em>– The result of crafting.</p>
<codeclass="sig-name descname">post_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafting_result</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase.post_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.post_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook to override.</p>
<p>This is called just after crafting has finished. A common use of this
method is to delete the inputs.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>crafting_result</strong> (<em>any</em>) – The outcome of crafting, as returned by <strong>do_craft</strong>.</p></li>
<li><p><strong>**kwargs</strong>– Any extra flags passed at initialization.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>any</em>– The final crafting result.</p>
<codeclass="sig-name descname">craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">raise_exception</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipeBase.craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipeBase.craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Main crafting call method. Call this to produce a result and make
sure all hooks run correctly.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>raise_exception</strong> (<em>bool</em>) – If crafting would return <strong>None</strong>, raise
exception instead.</p></li>
<li><p><strong>**kwargs</strong> (<em>any</em>) – Any other parameters that is relevant
for this particular craft operation. This will temporarily
override same-named kwargs given at the creation of this recipe
and be passed into all of the crafting hooks.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>any</em>– The result of the craft, or <strong>None</strong> if crafting failed.</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><aclass="reference internal"href="#evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"title="evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"><strong>CraftingValidationError</strong></a>– If recipe validation failed and
<strong>raise_exception</strong> is True.</p></li>
<li><p><aclass="reference internal"href="#evennia.contrib.game_systems.crafting.crafting.CraftingError"title="evennia.contrib.game_systems.crafting.crafting.CraftingError"><strong>CraftingError</strong></a>– On If trying to rerun a no-rerun recipe, or if crafting
would return <strong>None</strong> and raise_exception** is set.</p></li>
<codeclass="sig-name descname">allow_craft</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.NonExistentRecipe.allow_craft"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">allow_reuse</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.NonExistentRecipe.allow_reuse"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafter</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">inputs</span></em>, <emclass="sig-param"><spanclass="n">name</span><spanclass="o">=</span><spanclass="default_value">''</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#NonExistentRecipe.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.NonExistentRecipe.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the recipe.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>crafter</strong> (<em>Object</em>) – The one doing the crafting.</p></li>
<li><p><strong>*inputs</strong> (<em>any</em>) – The ingredients of the recipe to use.</p></li>
<li><p><strong>**kwargs</strong> (<em>any</em>) – Any other parameters that are relevant for
<codeclass="sig-name descname">pre_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#NonExistentRecipe.pre_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.NonExistentRecipe.pre_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook to override.</p>
<p>This is called just before crafting operation and is normally
responsible for validating the inputs, storing data on
<strong>self.validated_inputs</strong>.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>**kwargs</strong>– Optional extra flags passed during initialization or</p></li>
<li><p><strong>**.craft</strong>–</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"title="evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"><strong>CraftingValidationError</strong></a>– If validation fails.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">CraftingRecipe</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafter</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">inputs</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipe"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe"title="Permalink to this definition">¶</a></dt>
<spanclass="p">{</span><spanclass="s2">"key"</span><spanclass="p">:</span><spanclass="s2">"Bag of flour"</span><spanclass="p">,</span>
<codeclass="sig-name descname">name</code><emclass="property"> = 'crafting recipe'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.name"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">consumable_tag_category</code><emclass="property"> = 'crafting_material'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.consumable_tag_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">tool_tag_category</code><emclass="property"> = 'crafting_tool'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.tool_tag_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">tool_tags</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.tool_tags"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">exact_tools</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.exact_tools"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">exact_tool_order</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.exact_tool_order"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">error_tool_missing_message</code><emclass="property"> = 'Could not craft {outputs} without {missing}.'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.error_tool_missing_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">error_tool_order_message</code><emclass="property"> = 'Could not craft {outputs} since {missing} was added in the wrong order.'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.error_tool_order_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">error_tool_excess_message</code><emclass="property"> = 'Could not craft {outputs} without the exact tools (extra {excess}).'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.error_tool_excess_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">consumable_tags</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.consumable_tags"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">consume_on_fail</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.consume_on_fail"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">exact_consumables</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.exact_consumables"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">exact_consumable_order</code><emclass="property"> = False</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.exact_consumable_order"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">error_consumable_missing_message</code><emclass="property"> = 'Could not craft {outputs} without {missing}.'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.error_consumable_missing_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">error_consumable_order_message</code><emclass="property"> = 'Could not craft {outputs} since {missing} was added in the wrong order.'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.error_consumable_order_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">error_consumable_excess_message</code><emclass="property"> = 'Could not craft {outputs} without the exact ingredients (extra {excess}).'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.error_consumable_excess_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">output_prototypes</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.output_prototypes"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">failure_message</code><emclass="property"> = ''</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.failure_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">success_message</code><emclass="property"> = 'You successfully craft {outputs}!'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.success_message"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafter</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">inputs</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipe.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.__init__"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>crafter</strong> (<em>Object</em>) – The one doing the crafting.</p></li>
<li><p><strong>*inputs</strong> (<em>Object</em>) – The ingredients (+tools) of the recipe to use. The
The recipe will itself figure out (from tags) which is a tool and
which is a consumable.</p></li>
<li><p><strong>**kwargs</strong> (<em>any</em>) – Any other parameters that are relevant for
this recipe. These will be passed into the crafting hooks.</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>Internally, this class stores validated data in
<strong>.validated_consumables</strong> and <strong>.validated_tools</strong> respectively. The
<strong>.validated_inputs</strong> property (from parent) holds a list of everything
types in the order inserted to the class constructor.</p>
<codeclass="sig-name descname">consumable_names</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.consumable_names"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">tool_names</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.tool_names"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">output_names</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.output_names"title="Permalink to this definition">¶</a></dt>
<emclass="property">classmethod </em><codeclass="sig-name descname">seed</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">tool_kwargs</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">consumable_kwargs</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">location</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipe.seed"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.seed"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a helper class-method for easy testing and application of this
recipe. When called, it will create simple dummy ingredients with names
and tags needed by this recipe.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>tool_kwargs</strong> (<em>dict</em><em>, </em><em>optional</em>) – Will be passed as <strong>**tool_kwargs</strong> into the <strong>create_object</strong>
call for each tool. If not given, the matching
<strong>tool_name</strong> or <strong>tool_tag</strong> will be used for key.</p></li>
<li><p><strong>consumable_kwargs</strong> (<em>dict</em><em>, </em><em>optional</em>) – This will be passed as
<strong>**consumable_kwargs</strong> into the <strong>create_object</strong> call for each consumable.
If not given, matching <strong>consumable_name</strong> or <strong>consumable_tag</strong>
will be used for key.</p></li>
<li><p><strong>location</strong> (<em>Object</em><em>, </em><em>optional</em>) – If given, the created items will be created in this
location. This is a shortcut for adding {“location”: <obj>} to both the
consumable/tool kwargs (and will <em>override</em> any such setting in those kwargs).</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>tuple</em>– A tuple <strong>(tools, consumables)</strong> with newly created dummy
<codeclass="sig-name descname">pre_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipe.pre_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.pre_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Do pre-craft checks, including input validation.</p>
<p>Check so the given inputs are what is needed. This operates on
<strong>self.inputs</strong> which is set to the inputs added to the class
constructor. Validated data is stored as lists on <strong>.validated_tools</strong>
and <strong>.validated_consumables</strong> respectively.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>**kwargs</strong>– Any optional extra kwargs passed during initialization of
the recipe class.</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"title="evennia.contrib.game_systems.crafting.crafting.CraftingValidationError"><strong>CraftingValidationError</strong></a>– If validation fails. At this point the crafter
is expected to have been informed of the problem already.</p>
<codeclass="sig-name descname">do_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipe.do_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.do_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook to override. This will not be called if validation in <strong>pre_craft</strong>
fails.</p>
<p>This performs the actual crafting. At this point the inputs are
expected to have been verified already.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><p><em>list</em>–</p>
<dlclass="simple">
<dt>A list of spawned objects created from the inputs, or None</dt><dd><p>on a failure.</p>
</dd>
</dl>
</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This method should use <strong>self.msg</strong> to inform the user about the
specific reason of failure immediately.
We may want to analyze the tools in some way here to affect the
<codeclass="sig-name descname">post_craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">craft_result</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingRecipe.post_craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingRecipe.post_craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook to override.
This is called just after crafting has finished. A common use of
this method is to delete the inputs.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>craft_result</strong> (<em>list</em>) – The crafted result, provided by <strong>self.do_craft</strong>.</p></li>
<li><p><strong>**kwargs</strong> (<em>any</em>) – Passed from <strong>self.craft</strong>.</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>list</em>– The return(s) of the craft, possibly modified in this method.</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>This is _always_ called, also if validation in <strong>pre_craft</strong> fails
(<strong>craft_result</strong> will then be <strong>None</strong>).</p>
<codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">craft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">crafter</span></em>, <emclass="sig-param"><spanclass="n">recipe_name</span></em>, <emclass="sig-param"><spanclass="o">*</span><spanclass="n">inputs</span></em>, <emclass="sig-param"><spanclass="n">raise_exception</span><spanclass="o">=</span><spanclass="default_value">False</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#craft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.craft"title="Permalink to this definition">¶</a></dt>
<dd><p>Access function. Craft a given recipe from a source recipe module. A
recipe module is a Python module containing recipe classes. Note that this
requires <strong>settings.CRAFT_RECIPE_MODULES</strong> to be added to a list of one or
more python-paths to modules holding Recipe-classes.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>crafter</strong> (<em>Object</em>) – The one doing the crafting.</p></li>
<li><p><strong>recipe_name</strong> (<em>str</em>) – The <strong>CraftRecipe.name</strong> to use. This uses fuzzy-matching
if the result is unique.</p></li>
<li><p><strong>*inputs</strong>– Suitable ingredients and/or tools (Objects) to use in the crafting.</p></li>
<li><p><strong>raise_exception</strong> (<em>bool</em><em>, </em><em>optional</em>) – If crafting failed for whatever
reason, raise <strong>CraftingError</strong>. The user will still be informed by the
recipe.</p></li>
<li><p><strong>**kwargs</strong>– Optional kwargs to pass into the recipe (will passed into
recipe.craft).</p></li>
</ul>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><em>list</em>– Crafted objects, if any.</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><aclass="reference internal"href="#evennia.contrib.game_systems.crafting.crafting.CraftingError"title="evennia.contrib.game_systems.crafting.crafting.CraftingError"><strong>CraftingError</strong></a>– If <strong>raise_exception</strong> is True and crafting failed to</p></li>
<li><p><strong>produce an output. KeyError</strong>– If <strong>recipe_name</strong> failed to find a</p></li>
<li><p><strong>matching recipe class</strong><strong> (or </strong><strong>the hit was not precise enough.</strong><strong>)</strong>–</p></li>
</ul>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>If no recipe_module is given, will look for a list <strong>settings.CRAFT_RECIPE_MODULES</strong> and
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">CraftingCmdSet</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cmdsetobj</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">key</span><spanclass="o">=</span><spanclass="default_value">None</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingCmdSet"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'Crafting cmdset'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingCmdSet.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">at_cmdset_creation</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CraftingCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<dd><p>Hook method - this should be overloaded in the inheriting
class, and should take care of populating the cmdset by use of
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.contrib.game_systems.crafting.crafting.CraftingCmdSet'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CraftingCmdSet.path"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.game_systems.crafting.crafting.</code><codeclass="sig-name descname">CmdCraft</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="o">**</span><spanclass="n">kwargs</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CmdCraft"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'craft'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.locks"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = []</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">arg_regex</code><emclass="property"> = re.compile('\\s|$', re.IGNORECASE)</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.arg_regex"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': '', 'category': 'general', 'key': 'craft', 'no_prefix': ' ', 'tags': '', 'text': "\n Craft an item using ingredients and tools\n\n Usage:\n craft <recipe> [from <ingredient>,...] [using <tool>, ...]\n\n Examples:\n craft snowball from snow\n craft puppet from piece of wood using knife\n craft bread from flour, butter, water, yeast using owen, bowl, roller\n craft fireball using wand, spellbook\n\n Notes:\n Ingredients must be in the crafter's inventory. Tools can also be\n things in the current location, like a furnace, windmill or anvil.\n\n "}</em><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.search_index_entry"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">parse</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CmdCraft.parse"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.parse"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">func</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/game_systems/crafting/crafting.html#CmdCraft.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.game_systems.crafting.crafting.CmdCraft.func"title="Permalink to this definition">¶</a></dt>
<dd><p>Perform crafting.</p>
<p>Will check the <strong>craft</strong> locktype. If a consumable/ingredient does not pass
this check, we will check for the ‘crafting_consumable_err_msg’
Attribute, otherwise will use a default. If failing on a tool, will use
the <strong>crafting_tool_err_msg</strong> if available.</p>