profectus-docs/assets/api_modules_features_conversion.md.1d4a5672.js

1 line
16 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,N as a}from"./chunks/framework.0799945b.js";const m=JSON.parse('{"title":"Module: features/conversion","description":"","frontmatter":{"editLink":false},"headers":[],"relativePath":"api/modules/features/conversion.md","lastUpdated":null}'),r={name:"api/modules/features/conversion.md"},n=a('<h1 id="module-features-conversion" tabindex="-1">Module: features/conversion <a class="header-anchor" href="#module-features-conversion" aria-label="Permalink to &quot;Module: features/conversion&quot;"></a></h1><h2 id="interfaces" tabindex="-1">Interfaces <a class="header-anchor" href="#interfaces" aria-label="Permalink to &quot;Interfaces&quot;"></a></h2><ul><li><a href="../../interfaces/features/conversion.BaseConversion">BaseConversion</a></li><li><a href="../../interfaces/features/conversion.ConversionOptions">ConversionOptions</a></li></ul><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="conversion" tabindex="-1">Conversion <a class="header-anchor" href="#conversion" aria-label="Permalink to &quot;Conversion&quot;"></a></h3><p>Ƭ <strong>Conversion</strong>&lt;<code>T</code>&gt;: <a href="./feature#replace"><code>Replace</code></a>&lt;<code>T</code> &amp; <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, { <code>actualGain</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a>&lt;<code>T</code>[<code>&quot;actualGain&quot;</code>], <code>Ref</code>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt;&gt; ; <code>buyMax</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a>&lt;<code>T</code>[<code>&quot;buyMax&quot;</code>], <code>true</code>&gt; ; <code>currentAt</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a>&lt;<code>T</code>[<code>&quot;currentAt&quot;</code>], <code>Ref</code>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt;&gt; ; <code>currentGain</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a>&lt;<code>T</code>[<code>&quot;currentGain&quot;</code>], <code>Ref</code>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt;&gt; ; <code>formula</code>: <a href="./../game/formulas/types#invertibleformula"><code>InvertibleFormula</code></a> ; <code>nextAt</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a>&lt;<code>T</code>[<code>&quot;nextAt&quot;</code>], <code>Ref</code>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt;&gt; ; <code>spend</code>: <code>undefined</code> extends <code>T</code>[<code>&quot;spend&quot;</code>] ? (<code>amountGained</code>: <a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>) =&gt; <code>void</code> : <code>T</code>[<code>&quot;spend&quot;</code>] }&gt;</p><p>An object that converts one <a href="../../interfaces/features/resources/resource.Resource">Resource</a> into another at a given rate.</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>T</code></td><td style="text-align:left;">extends <a href="../../interfaces/features/conversion.ConversionOptions"><code>ConversionOptions</code></a></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/8c0a0c4/src/features/conversion.ts#L92" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:92</a></p><hr><h3 id="genericconversion" tabindex="-1">GenericConversion <a class="header-anchor" href="#genericconversion" aria-label="Permalink to &quot;GenericConversion&quot;"></a></h3><p>Ƭ <strong>GenericConversion</strong>: <a href="./feature#replace"><code>Replace</code></a>&lt;<a href="./conversion#conversion"><code>Conversion</code></a>&lt;<a href="../../interfaces/features/conversion.ConversionOptions"><code>ConversionOptions</code></a>&gt;, { <code>actualGain</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt; ; <code>buyMax</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a>&lt;<code>boolean</code>&gt; ; <code>currentAt</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt; ; <code>currentGain</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt; ; <code>nextAt</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a>&lt;<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>&gt; ; <code>spend</code>: (<code>amountGained</code>: <a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>) =&gt; <code>void</code> }&gt;</p><p>A type that matches any valid <a href="./conversion#conversion">Conversion</a> object.</p><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/8c0a0c4/src/features/conversion.ts#L106" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:106</a></p><h2 id="functions" tabindex="-1">Functions <a class="header-anchor" href="#functions" aria-label="Permalink to &quot;Functions&quot;"></a></h2><h3 id="createconversion" tabindex="-1">createConversion <a class="header-anchor" href="#createconversion" aria-label="Permalink to &quot;createConversion&quot;"></a></h3><p>▸ <strong>createConversion</strong>&lt;<code>T</code>&gt;(<code>optionsFunc</code>): <a href="./conversion#conversion"><code>Conversion</code></a>&lt;<code>T</code>&gt;</p><p>Lazily creates a conversion with the given options. You typically shouldn&#39;t use this function directly. Instead use one of the other conversion constructors, which will then call this.</p><p><strong><code>See</code></strong></p><ul><li><a href="./conversion#createcumulativeconversion">createCumulativeConversion</a>.</li><li><a href="./conversion#createindependentconversion">createIndependentConversion</a>.</li></ul><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="../../interfaces/features/conversion.ConversionOptions"><code>ConversionOptions</code></a></td></tr></tbody></table><h4 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>optionsFunc</code></td><td style="text-align:left;"><a href="./feature#optionsfunc"><code>OptionsFunc</code></a>&lt;<code>T</code>, <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, <a href="./conversion#genericconversion"><code>GenericConversion</code></a>&gt;</td><td style="text-align:left;">Conversion options.</td></tr></tbody></table><h4 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><a href="./conversion#conversion"><code>Conversion</code></a>&lt;<code>T</code>&gt;</p><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/8c0a0c4/src/features/conversion.ts#L125" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:125</a></p><hr><h3 id="createcumulativeconversion" tabindex="-1">createCumulativeConversion <a class="header-anchor" href="#createcumulativeconversion" aria-label="Permalink to &quot;createCumulativeConversion&quot;"></a></h3><p>▸ <strong>createCumulativeConversion</strong>&lt;<code>S</code>&gt;(<code>optionsFunc</code>): <a href="./conversion#conversion"><code>Conversion</code></a>&lt;<code>S</code>&gt;</p><p>Creates a conversion that simply adds to the gainResource amount upon converting. This is similar to the behavior of &quot;normal&quot; layers in The Modding Tree. This is equivalent to just calling createConversion directly.</p><h4 id="type-parameters-2" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-2" 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>S</code></td><td style="text-align:left;">extends <a href="../../interfaces/features/conversion.ConversionOptions"><code>ConversionOptions</code></a></td></tr></tbody></table><h4 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>optionsFunc</code></td><td style="text-align:left;"><a href="./feature#optionsfunc"><code>OptionsFunc</code></a>&lt;<code>S</code>, <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, <a href="./conversion#genericconversion"><code>GenericConversion</code></a>&gt;</td><td style="text-align:left;">Conversion options.</td></tr></tbody></table><h4 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><a href="./conversion#conversion"><code>Conversion</code></a>&lt;<code>S</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/8c0a0c4/src/features/conversion.ts#L200" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:200</a></p><hr><h3 id="createindependentconversion" tabindex="-1">createIndependentConversion <a class="header-anchor" href="#createindependentconversion" aria-label="Permalink to &quot;createIndependentConversion&quot;"></a></h3><p>▸ <strong>createIndependentConversion</strong>&lt;<code>S</code>&gt;(<code>optionsFunc</code>): <a href="./conversion#conversion"><code>Conversion</code></a>&lt;<code>S</code>&gt;</p><p>Creates a conversion that will replace the gainResource amount with the new amount upon converting. This is similar to the behavior of &quot;static&quot; layers in The Modding Tree.</p><h4 id="type-parameters-3" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-3" 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>S</code></td><td style="text-align:left;">extends <a href="../../interfaces/features/conversion.ConversionOptions"><code>ConversionOptions</code></a></td></tr></tbody></table><h4 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>optionsFunc</code></td><td style="text-align:left;"><a href="./feature#optionsfunc"><code>OptionsFunc</code></a>&lt;<code>S</code>, <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, <a href="./conversion#genericconversion"><code>GenericConversion</code></a>&gt;</td><td style="text-align:left;">Converison options.</td></tr></tbody></table><h4 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><a href="./conversion#conversion"><code>Conversion</code></a>&lt;<code>S</code>&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/8c0a0c4/src/features/conversion.ts#L211" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:211</a></p><hr><h3 id="setuppassivegeneration" tabindex="-1">setupPassiveGeneration <a class="header-anchor" href="#setuppassivegeneration" aria-label="Permalink to &quot;setupPassiveGeneration&quot;"></a></h3><p>▸ <strong>setupPassiveGeneration</strong>(<code>layer</code>, <code>conversion</code>, <code>rate?</code>, <code>cap?</code>): <code>void</code></p><p>This will automatically increase the value of conversion.gainResource without lowering the value of the input resource. It will by default perform 100% of a conversion&#39;s currentGain per second. If you use a ref for the rate you can set it&#39;s value to 0 when passive generation should be disabled.</p><h4 id="parameters-3" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-3" aria-label="Permalink to &quot;Parameters&quot;"></a></h4><table><thead><tr><th style="text-align:left;">Name</th><th style="text-align:left;">Type</th><th style="text-align:left;">Default value</th><th style="text-align:left;">Description</th></tr></thead><tbody><tr><td style="text-align:left;"><code>layer</code></td><td style="text-align:left;"><a href="../../interfaces/game/layers.BaseLayer"><code>BaseLayer</code></a></td><td style="text-align:left;"><code>undefined</code></td><td style="text-align:left;">The layer this passive generation will be associated with. Typically <code>this</code> when calling this function from inside a layer&#39;s options function.</td></tr><tr><td style="text-align:left;"><code>conversion</code></td><td style="text-align:left;"><a href="./conversion#genericconversion"><code>GenericConversion</code></a></td><td style="text-align:left;"><code>undefined</code></td><td style="text-align:left;">The conversion that will determine how much generation there is.</td></tr><tr><td style="text-align:left;"><code>rate</code></td><td style="text-align:left;"><a href="./../util/computed#computable"><code>Computable</code></a>&lt;<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>&gt;</td><td style="text-align:left;"><code>1</code></td><td style="text-align:left;">A multiplier to multiply against the conversion&#39;s currentGain.</td></tr><tr><td style="text-align:left;"><code>cap</code></td><td style="text-align:left;"><a href="./../util/computed#computable"><code>Computable</code></a>&lt;<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>&gt;</td><td style="text-align:left;"><code>Decimal.dInf</code></td><td style="text-align:left;">A value that should not be passed via passive generation.</td></tr></tbody></table><h4 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to &quot;Returns&quot;"></a></h4><p><code>void</code></p><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/8c0a0c4/src/features/conversion.ts#L271" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:271</a></p>',65),c=[n];function i(s,d,l,u,h,f){return o(),t("div",null,c)}const v=e(r,[["render",i]]);export{m as __pageData,v as default};