Updated HTML docs.

This commit is contained in:
Evennia docbuilder action 2022-12-03 12:50:01 +00:00
parent 4cd97e630f
commit 95f8ceb5c1
45 changed files with 169 additions and 160 deletions

View file

@ -242,10 +242,7 @@ You can't get that.
</pre></div>
</div>
<p>Think this default error message looks dull? The <code class="docutils literal notranslate"><span class="pre">get</span></code> command looks for an <a class="reference internal" href="../../../Components/Attributes.html"><span class="doc std std-doc">Attribute</span></a>
named <code class="docutils literal notranslate"><span class="pre">get_err_msg</span></code> for returning a nicer error message (we just happen to know this, you would need
to peek into the
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/commands/default/general.py#L235">code</a> for
the <code class="docutils literal notranslate"><span class="pre">get</span></code> command to find out.). You set attributes using the <code class="docutils literal notranslate"><span class="pre">set</span></code> command:</p>
named <code class="docutils literal notranslate"><span class="pre">get_err_msg</span></code> for returning a nicer error messageod (this can be seen from the default <code class="docutils literal notranslate"><span class="pre">get</span></code> command code). You set attributes using the <code class="docutils literal notranslate"><span class="pre">set</span></code> command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>set box/get_err_msg = It&#39;s way too heavy for you to lift.
</pre></div>
</div>

View file

