<spanid="evennia-contrib-rpg-dice-dice"></span><h1>evennia.contrib.rpg.dice.dice<aclass="headerlink"href="#module-evennia.contrib.rpg.dice.dice"title="Permalink to this headline">¶</a></h1>
<sectionid="dice">
<h2>Dice<aclass="headerlink"href="#dice"title="Permalink to this headline">¶</a></h2>
<p>Rolls dice for roleplaying, in-game gambling or GM:ing</p>
<codeclass="sig-prename descclassname">evennia.contrib.rpg.dice.dice.</code><codeclass="sig-name descname">roll</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">dicenum</span></em>, <emclass="sig-param"><spanclass="n">dicetype</span></em>, <emclass="sig-param"><spanclass="n">modifier</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">conditional</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">return_tuple</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/dice/dice.html#roll"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.roll"title="Permalink to this definition">¶</a></dt>
<dd><p>This is a standard dice roller.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>dicenum</strong> (<em>int</em>) – Number of dice to roll (the result to be added).</p></li>
<li><p><strong>dicetype</strong> (<em>int</em>) – Number of sides of the dice to be rolled.</p></li>
<li><p><strong>modifier</strong> (<em>tuple</em>) – A tuple <strong>(operator, value)</strong>, where operator is
one of <strong>“+”</strong>, <strong>“-”</strong>, <strong>“/”</strong> or <strong>“*”</strong>. The result of the dice
roll(s) will be modified by this value.</p></li>
<li><p><strong>conditional</strong> (<em>tuple</em>) – A tuple <strong>(conditional, value)</strong>, where
conditional is one of <strong>“==”</strong>,**”<”<strong>,</strong>”>”<strong>,</strong>”>=”<strong>,</strong>”<=**” or “<strong>!=</strong>”.
This allows the roller to directly return a result depending
on if the conditional was passed or not.</p></li>
<li><p><strong>return_tuple</strong> (<em>bool</em>) – Return a tuple with all individual roll
<dt>The result of the roll + modifiers. This is the</dt><dd><p>default return.</p>
</dd>
<dt>condition_result (bool): A True/False value returned if <strong>conditional</strong></dt><dd><p>is set but not <strong>return_tuple</strong>. This effectively hides the result
of the roll.</p>
</dd>
<dt>full_result (tuple): If, return_tuple** is <strong>True</strong>, instead</dt><dd><p>return a tuple <strong>(result, outcome, diff, rolls)</strong>. Here,
<strong>result</strong> is the normal result of the roll + modifiers.
<strong>outcome</strong> and <strong>diff</strong> are the boolean result of the roll and
absolute difference to the <strong>conditional</strong> input; they will
be will be <strong>None</strong> if <strong>conditional</strong> is not set. <strong>rolls</strong> is
itself a tuple holding all the individual rolls in the case of
multiple die-rolls.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>TypeError if non-supported modifiers</strong><strong> or </strong><strong>conditionals are given.</strong>–</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>All input numbers are converted to integers.</p>
<pclass="rubric">Examples</p>
<p>print roll_dice(2, 6) # 2d6
<<< 7
print roll_dice(1, 100, (‘+’, 5) # 1d100 + 5
<<< 34
print roll_dice(1, 20, conditional=(‘<’, 10) # let’say we roll 3
<codeclass="sig-prename descclassname">evennia.contrib.rpg.dice.dice.</code><codeclass="sig-name descname">roll_dice</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">dicenum</span></em>, <emclass="sig-param"><spanclass="n">dicetype</span></em>, <emclass="sig-param"><spanclass="n">modifier</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">conditional</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">return_tuple</span><spanclass="o">=</span><spanclass="default_value">False</span></em><spanclass="sig-paren">)</span><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.roll_dice"title="Permalink to this definition">¶</a></dt>
<li><p><strong>conditional</strong> (<em>tuple</em>) – A tuple <strong>(conditional, value)</strong>, where
conditional is one of <strong>“==”</strong>,**”<”<strong>,</strong>”>”<strong>,</strong>”>=”<strong>,</strong>”<=**” or “<strong>!=</strong>”.
This allows the roller to directly return a result depending
on if the conditional was passed or not.</p></li>
<li><p><strong>return_tuple</strong> (<em>bool</em>) – Return a tuple with all individual roll
<dt>The result of the roll + modifiers. This is the</dt><dd><p>default return.</p>
</dd>
<dt>condition_result (bool): A True/False value returned if <strong>conditional</strong></dt><dd><p>is set but not <strong>return_tuple</strong>. This effectively hides the result
of the roll.</p>
</dd>
<dt>full_result (tuple): If, return_tuple** is <strong>True</strong>, instead</dt><dd><p>return a tuple <strong>(result, outcome, diff, rolls)</strong>. Here,
<strong>result</strong> is the normal result of the roll + modifiers.
<strong>outcome</strong> and <strong>diff</strong> are the boolean result of the roll and
absolute difference to the <strong>conditional</strong> input; they will
be will be <strong>None</strong> if <strong>conditional</strong> is not set. <strong>rolls</strong> is
itself a tuple holding all the individual rolls in the case of
multiple die-rolls.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><strong>TypeError if non-supported modifiers</strong><strong> or </strong><strong>conditionals are given.</strong>–</p>
</dd>
</dl>
<pclass="rubric">Notes</p>
<p>All input numbers are converted to integers.</p>
<pclass="rubric">Examples</p>
<p>print roll_dice(2, 6) # 2d6
<<< 7
print roll_dice(1, 100, (‘+’, 5) # 1d100 + 5
<<< 34
print roll_dice(1, 20, conditional=(‘<’, 10) # let’say we roll 3
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.dice.dice.</code><codeclass="sig-name descname">CmdDice</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/rpg/dice/dice.html#CmdDice"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">key</code><emclass="property"> = 'dice'</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.key"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">aliases</code><emclass="property"> = ['roll', '@dice']</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.aliases"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">locks</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.locks"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/rpg/dice/dice.html#CmdDice.func"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.func"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">help_category</code><emclass="property"> = 'general'</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.help_category"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">lock_storage</code><emclass="property"> = 'cmd:all()'</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.lock_storage"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">search_index_entry</code><emclass="property"> = {'aliases': 'roll @dice', 'category': 'general', 'key': 'dice', 'no_prefix': ' roll dice', 'tags': '', 'text': "\n roll dice\n\n Usage:\n dice[/switch] <nr>d<sides> [modifier] [success condition]\n\n Switch:\n hidden - tell the room the roll is being done, but don't show the result\n secret - don't inform the room about neither roll nor result\n\n Examples:\n dice 3d6 + 4\n dice 1d100 - 2 < 50\n\n This will roll the given number of dice with given sides and modifiers.\n So e.g. 2d6 + 3 means to 'roll a 6-sided die 2 times and add the result,\n then add 3 to the total'.\n Accepted modifiers are +, -, * and /.\n A success condition is given as normal Python conditionals\n (<,>,<=,>=,==,!=). So e.g. 2d6 + 3 > 10 means that the roll will succeed\n only if the final result is above 8. If a success condition is given, the\n outcome (pass/fail) will be echoed along with how much it succeeded/failed\n with. The hidden/secret switches will hide all or parts of the roll from\n everyone but the person rolling.\n "}</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.CmdDice.search_index_entry"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.dice.dice.</code><codeclass="sig-name descname">DiceCmdSet</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/rpg/dice/dice.html#DiceCmdSet"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.DiceCmdSet"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/rpg/dice/dice.html#DiceCmdSet.at_cmdset_creation"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.DiceCmdSet.at_cmdset_creation"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">path</code><emclass="property"> = 'evennia.contrib.rpg.dice.dice.DiceCmdSet'</em><aclass="headerlink"href="#evennia.contrib.rpg.dice.dice.DiceCmdSet.path"title="Permalink to this definition">¶</a></dt>