profectus-docs/assets/api_modules_features_common.md.9e7d2a43.js

4 lines
12 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import{_ as e,c as t,o as a,N as o}from"./chunks/framework.0799945b.js";const m=JSON.parse('{"title":"Module: features/decorators/common","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/features/common.md","lastUpdated":null}'),r={name:"api/modules/features/common.md"},c=o(`<h1 id="module-features-decorators-common" tabindex="-1">Module: features/decorators/common <a class="header-anchor" href="#module-features-decorators-common" aria-label="Permalink to &quot;Module: features/decorators/common&quot;"></a></h1><h2 id="interfaces" tabindex="-1">Interfaces <a class="header-anchor" href="#interfaces" aria-label="Permalink to &quot;Interfaces&quot;"></a></h2><h3 id="effectfeatureoptions" tabindex="-1">EffectFeatureOptions <a class="header-anchor" href="#effectfeatureoptions" aria-label="Permalink to &quot;EffectFeatureOptions&quot;"></a></h3><p>• <strong>EffectFeatureOptions</strong>: <code>Object</code></p><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>effect</code></td><td style="text-align:left;"><code>any</code></td></tr></tbody></table><h4 id="defined-in" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c9ca859/src/features/decorators/common.ts#L14" target="_blank" rel="noreferrer">profectus/src/features/decorators/common.ts:14</a></p><h2 id="type-aliases" tabindex="-1">Type Aliases <a class="header-anchor" href="#type-aliases" aria-label="Permalink to &quot;Type Aliases&quot;"></a></h2><h3 id="decorator" tabindex="-1">Decorator <a class="header-anchor" href="#decorator" aria-label="Permalink to &quot;Decorator&quot;"></a></h3><p>Ƭ <strong>Decorator</strong>&lt;<code>FeatureOptions</code>, <code>BaseFeature</code>, <code>GenericFeature</code>, <code>S</code>&gt;: <code>Object</code></p><h4 id="type-parameters" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters" aria-label="Permalink to &quot;Type parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>FeatureOptions</code></td><td style="text-align:left;"><code>FeatureOptions</code></td></tr><tr><td style="text-align:left;"><code>BaseFeature</code></td><td style="text-align:left;"><code>object</code></td></tr><tr><td style="text-align:left;"><code>GenericFeature</code></td><td style="text-align:left;"><code>BaseFeature</code></td></tr><tr><td style="text-align:left;"><code>S</code></td><td style="text-align:left;">extends <a href="./../game/persistence#state"><code>State</code></a> = <a href="./../game/persistence#state"><code>State</code></a></td></tr></tbody></table><h4 id="type-declaration" tabindex="-1">Type declaration <a class="header-anchor" href="#type-declaration" aria-label="Permalink to &quot;Type declaration&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>getGatheredProps?</code></td><td style="text-align:left;">(<code>feature</code>: <a href="./feature#optionsobject"><code>OptionsObject</code></a>&lt;<code>FeatureOptions</code>, <code>BaseFeature</code> &amp; { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>&gt;) =&gt; <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype" target="_blank" rel="noreferrer"><code>Partial</code></a>&lt;<a href="./feature#optionsobject"><code>OptionsObject</code></a>&lt;<code>FeatureOptions</code>, <code>BaseFeature</code> &amp; { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>&gt;&gt;</td></tr><tr><td style="text-align:left;"><code>getPersistentData?</code></td><td style="text-align:left;">() =&gt; <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a>&lt;<code>string</code>, <a href="./../game/persistence#persistent"><code>Persistent</code></a>&lt;<code>S</code>&gt;&gt;</td></tr><tr><td style="text-align:left;"><code>postConstruct?</code></td><td style="text-align:left;">(<code>feature</code>: <a href="./feature#optionsobject"><code>OptionsObject</code></a>&lt;<code>FeatureOptions</code>, <code>BaseFeature</code> &amp; { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>&gt;) =&gt; <code>void</code></td></tr><tr><td style="text-align:left;"><code>preConstruct?</code></td><td style="text-align:left;">(<code>feature</code>: <a href="./feature#optionsobject"><code>OptionsObject</code></a>&lt;<code>FeatureOptions</code>, <code>BaseFeature</code> &amp; { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>&gt;) =&gt; <code>void</code></td></tr></tbody></table><h4 id="defined-in-1" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-1" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c9ca859/src/features/decorators/common.ts#L5" target="_blank" rel="noreferrer">profectus/src/features/decorators/common.ts:5</a></p><hr><h3 id="effectfeature" tabindex="-1">EffectFeature <a class="header-anchor" href="#effectfeature" aria-label="Permalink to &quot;EffectFeature&quot;"></a></h3><p>Ƭ <strong>EffectFeature</strong>&lt;<code>T</code>&gt;: <a href="./feature#replace"><code>Replace</code></a>&lt;<code>T</code>, { <code>effect</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a>&lt;<code>T</code>[<code>&quot;effect&quot;</code>]&gt; }&gt;</p><h4 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-label="Permalink to &quot;Type parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th></tr></thead><tbody><tr><td style="text-align:left;"><code>T</code></td><td style="text-align:left;">extends <a href="./common#effectfeatureoptions"><code>EffectFeatureOptions</code></a></td></tr></tbody></table><h4 id="defined-in-2" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-2" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c9ca859/src/features/decorators/common.ts#L18" target="_blank" rel="noreferrer">profectus/src/features/decorators/common.ts:18</a></p><hr><h3 id="genericdecorator" tabindex="-1">GenericDecorator <a class="header-anchor" href="#genericdecorator" aria-label="Permalink to &quot;GenericDecorator&quot;"></a></h3><p>Ƭ <strong>GenericDecorator</strong>: <a href="./common#decorator"><code>Decorator</code></a>&lt;<code>unknown</code>&gt;</p><h4 id="defined-in-3" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-3" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c9ca859/src/features/decorators/common.ts#L12" target="_blank" rel="noreferrer">profectus/src/features/decorators/common.ts:12</a></p><hr><h3 id="genericeffectfeature" tabindex="-1">GenericEffectFeature <a class="header-anchor" href="#genericeffectfeature" aria-label="Permalink to &quot;GenericEffectFeature&quot;"></a></h3><p>Ƭ <strong>GenericEffectFeature</strong>: <a href="./feature#replace"><code>Replace</code></a>&lt;<a href="./common#effectfeature"><code>EffectFeature</code></a>&lt;<a href="./common#effectfeatureoptions"><code>EffectFeatureOptions</code></a>&gt;, { <code>effect</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a>&lt;<code>any</code>&gt; }&gt;</p><h4 id="defined-in-4" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-4" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c9ca859/src/features/decorators/common.ts#L22" target="_blank" rel="noreferrer">profectus/src/features/decorators/common.ts:22</a></p><h2 id="variables" tabindex="-1">Variables <a class="header-anchor" href="#variables" aria-label="Permalink to &quot;Variables&quot;"></a></h2><h3 id="effectdecorator" tabindex="-1">effectDecorator <a class="header-anchor" href="#effectdecorator" aria-label="Permalink to &quot;effectDecorator&quot;"></a></h3><p>• <code>Const</code> <strong>effectDecorator</strong>: <a href="./common#decorator"><code>Decorator</code></a>&lt;<a href="./common#effectfeatureoptions"><code>EffectFeatureOptions</code></a>, <code>unknown</code>, <a href="./common#genericeffectfeature"><code>GenericEffectFeature</code></a>&gt;</p><p>Allows the usage of an <code>effect</code> field in the decorated feature.<br> To function properly, the <code>createFeature()</code> function must have its generic type extended by <a href="./common#effectfeatureoptions"><code>EffectFeatureOptions</code></a>.<br> To allow access to the decorated values outside the <code>createFeature()</code> function, the output type must be extended by <a href="./common#genericeffectfeature"><code>GenericEffectFeature</code></a>.</p><p><strong><code>Example</code></strong></p><div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#82AAFF;">createRepeatable</span><span style="color:#89DDFF;">&lt;</span><span style="color:#FFCB6B;">RepeatableOptions</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">EffectFeatureOptions</span><span style="color:#89DDFF;">&gt;</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">()</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=&gt;</span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">effect</span><span style="color:#89DDFF;">()</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;font-style:italic;">return</span><span style="color:#F07178;"> </span><span style="color:#A6ACCD;">Decimal</span><span style="color:#89DDFF;">.</span><span style="color:#82AAFF;">pow</span><span style="color:#F07178;">(</span><span style="color:#F78C6C;">2</span><span style="color:#89DDFF;">,</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">this.</span><span style="color:#A6ACCD;">amount</span><span style="color:#F07178;">)</span><span style="color:#89DDFF;">;</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">...</span></span>
<span class="line"><span style="color:#89DDFF;">}</span><span style="color:#A6ACCD;">)</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> effectDecorator) </span><span style="color:#89DDFF;font-style:italic;">as</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">GenericUpgrade</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&amp;</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">GenericEffectFeature</span><span style="color:#89DDFF;">;</span></span></code></pre></div><h4 id="defined-in-5" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-5" aria-label="Permalink to &quot;Defined in&quot;"></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c9ca859/src/features/decorators/common.ts#L38" target="_blank" rel="noreferrer">profectus/src/features/decorators/common.ts:38</a></p>`,41),s=[c];function n(d,l,i,p,f,u){return a(),t("div",null,s)}const y=e(r,[["render",n]]);export{m as __pageData,y as default};