4 lines
12 KiB
JavaScript
4 lines
12 KiB
JavaScript
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 "Module: features/decorators/common""></a></h1><h2 id="interfaces" tabindex="-1">Interfaces <a class="header-anchor" href="#interfaces" aria-label="Permalink to "Interfaces""></a></h2><h3 id="effectfeatureoptions" tabindex="-1">EffectFeatureOptions <a class="header-anchor" href="#effectfeatureoptions" aria-label="Permalink to "EffectFeatureOptions""></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 "Defined in""></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 "Type Aliases""></a></h2><h3 id="decorator" tabindex="-1">Decorator <a class="header-anchor" href="#decorator" aria-label="Permalink to "Decorator""></a></h3><p>Ƭ <strong>Decorator</strong><<code>FeatureOptions</code>, <code>BaseFeature</code>, <code>GenericFeature</code>, <code>S</code>>: <code>Object</code></p><h4 id="type-parameters" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters" aria-label="Permalink to "Type parameters""></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 "Type declaration""></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><<code>FeatureOptions</code>, <code>BaseFeature</code> & { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>>) => <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#partialtype" target="_blank" rel="noreferrer"><code>Partial</code></a><<a href="./feature#optionsobject"><code>OptionsObject</code></a><<code>FeatureOptions</code>, <code>BaseFeature</code> & { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>>></td></tr><tr><td style="text-align:left;"><code>getPersistentData?</code></td><td style="text-align:left;">() => <a href="https://www.typescriptlang.org/docs/handbook/utility-types.html#recordkeys-type" target="_blank" rel="noreferrer"><code>Record</code></a><<code>string</code>, <a href="./../game/persistence#persistent"><code>Persistent</code></a><<code>S</code>>></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><<code>FeatureOptions</code>, <code>BaseFeature</code> & { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>>) => <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><<code>FeatureOptions</code>, <code>BaseFeature</code> & { <code>id</code>: <code>string</code> }, <code>GenericFeature</code>>) => <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 "Defined in""></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 "EffectFeature""></a></h3><p>Ƭ <strong>EffectFeature</strong><<code>T</code>>: <a href="./feature#replace"><code>Replace</code></a><<code>T</code>, { <code>effect</code>: <a href="./../util/computed#getcomputabletype"><code>GetComputableType</code></a><<code>T</code>[<code>"effect"</code>]> }></p><h4 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-label="Permalink to "Type parameters""></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 "Defined in""></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 "GenericDecorator""></a></h3><p>Ƭ <strong>GenericDecorator</strong>: <a href="./common#decorator"><code>Decorator</code></a><<code>unknown</code>></p><h4 id="defined-in-3" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-3" aria-label="Permalink to "Defined in""></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 "GenericEffectFeature""></a></h3><p>Ƭ <strong>GenericEffectFeature</strong>: <a href="./feature#replace"><code>Replace</code></a><<a href="./common#effectfeature"><code>EffectFeature</code></a><<a href="./common#effectfeatureoptions"><code>EffectFeatureOptions</code></a>>, { <code>effect</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<code>any</code>> }></p><h4 id="defined-in-4" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-4" aria-label="Permalink to "Defined in""></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 "Variables""></a></h2><h3 id="effectdecorator" tabindex="-1">effectDecorator <a class="header-anchor" href="#effectdecorator" aria-label="Permalink to "effectDecorator""></a></h3><p>• <code>Const</code> <strong>effectDecorator</strong>: <a href="./common#decorator"><code>Decorator</code></a><<a href="./common#effectfeatureoptions"><code>EffectFeatureOptions</code></a>, <code>unknown</code>, <a href="./common#genericeffectfeature"><code>GenericEffectFeature</code></a>></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;"><</span><span style="color:#FFCB6B;">RepeatableOptions</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&</span><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">EffectFeatureOptions</span><span style="color:#89DDFF;">></span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">()</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=></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;">&</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 "Defined in""></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};
|