@ -174,7 +174,7 @@ Django parlance). You can specify such places in your settings (see the <code cl
<p>When you enter the address <code class="docutils literal notranslate"><span class="pre">http://localhost:4001/story</span></code> in your web browser, Django will parse that
field to figure out which page you want to go to. You tell it which patterns are relevant in the
file
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/game_template/web/urls.py">mygame/web/urls.py</a>.
<a class="reference external" href="https://github.com/evennia/evennia/blob/main/evennia/game_template/web/urls.py">mygame/web/urls.py</a>.
Open it now</p>
<p>Django looks for the variable <code class="docutils literal notranslate"><span class="pre">urlpatterns</span></code> in this file. You want to add your new pattern to the
<code class="docutils literal notranslate"><span class="pre">custom_patterns</span></code> list we have prepared - that is then merged with the default <code class="docutils literal notranslate"><span class="pre">urlpatterns</span></code>. Heres

View file

@ -152,15 +152,8 @@ values for Health, a list of skills etc, store those things on the Character - d
roll or change them.</p></li>
<li><p>Next is to determine just how you want to store things on your Objects and Characters. You can
choose to either store things as individual <a class="reference internal" href="../Components/Attributes.html"><span class="doc std std-doc">Attributes</span></a>, like <code class="docutils literal notranslate"><span class="pre">character.db.STR=34</span></code> and
<code class="docutils literal notranslate"><span class="pre">character.db.Hunting_skill=20</span></code>. But you could also use some custom storage method, like a
dictionary <code class="docutils literal notranslate"><span class="pre">character.db.skills</span> <span class="pre">=</span> <span class="pre">{&quot;Hunting&quot;:34,</span> <span class="pre">&quot;Fishing&quot;:20,</span> <span class="pre">...}</span></code>. A much more fancy solution is
to look at the Ainneve <a class="reference external" href="https://github.com/evennia/ainneve/blob/master/world/traits.py">Trait
handler</a>. Finally you could even go
with a <a class="reference internal" href="../Concepts/Models.html"><span class="doc std std-doc">custom django model</span></a>. Which is the better depends on your game and the
complexity of your system.</p></li>
<li><p>Make a clear <a class="reference external" href="https://en.wikipedia.org/wiki/Application_programming_interface">API</a> into your
rules. That is, make methods/functions that you feed with, say, your Character and which skill you
want to check. That is, you want something similar to this:</p>
<code class="docutils literal notranslate"><span class="pre">character.db.Hunting_skill=20</span></code>. But you could also use some custom storage method, like a dictionary <code class="docutils literal notranslate"><span class="pre">character.db.skills</span> <span class="pre">=</span> <span class="pre">{&quot;Hunting&quot;:34,</span> <span class="pre">&quot;Fishing&quot;:20,</span> <span class="pre">...}</span></code>. A much more fancy solution is to look at the <a class="reference internal" href="../Contribs/Contrib-Traits.html"><span class="doc std std-doc">Trait handler contrib</span></a>. Finally you could even go with a <a class="reference internal" href="../Concepts/Models.html"><span class="doc std std-doc">custom django model</span></a>. Which is the better depends on your game and the complexity of your system.</p></li>
<li><p>Make a clear <a class="reference external" href="https://en.wikipedia.org/wiki/Application_programming_interface">API</a> into your rules. That is, make methods/functions that you feed with, say, your Character and which skill you want to check. That is, you want something similar to this:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span> <span class="kn">from</span> <span class="nn">world</span> <span class="kn">import</span> <span class="n">rules</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rules</span><span class="o">.</span><span class="n">roll_skill</span><span class="p">(</span><span class="n">character</span><span class="p">,</span> <span class="s2">&quot;hunting&quot;</span><span class="p">)</span>
<span class="n">result</span> <span class="o">=</span> <span class="n">rules</span><span class="o">.</span><span class="n">roll_challenge</span><span class="p">(</span><span class="n">character1</span><span class="p">,</span> <span class="n">character2</span><span class="p">,</span> <span class="s2">&quot;swords&quot;</span><span class="p">)</span>
@ -172,8 +165,7 @@ want to check. That is, you want something similar to this:</p>
</section>
<section id="coded-systems">
<h2>Coded systems<a class="headerlink" href="#coded-systems" title="Permalink to this headline"></a></h2>
<p>Inspired by tabletop role playing games, most game systems mimic some sort of die mechanic. To this end Evennia offers a full <a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/contrib/dice.py">dice roller</a> in its <code class="docutils literal notranslate"><span class="pre">contrib</span></code>
folder. For custom implementations, Python offers many ways to randomize a result using its in-built <code class="docutils literal notranslate"><span class="pre">random</span></code> module. No matter how its implemented, we will in this text refer to the action of determining an outcome as a “roll”.</p>
<p>Inspired by tabletop role playing games, most game systems mimic some sort of die mechanic. To this end Evennia offers a full <a class="reference internal" href="../Contribs/Contrib-Dice.html"><span class="doc std std-doc">dice roller contribution</span></a>. For custom implementations, Python offers many ways to randomize a result using its in-built <code class="docutils literal notranslate"><span class="pre">random</span></code> module. No matter how its implemented, we will in this text refer to the action of determining an outcome as a “roll”.</p>
<p>In a freeform system, the result of the roll is just compared with values and people (or the game
master) just agree on what it means. In a coded system the result now needs to be processed somehow. There are many things that may happen as a result of rule enforcement:</p>
<ul class="simple">

View file

@ -429,19 +429,15 @@ This is a great warrior.
</pre></div>
</div>
<p>We dont actually have to modify the <code class="docutils literal notranslate"><span class="pre">look</span></code> command itself however. To understand why, take a look
at how the default <code class="docutils literal notranslate"><span class="pre">look</span></code> is actually defined. It sits in <code class="docutils literal notranslate"><span class="pre">evennia/commands/default/general.py</span></code> (or
browse it online
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/commands/default/general.py#L44">here</a>).
You will find that the actual return text is done by the <code class="docutils literal notranslate"><span class="pre">look</span></code> command calling a <em>hook method</em>
at how the default <code class="docutils literal notranslate"><span class="pre">look</span></code> is actually defined. It sits in <a class="reference internal" href="../api/evennia.commands.default.general.html#evennia-commands-default-general"><span class="std std-ref">evennia/commands/default/general.py</span></a>.</p>
<p>You will find that the actual return text is done by the <code class="docutils literal notranslate"><span class="pre">look</span></code> command calling a <em>hook method</em>
named <code class="docutils literal notranslate"><span class="pre">return_appearance</span></code> on the object looked at. All the <code class="docutils literal notranslate"><span class="pre">look</span></code> does is to echo whatever this hook
returns. So what we need to do is to edit our custom Character typeclass and overload its
<code class="docutils literal notranslate"><span class="pre">return_appearance</span></code> to return what we want (this is where the advantage of having a custom typeclass
comes into play for real).</p>
<p>Go back to your custom Character typeclass in <code class="docutils literal notranslate"><span class="pre">mygame/typeclasses/characters.py</span></code>. The default
implementation of <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">appearance</span></code> is found in <code class="docutils literal notranslate"><span class="pre">evennia.DefaultCharacter</span></code> (or online
<a class="reference external" href="https://github.com/evennia/evennia/blob/master/evennia/objects/objects.py#L1438">here</a>). If you
want to make bigger changes you could copy &amp; paste the whole default thing into our overloading
method. In our case the change is small though:</p>
implementation of <code class="docutils literal notranslate"><span class="pre">return</span> <span class="pre">appearance</span></code> is found in <a class="reference internal" href="../api/evennia.objects.objects.html#evennia.objects.objects.DefaultCharacter" title="evennia.objects.objects.DefaultCharacter"><span class="xref myst py py-class">evennia.DefaultCharacter</span></a>.</p>
<p>If you want to make bigger changes you could copy &amp; paste the whole default thing into our overloading method. In our case the change is small though:</p>
<div class="highlight-python notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">Character</span><span class="p">(</span><span class="n">DefaultCharacter</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> [...]</span>