evennia/docs/2.x/api/evennia.contrib.tutorials.evadventure.rules.html

340 lines
21 KiB
HTML
Raw Normal View History

2023-06-10 08:55:41 +02:00
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.17.1: http://docutils.sourceforge.net/" />
2023-10-19 20:22:27 +00:00
<title>evennia.contrib.tutorials.evadventure.rules &#8212; Evennia 2.x documentation</title>
2023-06-10 08:55:41 +02:00
<link rel="stylesheet" href="../_static/nature.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script src="../_static/jquery.js"></script>
<script src="../_static/underscore.js"></script>
<script src="../_static/doctools.js"></script>
<script src="../_static/language_data.js"></script>
<link rel="shortcut icon" href="../_static/favicon.ico"/>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="evennia.contrib.tutorials.evadventure.shops" href="evennia.contrib.tutorials.evadventure.shops.html" />
<link rel="prev" title="evennia.contrib.tutorials.evadventure.rooms" href="evennia.contrib.tutorials.evadventure.rooms.html" />
</head><body>
2023-10-19 20:22:27 +00:00
2023-06-10 08:55:41 +02:00
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
accesskey="I">index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="evennia.contrib.tutorials.evadventure.shops.html" title="evennia.contrib.tutorials.evadventure.shops"
accesskey="N">next</a> |</li>
<li class="right" >
<a href="evennia.contrib.tutorials.evadventure.rooms.html" title="evennia.contrib.tutorials.evadventure.rooms"
accesskey="P">previous</a> |</li>
2023-10-19 20:22:27 +00:00
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> &#187;</li>
2023-06-10 08:55:41 +02:00
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-4"><a href="evennia.contrib.html" >evennia.contrib</a> &#187;</li>
<li class="nav-item nav-item-5"><a href="evennia.contrib.tutorials.html" >evennia.contrib.tutorials</a> &#187;</li>
<li class="nav-item nav-item-6"><a href="evennia.contrib.tutorials.evadventure.html" accesskey="U">evennia.contrib.tutorials.evadventure</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">evennia.contrib.tutorials.evadventure.rules</a></li>
</ul>
</div>
<div class="document">
<div class="documentwrapper">
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="../index.html">
<img class="logo" src="../_static/evennia_logo.png" alt="Logo"/>
</a></p>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="../search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
<h4>Previous topic</h4>
<p class="topless"><a href="evennia.contrib.tutorials.evadventure.rooms.html"
title="previous chapter">evennia.contrib.tutorials.evadventure.rooms</a></p>
<h4>Next topic</h4>
<p class="topless"><a href="evennia.contrib.tutorials.evadventure.shops.html"
title="next chapter">evennia.contrib.tutorials.evadventure.shops</a></p>
<div role="note" aria-label="source link">
<!--h3>This Page</h3-->
<ul class="this-page-menu">
<li><a href="../_sources/api/evennia.contrib.tutorials.evadventure.rules.md.txt"
rel="nofollow">Show Page Source</a></li>
</ul>
</div><h3>Links</h3>
<ul>
2023-10-19 20:22:27 +00:00
<li><a href="https://www.evennia.com/docs/latest/index.html">Documentation Top</a> </li>
<li><a href="https://www.evennia.com">Evennia Home</a> </li>
<li><a href="https://github.com/evennia/evennia">Github</a> </li>
2023-06-10 08:55:41 +02:00
<li><a href="http://games.evennia.com">Game Index</a> </li>
<li>
<a href="https://discord.gg/AJJpcRUhtF">Discord</a> -
<a href="https://github.com/evennia/evennia/discussions">Discussions</a> -
<a href="https://evennia.blogspot.com/">Blog</a>
</li>
</ul>
2023-10-19 20:22:27 +00:00
<h3>Doc Versions</h3>
2023-10-19 19:49:53 +00:00
<ul>
2023-10-19 20:22:27 +00:00
<li><a href="evennia.contrib.tutorials.evadventure.rules.html">2.x (main branch)</a></li>
2023-10-19 19:49:53 +00:00
<ul>
2023-10-19 20:22:27 +00:00
<li><a href="../1.3.0/index.html">1.3.0 (v1.3.0 branch)</a></li>
<li><a href="../0.9.5/index.html">0.9.5 (v0.9.5 branch)</a></li>
2023-10-19 19:49:53 +00:00
</ul>
2023-06-10 08:55:41 +02:00
</div>
</div>
<div class="bodywrapper">
<div class="body" role="main">
<section id="module-evennia.contrib.tutorials.evadventure.rules">
<span id="evennia-contrib-tutorials-evadventure-rules"></span><h1>evennia.contrib.tutorials.evadventure.rules<a class="headerlink" href="#module-evennia.contrib.tutorials.evadventure.rules" title="Permalink to this headline"></a></h1>
<p>MUD ruleset based on the _Knave_ OSR tabletop RPG by Ben Milton (modified for MUD use).</p>
2023-10-19 20:22:27 +00:00
<p>The center of the rule system is the “RollEngine”, which handles all rolling of dice
and determining what the outcome is.</p>
<hr class="docutils" />
2023-06-10 08:55:41 +02:00
<dl class="py class">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine">
<em class="property">class </em><code class="sig-prename descclassname">evennia.contrib.tutorials.evadventure.rules.</code><code class="sig-name descname">EvAdventureRollEngine</code><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine" title="Permalink to this definition"></a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>This groups all dice rolls of EvAdventure. These could all have been normal functions, but we
are group them in a class to make them easier to partially override and replace later.</p>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll">
<code class="sig-name descname">roll</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">roll_string</span></em>, <em class="sig-param"><span class="n">max_number</span><span class="o">=</span><span class="default_value">10</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.roll"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll" title="Permalink to this definition"></a></dt>
<dd><p>NOTE: In evennia/contribs/rpg/dice/ is a more powerful dice roller with
more features, such as modifiers, secret rolls etc. This is much simpler and only
gets a simple sum of normal rpg-dice.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>roll_string</strong> (<em>str</em>) A roll using standard rpg syntax, &lt;number&gt;d&lt;diesize&gt;, like
1d6, 2d10 etc. Max die-size is 1000.</p></li>
<li><p><strong>max_number</strong> (<em>int</em>) The max number of dice to roll. Defaults to 10, which is usually
more than enough.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><em>int</em> The rolled result - sum of all dice rolled.</p>
</dd>
<dt class="field-odd">Raises</dt>
<dd class="field-odd"><p><strong>TypeError</strong> If roll_string is not on the right format or otherwise doesnt validate.</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Since we may see user input to this function, we make sure to validate the inputs (we
wouldnt bother much with that if it was just for developer use).</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll_with_advantage_or_disadvantage">
<code class="sig-name descname">roll_with_advantage_or_disadvantage</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">advantage</span><span class="o">=</span><span class="default_value">False</span></em>, <em class="sig-param"><span class="n">disadvantage</span><span class="o">=</span><span class="default_value">False</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.roll_with_advantage_or_disadvantage"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll_with_advantage_or_disadvantage" title="Permalink to this definition"></a></dt>
<dd><p>Base roll of d20, or 2d20, based on dis/advantage given.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>bonus</strong> (<em>int</em>) The ability bonus to apply, like strength or charisma.</p></li>
<li><p><strong>advantage</strong> (<em>bool</em>) Roll 2d20 and use the bigger number.</p></li>
<li><p><strong>disadvantage</strong> (<em>bool</em>) Roll 2d20 and use the smaller number.</p></li>
</ul>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Disadvantage and advantage cancel each other out.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.saving_throw">
<code class="sig-name descname">saving_throw</code><span class="sig-paren">(</span><em class="sig-param">character</em>, <em class="sig-param">bonus_type=&lt;Ability.STR: 'strength'&gt;</em>, <em class="sig-param">target=15</em>, <em class="sig-param">advantage=False</em>, <em class="sig-param">disadvantage=False</em>, <em class="sig-param">modifier=0</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.saving_throw"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.saving_throw" title="Permalink to this definition"></a></dt>
<dd><p>A saving throw without a clear enemy to beat. In _Knave_ all unopposed saving
throws always tries to beat 15, so (d20 + bonus + modifier) &gt; 15.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>character</strong> (<em>Object</em>) The one attempting to save themselves.</p></li>
<li><p><strong>bonus_type</strong> (<em>enum.Ability</em>) The ability bonus to apply, like strength or
charisma.</p></li>
<li><p><strong>target</strong> (<em>int</em><em>, </em><em>optional</em>) Used for opposed throws (in Knave any regular
saving through must always beat 15).</p></li>
<li><p><strong>advantage</strong> (<em>bool</em><em>, </em><em>optional</em>) Roll 2d20 and use the bigger number.</p></li>
<li><p><strong>disadvantage</strong> (<em>bool</em><em>, </em><em>optional</em>) Roll 2d20 and use the smaller number.</p></li>
<li><p><strong>modifier</strong> (<em>int</em><em>, </em><em>optional</em>) An additional +/- modifier to the roll.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><em>tuple</em> </p>
<dl class="simple">
<dt>A tuple <strong>(bool, str, str)</strong>. The bool indicates if the save was passed or not.</dt><dd><p>The second element is the quality of the roll - None (normal),
“critical fail” and “critical success”. Last element is a text detailing
the roll, for display purposes.</p>
</dd>
</dl>
</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Advantage and disadvantage cancel each other out.</p>
<p class="rubric">Example</p>
<p>Trying to overcome the effects of poison, roll d20 + Constitution-bonus above 15.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.opposed_saving_throw">
<code class="sig-name descname">opposed_saving_throw</code><span class="sig-paren">(</span><em class="sig-param">attacker</em>, <em class="sig-param">defender</em>, <em class="sig-param">attack_type=&lt;Ability.STR: 'strength'&gt;</em>, <em class="sig-param">defense_type=&lt;Ability.ARMOR: 'armor'&gt;</em>, <em class="sig-param">advantage=False</em>, <em class="sig-param">disadvantage=False</em>, <em class="sig-param">modifier=0</em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.opposed_saving_throw"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.opposed_saving_throw" title="Permalink to this definition"></a></dt>
<dd><p>An saving throw that tries to beat an active opposing side.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>attacker</strong> (<em>Character</em>) The attacking party.</p></li>
<li><p><strong>defender</strong> (<em>Character</em>) The one defending.</p></li>
<li><p><strong>attack_type</strong> (<em>str</em>) Which ability to use in the attack, like strength or willpower.
Minimum is always 1.</p></li>
<li><p><strong>defense_type</strong> (<em>str</em>) Which ability to defend with, in addition to armor.
Minimum is always 11 (bonus + 10 is always the defense in _Knave_).</p></li>
<li><p><strong>advantage</strong> (<em>bool</em>) Roll 2d20 and use the bigger number.</p></li>
<li><p><strong>disadvantage</strong> (<em>bool</em>) Roll 2d20 and use the smaller number.</p></li>
<li><p><strong>modifier</strong> (<em>int</em>) An additional +/- modifier to the roll.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><p><em>tuple</em> </p>
<dl class="simple">
<dt>(bool, str, str): If the attack succeed or not. The second element is the</dt><dd><p>quality of the roll - None (normal), “critical fail” and “critical success”. Last
element is a text that summarizes the details of the roll.</p>
</dd>
</dl>
</p>
</dd>
</dl>
<p class="rubric">Notes</p>
<p>Advantage and disadvantage cancel each other out.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll_random_table">
<code class="sig-name descname">roll_random_table</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">dieroll</span></em>, <em class="sig-param"><span class="n">table_choices</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.roll_random_table"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll_random_table" title="Permalink to this definition"></a></dt>
<dd><p>Make a roll on a random table.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>dieroll</strong> (<em>str</em>) The dice to roll, like 1d6, 1d20, 3d6 etc).</p></li>
<li><p><strong>table_choices</strong> (<em>iterable</em>) If a list of single elements, the die roll
should fully encompass the table, like a 1d20 roll for a table
with 20 elements. If each element is a tuple, the first element
of the tuple is assumed to be a string X-Y indicating the
range of values that should match the roll.</p></li>
</ul>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><em>Any</em> The result of the random roll.</p>
</dd>
</dl>
<p class="rubric">Example</p>
<p><strong>roll table_choices = [(1-5, “Blue”), (6-9: “Red”), (10, “Purple”)]</strong></p>
<p class="rubric">Notes</p>
<p>If the roll is outside of the listing, the closest edge value is used.</p>
</dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.morale_check">
<code class="sig-name descname">morale_check</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">defender</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.morale_check"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.morale_check" title="Permalink to this definition"></a></dt>
<dd><p>A morale check is done for NPCs/monsters. Its done with a 2d6 against
their morale.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>defender</strong> (<em>NPC</em>) The entity trying to defend its morale.</p>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><p><em>bool</em> False if morale roll failed, True otherwise.</p>
</dd>
</dl>
</dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.heal_from_rest">
<code class="sig-name descname">heal_from_rest</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">character</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.heal_from_rest"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.heal_from_rest" title="Permalink to this definition"></a></dt>
<dd><p>A meal and a full nights rest allow for regaining 1d8 + Const bonus HP.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><p><strong>character</strong> (<em>Character</em>) The one resting.</p>
</dd>
</dl>
</dd></dl>
<dl class="py attribute">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.death_map">
<code class="sig-name descname">death_map</code><em class="property"> = {'addled': 'intelligence', 'disfigured': 'charisma', 'rattled': 'wisdom', 'sickly': 'constitution', 'unsteady': 'dexterity', 'weakened': 'strength'}</em><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.death_map" title="Permalink to this definition"></a></dt>
<dd></dd></dl>
<dl class="py method">
<dt id="evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll_death">
<code class="sig-name descname">roll_death</code><span class="sig-paren">(</span><em class="sig-param"><span class="n">character</span></em><span class="sig-paren">)</span><a class="reference internal" href="../_modules/evennia/contrib/tutorials/evadventure/rules.html#EvAdventureRollEngine.roll_death"><span class="viewcode-link">[source]</span></a><a class="headerlink" href="#evennia.contrib.tutorials.evadventure.rules.EvAdventureRollEngine.roll_death" title="Permalink to this definition"></a></dt>
<dd><p>Happens when hitting &lt;= 0 hp. unless dead,</p>
</dd></dl>
</dd></dl>
</section>
</div>
</div>
</div>
</div>
<div class="related" role="navigation" aria-label="related navigation">
<h3>Navigation</h3>
<ul>
<li class="right" style="margin-right: 10px">
<a href="../genindex.html" title="General Index"
>index</a></li>
<li class="right" >
<a href="../py-modindex.html" title="Python Module Index"
>modules</a> |</li>
<li class="right" >
<a href="evennia.contrib.tutorials.evadventure.shops.html" title="evennia.contrib.tutorials.evadventure.shops"
>next</a> |</li>
<li class="right" >
<a href="evennia.contrib.tutorials.evadventure.rooms.html" title="evennia.contrib.tutorials.evadventure.rooms"
>previous</a> |</li>
2023-10-19 20:22:27 +00:00
<li class="nav-item nav-item-0"><a href="../index.html">Evennia 2.x</a> &#187;</li>
2023-06-10 08:55:41 +02:00
<li class="nav-item nav-item-1"><a href="../Evennia-API.html" >API Summary</a> &#187;</li>
<li class="nav-item nav-item-2"><a href="evennia-api.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-3"><a href="evennia.html" >evennia</a> &#187;</li>
<li class="nav-item nav-item-4"><a href="evennia.contrib.html" >evennia.contrib</a> &#187;</li>
<li class="nav-item nav-item-5"><a href="evennia.contrib.tutorials.html" >evennia.contrib.tutorials</a> &#187;</li>
<li class="nav-item nav-item-6"><a href="evennia.contrib.tutorials.evadventure.html" >evennia.contrib.tutorials.evadventure</a> &#187;</li>
<li class="nav-item nav-item-this"><a href="">evennia.contrib.tutorials.evadventure.rules</a></li>
</ul>
</div>
2023-10-19 20:22:27 +00:00
2023-06-10 08:55:41 +02:00
<div class="footer" role="contentinfo">
2023-10-19 20:22:27 +00:00
&#169; Copyright 2023, The Evennia developer community.
2023-06-10 08:55:41 +02:00
Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.2.1.
</div>
</body>
</html>