<spanid="evennia-contrib-rpg-traits-traits"></span><h1>evennia.contrib.rpg.traits.traits<aclass="headerlink"href="#module-evennia.contrib.rpg.traits.traits"title="Permalink to this headline">¶</a></h1>
<p>Traits</p>
<p>Whitenoise 2014, Ainneve contributors,
Griatch 2020</p>
<p>A <strong>Trait</strong> represents a modifiable property on (usually) a Character. They can
be used to represent everything from attributes (str, agi etc) to skills
(hunting 10, swords 14 etc) and dynamically changing things like HP, XP etc.</p>
<p>Traits use Evennia Attributes under the hood, making them persistent (they survive
a server reload/reboot).</p>
<sectionid="installation">
<h2>Installation<aclass="headerlink"href="#installation"title="Permalink to this headline">¶</a></h2>
<p>Traits are always added to a typeclass, such as the Character class.</p>
<p>There are two ways to set up Traits on a typeclass. The first sets up the <strong>TraitHandler</strong>
as a property <strong>.traits</strong> on your class and you then access traits as e.g. <strong>.traits.strength</strong>.
The other alternative uses a <strong>TraitProperty</strong>, which makes the trait available directly
as e.g. <strong>.strength</strong>. This solution also uses the <strong>TraitHandler</strong>, but you don’t need to
define it explicitly. You can combine both styles if you like.</p>
<sectionid="traits-with-traithandler">
<h3>Traits with TraitHandler<aclass="headerlink"href="#traits-with-traithandler"title="Permalink to this headline">¶</a></h3>
<p>Here’s an example for adding the TraitHandler to the Character class:</p>
<p>> Note that the property-name will become the name of the trait and you don’t supply <strong>trait_key</strong>
> separately.</p>
<p>> The <strong>.traits</strong> TraitHandler will still be created (it’s used under the
> hood. But it will only be created when the TraitProperty has been accessed at least once,
> so be careful if mixing the two styles. If you want to make sure <strong>.traits</strong> is always available,
> add the <strong>TraitHandler</strong> manually like shown earlier - the <strong>TraitProperty</strong> will by default use
> the same handler (<strong>.traits</strong>).</p>
</section>
</section>
<sectionid="using-traits">
<h2>Using traits<aclass="headerlink"href="#using-traits"title="Permalink to this headline">¶</a></h2>
<p>A trait is added to the traithandler (if you use <strong>TraitProperty</strong> the handler is just created under
the hood) after which one can access it as a property on the handler (similarly to how you can do
.db.attrname for Attributes in Evennia).</p>
<p>All traits have a _read-<ahref="#id7"><spanclass="problematic"id="id8">only_</span></a> field <strong>.value</strong>. This is only used to read out results, you never
manipulate it directly (if you try, it will just remain unchanged). The <strong>.value</strong> is calculated based
on combining fields, like <strong>.base</strong> and <strong>.mod</strong> - which fields are available and how they relate to
<p>The keys must be supplied from smallest to largest. Any values below the lowest and above the
highest description will be considered to be included in the closest description slot.
By calling <strong>.desc()</strong> on the Counter, you will get the text matching the current <strong>value</strong>.</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># (could also have passed descs= to traits.add())</span>
<h2>Expanding with your own Traits<aclass="headerlink"href="#expanding-with-your-own-traits"title="Permalink to this headline">¶</a></h2>
<p>A Trait is a class inhering from <strong>evennia.contrib.rpg.traits.Trait</strong> (or from one of
the existing Trait classes).</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="c1"># in a file, say, 'mygame/world/traits.py'</span>
<p>Reload the server and you should now be able to use your trait:</p>
<divclass="highlight-default notranslate"><divclass="highlight"><pre><span></span><spanclass="o">></span><spanclass="n">obj</span><spanclass="o">.</span><spanclass="n">traits</span><spanclass="o">.</span><spanclass="n">add</span><spanclass="p">(</span><spanclass="s2">"mood"</span><spanclass="p">,</span><spanclass="s2">"A dark mood"</span><spanclass="p">,</span><spanclass="n">rage</span><spanclass="o">=</span><spanclass="mi">30</span><spanclass="p">,</span><spanclass="n">trait_type</span><spanclass="o">=</span><spanclass="s1">'rage'</span><spanclass="p">)</span>
<spanclass="n">rage</span><spanclass="o">=</span><spanclass="n">TraitProperty</span><spanclass="p">(</span><spanclass="s2">"A dark mood"</span><spanclass="p">,</span><spanclass="n">rage</span><spanclass="o">=</span><spanclass="mi">30</span><spanclass="p">,</span><spanclass="n">trait_type</span><spanclass="o">=</span><spanclass="s1">'rage'</span><spanclass="p">)</span>
<emclass="property">exception </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">TraitException</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">msg</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitException"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitException"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">msg</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitException.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitException.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize self. See help(type(self)) for accurate signature.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">MandatoryTraitKey</code><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#MandatoryTraitKey"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.MandatoryTraitKey"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">TraitHandler</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">obj</span></em>, <emclass="sig-param"><spanclass="n">db_attribute_key</span><spanclass="o">=</span><spanclass="default_value">'traits'</span></em>, <emclass="sig-param"><spanclass="n">db_attribute_category</span><spanclass="o">=</span><spanclass="default_value">'traits'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">obj</span></em>, <emclass="sig-param"><spanclass="n">db_attribute_key</span><spanclass="o">=</span><spanclass="default_value">'traits'</span></em>, <emclass="sig-param"><spanclass="n">db_attribute_category</span><spanclass="o">=</span><spanclass="default_value">'traits'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the handler and set up its internal Attribute-based storage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>obj</strong> (<em>Object</em>) – Parent Object typeclass for this TraitHandler</p></li>
<li><p><strong>db_attribute_key</strong> (<em>str</em>) – Name of the DB attribute for trait data storage.</p></li>
<li><p><strong>db_attribute_category</strong> (<em>str</em>) – Name of DB attribute’s category to trait data storage.</p></li>
<codeclass="sig-name descname">all</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler.all"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler.all"title="Permalink to this definition">¶</a></dt>
<dd><p>Get all trait keys in this handler.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><em>list</em>– All Trait keys.</p>
<codeclass="sig-name descname">get</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_key</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler.get"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler.get"title="Permalink to this definition">¶</a></dt>
<dd><dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>trait_key</strong> (<em>str</em>) – key from the traits dict containing config data.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p>(<strong>Trait</strong> or <strong>None</strong>) – named Trait class or None if trait key
<codeclass="sig-name descname">add</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_key</span></em>, <emclass="sig-param"><spanclass="n">name</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">trait_type</span><spanclass="o">=</span><spanclass="default_value">'static'</span></em>, <emclass="sig-param"><spanclass="n">force</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">trait_properties</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler.add"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler.add"title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new Trait and add it to the handler.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>trait_key</strong> (<em>str</em>) – This is the name of the property that will be made
available on this handler (example ‘hp’).</p></li>
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) – Name of the Trait, like “Health”. If
not given, will use <strong>trait_key</strong> starting with a capital letter.</p></li>
<li><p><strong>trait_type</strong> (<em>str</em><em>, </em><em>optional</em>) – One of ‘static’, ‘counter’ or ‘gauge’.</p></li>
<li><p><strong>force</strong> (<em>bool</em>) – If set, create a new Trait even if a Trait with
the same <strong>trait_key</strong> already exists.</p></li>
<li><p><strong>trait_properties</strong> (<em>dict</em>) – These will all be use to initialize
the new trait. See the <strong>properties</strong> class variable on each
Trait class to see which are required.</p></li>
</ul>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.contrib.rpg.traits.traits.TraitException"title="evennia.contrib.rpg.traits.traits.TraitException"><strong>TraitException</strong></a>– If specifying invalid values for the given Trait,
the <strong>trait_type</strong> is not recognized, or an existing trait
already exists (and <strong>force</strong> is unset).</p>
<codeclass="sig-name descname">remove</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_key</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler.remove"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler.remove"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove a Trait from the handler’s parent object.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>trait_key</strong> (<em>str</em>) – The name of the trait to remove.</p>
<codeclass="sig-name descname">clear</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitHandler.clear"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitHandler.clear"title="Permalink to this definition">¶</a></dt>
<dd><p>Remove all Traits from the handler’s parent object.</p>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">name</span><spanclass="o">=</span><spanclass="default_value">None</span></em>, <emclass="sig-param"><spanclass="n">trait_type</span><spanclass="o">=</span><spanclass="default_value">'static'</span></em>, <emclass="sig-param"><spanclass="n">force</span><spanclass="o">=</span><spanclass="default_value">True</span></em>, <emclass="sig-param"><spanclass="o">**</span><spanclass="n">trait_properties</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#TraitProperty.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.TraitProperty.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize a TraitField. Mimics TraitHandler.add input except no <strong>trait_key</strong>.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><ulclass="simple">
<li><p><strong>name</strong> (<em>str</em><em>, </em><em>optional</em>) – Name of the Trait, like “Health”. If
not given, will use <strong>trait_key</strong> starting with a capital letter.</p></li>
<li><p><strong>trait_type</strong> (<em>str</em><em>, </em><em>optional</em>) – One of ‘static’, ‘counter’ or ‘gauge’.</p></li>
<li><p><strong>force</strong> (<em>bool</em>) – If set, create a new Trait even if a Trait with
the same <strong>trait_key</strong> already exists.</p></li>
</ul>
</dd>
</dl>
<dlclass="simple">
<dt>Kwargs:</dt><dd><dlclass="simple">
<dt>traithandler_name (str): If given, this is used as the name of the TraitHandler created</dt><dd><p>behind the scenes. If not set, this will be a property <strong>traits</strong> on the class.</p>
</dd>
<dt>any: All other trait_properties are the same as for adding a new trait of the given type</dt><dd><p>using the normal TraitHandler.</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</dd></dl>
<dlclass="py class">
<dtid="evennia.contrib.rpg.traits.traits.Trait">
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">Trait</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#Trait"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">trait_type</code><emclass="property"> = 'trait'</em><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.trait_type"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">default_keys</code><emclass="property"> = {'value': None}</em><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.default_keys"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">allow_extra_properties</code><emclass="property"> = True</em><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.allow_extra_properties"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">__init__</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#Trait.__init__"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.__init__"title="Permalink to this definition">¶</a></dt>
<dd><p>This both initializes and validates the Trait on creation. It must
raise exception if validation fails. The TraitHandler will call this
when the trait is furst added, to make sure it validates before
storing.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>trait_data</strong> (<em>any</em>) – Any pickle-able values to store with this trait.
This must contain any cls.default_keys that do not have a default
value in cls.data_default_values. Any extra kwargs will be made
available as extra properties on the Trait, assuming the class
variable <strong>allow_extra_properties</strong> is set.</p>
</dd>
<dtclass="field-even">Raises</dt>
<ddclass="field-even"><p><aclass="reference internal"href="#evennia.contrib.rpg.traits.traits.TraitException"title="evennia.contrib.rpg.traits.traits.TraitException"><strong>TraitException</strong></a>– If input-validation failed.</p>
<emclass="property">static </em><codeclass="sig-name descname">validate_input</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cls</span></em>, <emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#Trait.validate_input"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.validate_input"title="Permalink to this definition">¶</a></dt>
<dd><p>Validate input</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>trait_data</strong> (<em>dict</em><em> or </em><em>_SaverDict</em>) – Data to be used for
initialization of this trait.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>dict</em>–</p>
<dlclass="simple">
<dt>Validated data, possibly complemented with default</dt><dd><p>values from default_keys.</p>
</dd>
</dl>
</p>
</dd>
<dtclass="field-odd">Raises</dt>
<ddclass="field-odd"><p><aclass="reference internal"href="#evennia.contrib.rpg.traits.traits.TraitException"title="evennia.contrib.rpg.traits.traits.TraitException"><strong>TraitException</strong></a>– If finding unset keys without a default.</p>
<emclass="property">property </em><codeclass="sig-name descname">name</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.name"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">key</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.key"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">value</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.Trait.value"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">StaticTrait</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#StaticTrait"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.StaticTrait"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">trait_type</code><emclass="property"> = 'static'</em><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.StaticTrait.trait_type"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">base</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.StaticTrait.base"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">mod</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.StaticTrait.mod"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">mult</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.StaticTrait.mult"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">value</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.StaticTrait.value"title="Permalink to this definition">¶</a></dt>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">CounterTrait</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#CounterTrait"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">trait_type</code><emclass="property"> = 'counter'</em><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.trait_type"title="Permalink to this definition">¶</a></dt>
<emclass="property">static </em><codeclass="sig-name descname">validate_input</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">cls</span></em>, <emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#CounterTrait.validate_input"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.validate_input"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">base</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.base"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">mod</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.mod"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">mult</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.mult"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">min</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.min"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">max</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.max"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">current</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.current"title="Permalink to this definition">¶</a></dt>
<dd><p>The <strong>current</strong> value of the <strong>Trait</strong>. This does not have .mod added and is not .mult-iplied.</p>
<emclass="property">property </em><codeclass="sig-name descname">value</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.value"title="Permalink to this definition">¶</a></dt>
<dd><p>The value of the Trait. (current + mod) * mult</p>
<emclass="property">property </em><codeclass="sig-name descname">ratetarget</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.ratetarget"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">percent</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">formatting</span><spanclass="o">=</span><spanclass="default_value">'{:3.1f}%'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#CounterTrait.percent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.percent"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current value as a percentage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>formatting</strong> (<em>str</em><em>, </em><em>optional</em>) – Should contain a
format-tag which will receive the value. If
this is set to None, the raw float will be
returned.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>float or str</em>–</p>
<dlclass="simple">
<dt>Depending of if a <strong>formatting</strong> string</dt><dd><p>is supplied or not.</p>
<codeclass="sig-name descname">reset</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#CounterTrait.reset"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.reset"title="Permalink to this definition">¶</a></dt>
<dd><p>Resets <strong>current</strong> property equal to <strong>base</strong> value.</p>
<codeclass="sig-name descname">desc</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#CounterTrait.desc"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.CounterTrait.desc"title="Permalink to this definition">¶</a></dt>
<dd><p>Retrieve descriptions of the current value, if available.</p>
<p>This must be a mapping {upper_bound_inclusive: text},
ordered from small to big. Any value above the highest
upper bound will be included as being in the highest bound.
rely on Python3.7+ dicts retaining ordering to let this
describe the interval.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Returns</dt>
<ddclass="field-odd"><p><p><em>str</em>–</p>
<dlclass="simple">
<dt>The description describing the <strong>value</strong> value.</dt><dd><p>If not found, returns the empty string.</p>
<emclass="property">class </em><codeclass="sig-prename descclassname">evennia.contrib.rpg.traits.traits.</code><codeclass="sig-name descname">GaugeTrait</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">trait_data</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#GaugeTrait"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">trait_type</code><emclass="property"> = 'gauge'</em><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.trait_type"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">base</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.base"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">mod</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.mod"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">mult</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.mult"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">min</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.min"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">max</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.max"title="Permalink to this definition">¶</a></dt>
<emclass="property">property </em><codeclass="sig-name descname">current</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.current"title="Permalink to this definition">¶</a></dt>
<dd><p>The <strong>current</strong> value of the gauge.</p>
<emclass="property">property </em><codeclass="sig-name descname">value</code><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.value"title="Permalink to this definition">¶</a></dt>
<codeclass="sig-name descname">percent</code><spanclass="sig-paren">(</span><emclass="sig-param"><spanclass="n">formatting</span><spanclass="o">=</span><spanclass="default_value">'{:3.1f}%'</span></em><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#GaugeTrait.percent"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.percent"title="Permalink to this definition">¶</a></dt>
<dd><p>Return the current value as a percentage.</p>
<dlclass="field-list simple">
<dtclass="field-odd">Parameters</dt>
<ddclass="field-odd"><p><strong>formatting</strong> (<em>str</em><em>, </em><em>optional</em>) – Should contain a
format-tag which will receive the value. If
this is set to None, the raw float will be
returned.</p>
</dd>
<dtclass="field-even">Returns</dt>
<ddclass="field-even"><p><p><em>float or str</em>–</p>
<dlclass="simple">
<dt>Depending of if a <strong>formatting</strong> string</dt><dd><p>is supplied or not.</p>
<codeclass="sig-name descname">reset</code><spanclass="sig-paren">(</span><spanclass="sig-paren">)</span><aclass="reference internal"href="../_modules/evennia/contrib/rpg/traits/traits.html#GaugeTrait.reset"><spanclass="viewcode-link">[source]</span></a><aclass="headerlink"href="#evennia.contrib.rpg.traits.traits.GaugeTrait.reset"title="Permalink to this definition">¶</a></dt>
<dd><p>Fills the gauge to its maximum allowed by base + mod</p>