1 line
24 KiB
JavaScript
1 line
24 KiB
JavaScript
import{_ as e,c as t,o,N as a}from"./chunks/framework.0799945b.js";const b=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><h3 id="baseconversion" tabindex="-1">BaseConversion <a class="header-anchor" href="#baseconversion" aria-label="Permalink to "BaseConversion""></a></h3><p>• <strong>BaseConversion</strong>: <code>Object</code></p><p>The properties that are added onto a processed <a href="./conversion#conversionoptions">ConversionOptions</a> to create a <a href="./conversion#conversion">Conversion</a>.</p><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>convert</code></td><td style="text-align:left;"><code>VoidFunction</code></td><td style="text-align:left;">The function that performs the actual conversion.</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/c386ace/src/features/conversion.ts#L84" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:84</a></p><hr><h3 id="conversionoptions" tabindex="-1">ConversionOptions <a class="header-anchor" href="#conversionoptions" aria-label="Permalink to "ConversionOptions""></a></h3><p>• <strong>ConversionOptions</strong>: <code>Object</code></p><p>An object that configures a <a href="./conversion#conversion">Conversion</a>.</p><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>actualGain?</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;">The absolute amount the output resource will be changed by. Typically this will be set for you in a conversion constructor. This will differ from <a href="./conversion#currentgain">currentGain</a> in the cases where the conversion isn't just adding the converted amount to the output resource.</td></tr><tr><td style="text-align:left;"><code>baseResource</code></td><td style="text-align:left;"><a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td><td style="text-align:left;">The input <a href="./resource#resource">Resource</a> for this conversion.</td></tr><tr><td style="text-align:left;"><code>buyMax?</code></td><td style="text-align:left;"><a href="./../util/computed#computable"><code>Computable</code></a><<code>boolean</code>></td><td style="text-align:left;">Whether or not to cap the amount of the output resource gained by converting at 1. Defaults to true.</td></tr><tr><td style="text-align:left;"><code>convert?</code></td><td style="text-align:left;"><code>VoidFunction</code></td><td style="text-align:left;">The function that performs the actual conversion from <a href="./conversion#baseresource">baseResource</a> to <a href="./conversion#gainresource">gainResource</a>. Typically this will be set for you in a conversion constructor.</td></tr><tr><td style="text-align:left;"><code>currentAt?</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;">The amount of the input resource currently being required in order to produce the <a href="./conversion#currentgain">currentGain</a>. That is, if it went below this value then <a href="./conversion#currentgain">currentGain</a> would decrease. Typically this will be set for you in a conversion constructor.</td></tr><tr><td style="text-align:left;"><code>currentGain?</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;">How much of the output resource the conversion can currently convert for. Typically this will be set for you in a conversion constructor.</td></tr><tr><td style="text-align:left;"><code>formula</code></td><td style="text-align:left;">(<code>variable</code>: <a href="./../game/formulas/types#genericformula"><code>GenericFormula</code></a> & { <code>invert</code>: (<code>value</code>: <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>) => <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a> } & { <code>evaluateIntegral</code>: (<code>variable?</code>: <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>) => <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a> } & { <code>invertIntegral</code>: (<code>value</code>: <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>) => <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a> }) => <a href="./../game/formulas/types#invertibleformula"><code>InvertibleFormula</code></a></td><td style="text-align:left;">The formula used to determine how much <a href="./conversion#gainresource">gainResource</a> should be earned by this converting. The passed value will be a Formula representing the <a href="./conversion#baseresource">baseResource</a> variable.</td></tr><tr><td style="text-align:left;"><code>gainResource</code></td><td style="text-align:left;"><a href="./resource#resource"><code>Resource</code></a><<a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>></td><td style="text-align:left;">The output <a href="./resource#resource">Resource</a> for this conversion. i.e. the resource being generated.</td></tr><tr><td style="text-align:left;"><code>nextAt?</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;">The amount of the input resource required to make <a href="./conversion#currentgain">currentGain</a> increase. Typically this will be set for you in a conversion constructor.</td></tr><tr><td style="text-align:left;"><code>onConvert?</code></td><td style="text-align:left;">(<code>amountGained</code>: <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>) => <code>void</code></td><td style="text-align:left;">A callback that happens after a conversion has been completed. Receives the amount gained via conversion. This will not be called whenever using currentGain without calling convert (e.g. passive generation)</td></tr><tr><td style="text-align:left;"><code>spend?</code></td><td style="text-align:left;">(<code>amountGained</code>: <a href="./../lib/break_eternity#decimalsource"><code>DecimalSource</code></a>) => <code>void</code></td><td style="text-align:left;">The function that spends the <a href="./conversion#baseresource">baseResource</a> as part of the conversion. Defaults to setting the <a href="./conversion#baseresource">baseResource</a> amount to 0.</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/c386ace/src/features/conversion.ts#L20" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:20</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="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="./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="./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="./conversion#conversionoptions"><code>ConversionOptions</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/c386ace/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="./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-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/c386ace/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><h5 id="type-parameters-1" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-1" aria-label="Permalink to "Type parameters""></a></h5><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="./conversion#conversionoptions"><code>ConversionOptions</code></a></td></tr></tbody></table><h5 id="parameters" tabindex="-1">Parameters <a class="header-anchor" href="#parameters" aria-label="Permalink to "Parameters""></a></h5><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="./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><h5 id="returns" tabindex="-1">Returns <a class="header-anchor" href="#returns" aria-label="Permalink to "Returns""></a></h5><p><a href="./conversion#conversion"><code>Conversion</code></a><<code>T</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/c386ace/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><h5 id="type-parameters-2" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-2" aria-label="Permalink to "Type parameters""></a></h5><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="./conversion#conversionoptions"><code>ConversionOptions</code></a></td></tr></tbody></table><h5 id="parameters-1" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-1" aria-label="Permalink to "Parameters""></a></h5><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="./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><h5 id="returns-1" tabindex="-1">Returns <a class="header-anchor" href="#returns-1" aria-label="Permalink to "Returns""></a></h5><p><a href="./conversion#conversion"><code>Conversion</code></a><<code>S</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/c386ace/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><h5 id="type-parameters-3" tabindex="-1">Type parameters <a class="header-anchor" href="#type-parameters-3" aria-label="Permalink to "Type parameters""></a></h5><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="./conversion#conversionoptions"><code>ConversionOptions</code></a></td></tr></tbody></table><h5 id="parameters-2" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-2" aria-label="Permalink to "Parameters""></a></h5><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="./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><h5 id="returns-2" tabindex="-1">Returns <a class="header-anchor" href="#returns-2" aria-label="Permalink to "Returns""></a></h5><p><a href="./conversion#conversion"><code>Conversion</code></a><<code>S</code>></p><h4 id="defined-in-6" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-6" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c386ace/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><h5 id="parameters-3" tabindex="-1">Parameters <a class="header-anchor" href="#parameters-3" aria-label="Permalink to "Parameters""></a></h5><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="./../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><h5 id="returns-3" tabindex="-1">Returns <a class="header-anchor" href="#returns-3" aria-label="Permalink to "Returns""></a></h5><p><code>void</code></p><h4 id="defined-in-7" tabindex="-1">Defined in <a class="header-anchor" href="#defined-in-7" aria-label="Permalink to "Defined in""></a></h4><p><a href="https://github.com/profectus-engine/Profectus/blob/c386ace/src/features/conversion.ts#L271" target="_blank" rel="noreferrer">profectus/src/features/conversion.ts:271</a></p>',77),c=[n];function i(d,s,l,u,h,f){return o(),t("div",null,c)}const m=e(r,[["render",i]]);export{b as __pageData,m as default};
|