<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>
<p>Evennia contribution - Griatch 2012</p>
<p>This module implements a a dice-roller and a <strong>dice</strong>/<strong>roll</strong> command
to go with it. It uses standard RPG ‘d’-syntax (e.g. 2d6 to roll two
six-sided die) and also supports modifiers such as 3d6 + 5.</p>
<blockquote>
<div><p>> roll 1d20 + 2</p>
</div></blockquote>
<p>One can also specify a standard Python operator in order to specify
eventual target numbers and get results in a fair and guaranteed
unbiased way. For example a GM could (using the dice command) from
the start define the roll as 2d6 < 8 to show that a roll below 8 is
required to succeed. The command will normally echo this result to all
parties (although it also has options for hidden and secret rolls).</p>
</section>
<sectionid="installation">
<h2>Installation:<aclass="headerlink"href="#installation"title="Permalink to this headline">¶</a></h2>
<p>Add the <strong>CmdDice</strong> command from this module to your character’s cmdset
(and then restart the server):</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># in mygame/commands/default_cmdsets.py</span>
<li><p><strong>dice</strong> (<em>int</em><em> or </em><em>str</em>) – If an <strong>int</strong>, this is the number of dice to roll, and <strong>dicetype</strong> is used
to determine the type. If a <strong>str</strong>, it should be on the form <strong>NdM</strong> where <strong>N</strong> is the number
of dice and <strong>M</strong> is the number of sides on each die. Also
<strong>NdM [modifier] [number] [conditional]</strong> is understood, e.g. <strong>1d6 + 3</strong>
or <strong>2d10 / 2 > 10</strong>.</p></li>
<li><p><strong>dicetype</strong> (<em>int</em><em>, </em><em>optional</em>) – Number of sides of the dice to be rolled. Ignored if
<strong>dice</strong> is a string.</p></li>
<li><p><strong>modifier</strong> (<em>tuple</em><em>, </em><em>optional</em>) – A tuple <strong>(operator, value)</strong>, where operator is
conditional is one of <strong>“==”</strong>,**”<”<strong>,</strong>”>”<strong>,</strong>”>=”<strong>,</strong>”<=**” or “<strong>!=</strong>”.
<li><p><strong>dice</strong> (<em>int</em><em> or </em><em>str</em>) – If an <strong>int</strong>, this is the number of dice to roll, and <strong>dicetype</strong> is used
to determine the type. If a <strong>str</strong>, it should be on the form <strong>NdM</strong> where <strong>N</strong> is the number
of dice and <strong>M</strong> is the number of sides on each die. Also
<strong>NdM [modifier] [number] [conditional]</strong> is understood, e.g. <strong>1d6 + 3</strong>
or <strong>2d10 / 2 > 10</strong>.</p></li>
<li><p><strong>dicetype</strong> (<em>int</em><em>, </em><em>optional</em>) – Number of sides of the dice to be rolled. Ignored if
<strong>dice</strong> is a string.</p></li>
<li><p><strong>modifier</strong> (<em>tuple</em><em>, </em><em>optional</em>) – A tuple <strong>(operator, value)</strong>, where operator is
conditional is one of <strong>“==”</strong>,**”<”<strong>,</strong>”>”<strong>,</strong>”>=”<strong>,</strong>”<=**” or “<strong>!=</strong>”.
<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"> = ['@dice', 'roll']</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>
<dd><p>Mostly parsing for calling the dice roller function</p>
<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': '@dice roll', 'category': 'general', 'key': 'dice', 'no_prefix': ' dice roll', '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>