1 line
16 KiB
JavaScript
1 line
16 KiB
JavaScript
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 "Module: features/conversion""></a></h1><h2 id="interfaces" tabindex="-1">Interfaces <a class="header-anchor" href="#interfaces" aria-label="Permalink to "Interfaces""></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 "Type Aliases""></a></h2><h3 id="conversion" tabindex="-1">Conversion <a class="header-anchor" href="#conversion" aria-label="Permalink to "Conversion""></a></h3><p>Ƭ <strong>Conversion</strong><<code>T</code>>: <a href="./feature#replace"><code>Replace</code></a><<code>T</code> & <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, { <code>actualGain</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"actualGain"</code>], <code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>>> ; <code>buyMax</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"buyMax"</code>], <code>true</code>> ; <code>currentAt</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"currentAt"</code>], <code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>>> ; <code>currentGain</code>: <a href="./../util/computed#getcomputabletypewithdefault"><code>GetComputableTypeWithDefault</code></a><<code>T</code>[<code>"currentGain"</code>], <code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>>> ; <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><<code>T</code>[<code>"nextAt"</code>], <code>Ref</code><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>>> ; <code>spend</code>: <code>undefined</code> extends <code>T</code>[<code>"spend"</code>] ? (<code>amountGained</code>: <a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>) => <code>void</code> : <code>T</code>[<code>"spend"</code>] }></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 "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="../../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 "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/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 "GenericConversion""></a></h3><p>Ƭ <strong>GenericConversion</strong>: <a href="./feature#replace"><code>Replace</code></a><<a href="./conversion#conversion"><code>Conversion</code></a><<a href="../../interfaces/features/conversion.ConversionOptions"><code>ConversionOptions</code></a>>, { <code>actualGain</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>> ; <code>buyMax</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<code>boolean</code>> ; <code>currentAt</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>> ; <code>currentGain</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>> ; <code>nextAt</code>: <a href="./../util/computed#processedcomputable"><code>ProcessedComputable</code></a><<a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>> ; <code>spend</code>: (<code>amountGained</code>: <a href="./../util/bignum#decimalsource"><code>DecimalSource</code></a>) => <code>void</code> }></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 "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/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 "Functions""></a></h2><h3 id="createconversion" tabindex="-1">createConversion <a class="header-anchor" href="#createconversion" aria-label="Permalink to "createConversion""></a></h3><p>▸ <strong>createConversion</strong><<code>T</code>>(<code>optionsFunc</code>): <a href="./conversion#conversion"><code>Conversion</code></a><<code>T</code>></p><p>Lazily creates a conversion with the given options. You typically shouldn'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 "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="../../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 "Parameters""></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><<code>T</code>, <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, <a href="./conversion#genericconversion"><code>GenericConversion</code></a>></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 "Returns""></a></h4><p><a href="./conversion#conversion"><code>Conversion</code></a><<code>T</code>></p><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/70cda5f/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 "createCumulativeConversion""></a></h3><p>▸ <strong>createCumulativeConversion</strong><<code>S</code>>(<code>optionsFunc</code>): <a href="./conversion#conversion"><code>Conversion</code></a><<code>S</code>></p><p>Creates a conversion that simply adds to the gainResource amount upon converting. This is similar to the behavior of "normal" 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 "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>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 "Parameters""></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><<code>S</code>, <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, <a href="./conversion#genericconversion"><code>GenericConversion</code></a>></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 "Returns""></a></h4><p><a href="./conversion#conversion"><code>Conversion</code></a><<code>S</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/70cda5f/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 "createIndependentConversion""></a></h3><p>▸ <strong>createIndependentConversion</strong><<code>S</code>>(<code>optionsFunc</code>): <a href="./conversion#conversion"><code>Conversion</code></a><<code>S</code>></p><p>Creates a conversion that will replace the gainResource amount with the new amount upon converting. This is similar to the behavior of "static" 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 "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>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 "Parameters""></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><<code>S</code>, <a href="../../interfaces/features/conversion.BaseConversion"><code>BaseConversion</code></a>, <a href="./conversion#genericconversion"><code>GenericConversion</code></a>></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 "Returns""></a></h4><p><a href="./conversion#conversion"><code>Conversion</code></a><<code>S</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/70cda5f/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 "setupPassiveGeneration""></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's currentGain per second. If you use a ref for the rate you can set it'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 "Parameters""></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'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><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td><td style="text-align:left;"><code>1</code></td><td style="text-align:left;">A multiplier to multiply against the conversion'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><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></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 "Returns""></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 "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/70cda5f/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};
|