pages/assets/public_gamedevtree_docs_layer-features.md.a7640a7f.js

18 lines
19 KiB
JavaScript

import{_ as e,c as t,o as a,d as s}from"./app.99998402.js";const f=JSON.parse('{"title":"Layer Features","description":"","frontmatter":{},"headers":[{"level":2,"title":"Layer Definition features","slug":"layer-definition-features","link":"#layer-definition-features","children":[]},{"level":2,"title":"Big features (all optional)","slug":"big-features-all-optional","link":"#big-features-all-optional","children":[]},{"level":2,"title":"Prestige formula features","slug":"prestige-formula-features","link":"#prestige-formula-features","children":[]},{"level":2,"title":"Tree/node features","slug":"tree-node-features","link":"#tree-node-features","children":[]},{"level":2,"title":"Other features","slug":"other-features","link":"#other-features","children":[]},{"level":2,"title":"Custom Prestige type","slug":"custom-prestige-type","link":"#custom-prestige-type","children":[]}],"relativePath":"public/gamedevtree/docs/layer-features.md","lastUpdated":null}'),o={name:"public/gamedevtree/docs/layer-features.md"},n=s(`<h1 id="layer-features" tabindex="-1">Layer Features <a class="header-anchor" href="#layer-features" aria-hidden="true">#</a></h1><p>This is a more comprehensive list of established features to add to layers. You can add more freely, if you want to have other functions or values associated with your layer. These have special functionality, though.</p><p>You can make almost any value dynamic by using a function in its place, including all display strings and styling/color features.</p><p>Key:</p><ul><li>No label: This is required and the game will crash if it isn&#39;t included.</li><li><strong>sometimes required</strong>: This is may be required, depending on other things in the layer.</li><li><strong>optional</strong>: You can leave this out if you don&#39;t intend to use that feature for the layer.</li></ul><h2 id="layer-definition-features" tabindex="-1">Layer Definition features <a class="header-anchor" href="#layer-definition-features" aria-hidden="true">#</a></h2><ul><li><p>layer: <strong>Assigned automagically</strong>. It&#39;s the same value as the name of this layer, so you can do player[this.layer].points or similar to access the save value. It makes copying code to new layers easier. It is also assigned to all upgrades and buyables and such.</p></li><li><p>name: <strong>Optional</strong>, used in reset confirmations (and maybe other places). If absent, it just uses the layer&#39;s id.</p></li><li><p>startData(): A function to return the default save data for this layer. Add any variables you have to it. Any nonstandard Decimal variables need to be added to convertToDecimal as well. Standard values: Required: unlocked: a bool determining if this layer is unlocked or not points: a Decimal, the main currency for the layer Optional: total: A Decimal, tracks total amount of main prestige currency best: A Decimal, tracks highest amount of main prestige currency unlockOrder: used to keep track of relevant layers unlocked before this one.</p></li><li><p>color: A color associated with this layer, used in many places. (A string in hex format with a #)</p></li><li><p>row: The row of the layer, starting at 0. This affects where the node appears on the tree, and which resets affect the layer.</p><pre><code> Using &quot;side&quot; instead of a number will cause the layer to appear off to the side as a smaller node (useful for achievements
and statistics). Side layers are not affected by resets unless you add a doReset to them.
</code></pre></li><li><p>resource: Name of the main currency you gain by resetting on this layer.</p></li><li><p>effect(): <strong>optional</strong>, A function that calculates and returns the current values of any bonuses inherent to the main currency. Can return a value or an object containing multiple values. <em>You will also have to implement the effect where it is applied.</em></p></li><li><p>effectDescription: <strong>optional</strong>, A function that returns a description of this effect. If the text stays constant, it can just be a string.</p></li><li><p>layerShown(): A function returning a bool which determines if this layer&#39;s node should be visible on the tree. It can also return &quot;ghost&quot;, which will hide the layer, but its node will still take up space in the tree.</p></li><li><p>hotkeys: <strong>optional</strong>, An array containing information on any hotkeys associated with this layer:</p><div class="language-js"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki"><code><span class="line"><span style="color:#FFCB6B;">hotkeys</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> [</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span><span style="color:#F07178;">key</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">p</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;">// What the hotkey button is. Use uppercase if it&#39;s combined with shift, or &quot;ctrl+x&quot; if ctrl is.</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">desc</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">p: reset your points for prestige points</span><span style="color:#89DDFF;">&quot;</span><span style="color:#89DDFF;">,</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;">// The description of the hotkey used in the How To Play</span></span>
<span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#F07178;">onPress</span><span style="color:#89DDFF;">(){</span><span style="color:#89DDFF;">if</span><span style="color:#F07178;"> (</span><span style="color:#A6ACCD;">player</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">p</span><span style="color:#89DDFF;">.</span><span style="color:#A6ACCD;">unlocked</span><span style="color:#F07178;">) </span><span style="color:#82AAFF;">doReset</span><span style="color:#F07178;">(</span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">p</span><span style="color:#89DDFF;">&quot;</span><span style="color:#F07178;">)</span><span style="color:#89DDFF;">}},</span><span style="color:#A6ACCD;"> </span><span style="color:#676E95;">// This function is called when the hotkey is pressed.</span></span>
<span class="line"><span style="color:#A6ACCD;">]</span><span style="color:#89DDFF;">,</span></span>
<span class="line"></span></code></pre></div></li><li><p>style: <strong>optional</strong>, a &quot;CSS object&quot; where the keys are CSS attributes ,containing any CSS that should affect this layer&#39;s entire tab.</p></li><li><p>tabFormat: <strong>optional</strong>, use this if you want to add extra things to your tab or change the layout. <a href="./custom-tab-layouts">See here for more info.</a></p></li><li><p>midsection: <strong>optional</strong>, an alternative to tabFormat, which is inserted in between Milestones and Buyables in the standard tab layout. (cannot do subtabs)</p></li></ul><h2 id="big-features-all-optional" tabindex="-1">Big features (all optional) <a class="header-anchor" href="#big-features-all-optional" aria-hidden="true">#</a></h2><ul><li><p>upgrades: A grid of one-time purchases which can have unique upgrade conditions, currency costs, and bonuses. <a href="./upgrades">Explanations are in a separate file.</a></p></li><li><p>milestones: A list of bonuses gained upon reaching certain thresholds of a resource. Often used for automation/QOL. <a href="./milestones">Explanations are in a separate file.</a></p></li><li><p>challenges: The player can enter challenges, which make the game harder. If they reach a goal and beat the challenge, they recieve a bonus. <a href="./challenges">Explanations are in a separate file.</a></p></li><li><p>buyables: Effectively upgrades that can be bought multiple times, and are optionally respeccable. Many uses. <a href="./buyables">Explanations are in a separate file.</a></p></li><li><p>clickables: Extremely versatile and generalized buttons which can only be clicked sometimes. <a href="./clickables">Explanations are in a separate file.</a></p></li><li><p>microtabs: An area that functions like a set of subtabs, with buttons at the top changing the content within. (Advanced) <a href="./subtabs-and-microtabs">Explanations are in a separate file.</a></p></li><li><p>bars: Display some information as a progress bar, gague, or similar. They are highly customizable, and can be vertical as well. <a href="./bars">Explanations are in a separate file.</a></p></li><li><p>achievements: Kind of like milestones, but with a different display style and some other differences. Extra features are on the way at a later date! <a href="./achievements">Explanations are in a separate file.</a></p></li><li><p>infoboxes: Displays some text in a box that can be shown or hidden. <a href="./infoboxes">Explanations are in a separate file.</a></p></li></ul><h2 id="prestige-formula-features" tabindex="-1">Prestige formula features <a class="header-anchor" href="#prestige-formula-features" aria-hidden="true">#</a></h2><ul><li><p>type: <strong>optional</strong>, Determines which prestige formula you use. Defaults to &quot;none&quot;. &quot;normal&quot;: The amount of currency you gain is independent of its current amount (like Prestige). formula before bonuses is based on <code>baseResource^exponent</code> &quot;static&quot;: The cost is dependent on your total after reset. formula before bonuses is based on <code>base^(x^exponent)</code> &quot;custom&quot;: You can define everything, from the calculations to the text on the button, yourself. (See more at the bottom) &quot;none&quot;: This layer does not prestige, and therefore does not need any of the other features in this section.</p></li><li><p>baseResource: The name of the resource that determines how much of the main currency you gain on reset.</p></li><li><p>baseAmount(): A function that gets the current value of the base resource.</p></li><li><p>requires: A Decimal, the amount of the base needed to gain 1 of the prestige currency. Also the amount required to unlock the layer. You can instead make this a function, to make it harder if another layer was unlocked first (based on unlockOrder).</p></li><li><p>exponent: Used as described above.</p></li><li><p>base: <strong>sometimes required</strong>, required for &quot;static&quot; layers, used as described above. If absent, defaults to 2. Must be greater than 1.</p></li><li><p>roundUpCost: <strong>optional</strong>, a bool, which is true if the resource cost needs to be rounded up. (use if the base resource is a &quot;static&quot; currency.)</p></li><li><p>canBuyMax(): <strong>sometimes required</strong>, required for static layers, function used to determine if buying max is permitted.</p></li><li><p>gainMult(), gainExp(): <strong>optional</strong>, Functions that calculate the multiplier and exponent on resource gain from upgrades and boosts and such. Plug in any bonuses here.</p></li><li><p>onPrestige(gain): <strong>optional</strong>, A function that triggers when this layer prestiges, just before you gain the currency. Can be used to have secondary resource gain on prestige, or to recalculate things or whatnot.</p></li><li><p>resetDesc: <strong>optional</strong>, use this to replace &quot;Reset for &quot; on the Prestige button with something else.</p></li><li><p>prestigeButtonText(): <strong>Sometimes required</strong>, Use this to make the entirety of the text a Prestige button contains. Only required for custom layers, but usable by all types.</p></li></ul><h2 id="tree-node-features" tabindex="-1">Tree/node features <a class="header-anchor" href="#tree-node-features" aria-hidden="true">#</a></h2><ul><li><p>symbol: <strong>optional</strong>, the text that appears on this layer&#39;s node. Default is the layer id with the first letter capitalized</p></li><li><p>position: <strong>optional</strong>, Determines the horizontal position of the layer in its row. By default, it uses the layer id, and layers are sorted in alphabetical order.</p></li><li><p>branches: <strong>optional</strong>, an array of layer ids. On a tree, a line will appear from this layer to all of the layers in the list. Alternatively, an entry in the array can be a 2-element array consisting of the layer id and a color value. The color value can either be a string with a hex color code, or a number from 1-3 (theme-affected colors)</p></li><li><p>nodeStyle: <strong>optional</strong>, a CSS object, where the keys are CSS attributes, which styles this layer&#39;s node on the tree</p></li><li><p>tooltip() / tooltipLocked(): <strong>optional</strong> Functions that return text, which is the tooltip for the node when the layer is unlocked or locked, respectively. By default the tooltips behave the same as in the original Prestige Tree.</p></li></ul><h2 id="other-features" tabindex="-1">Other features <a class="header-anchor" href="#other-features" aria-hidden="true">#</a></h2><ul><li><p>doReset(resettingLayer): <strong>optional</strong>, is triggered when a layer on a row greater than or equal to this one does a reset. The default behavior is to reset everything on the row, but only if it was triggered by a layer in a higher row. (doReset is always called for side layers, but for these the default behavior is to reset nothing.)</p><pre><code> If you want to keep things, determine what to keep based on the resettingLayer, milestones, and such, then call
resetLayerData(layer, keep), where layer is this layer, and keep is an array of the names of things to keep.
It can include things like &quot;points&quot;, &quot;best&quot;, &quot;total&quot; (for this layer&#39;s prestige currency), &quot;upgrades&quot;,
any unique variables like &quot;generatorPower&quot;, etc.
If you want to only keep specific upgrades or something like that, save them in a separate variable, then
call layerDataReset, and then set player[layer].upgrades to the saved upgrades.
</code></pre></li><li><p>update(diff): <strong>optional</strong>, this function is called every game tick. Use it for any passive resource production or time-based things. diff is the time since the last tick. Suggestion: use addPoints(layer, gain) when generating points to automatically update the best and total amounts.</p></li><li><p>automate(): <strong>optional</strong>, this function is called every game tick, after production. Use it to activate any autobuyers or auto-resets or similar on this layer, if appropriate.</p></li><li><p>resetsNothing: <strong>optional</strong>, returns true if this layer shouldn&#39;t trigger any resets when you prestige.</p></li><li><p>increaseUnlockOrder: <strong>optional</strong>, an array of layer ids. When this layer is unlocked for the first time, the unlockOrder value for any not-yet-unlocked layers in this list increases. This can be used to make them harder to unlock.</p></li><li><p>shouldNotify: <strong>optional</strong>, a function to return true if this layer should be highlighted in the tree. The layer will automatically be highlighted if you can buy an upgrade whether you have this or not.</p></li><li><p>componentStyles: <strong>optional</strong>, An object that contains a set of functions returning CSS objects. Each of these will be applied to any components on the layer with the type of its id. Example:</p></li></ul><div class="language-js"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki"><code><span class="line"><span style="color:#A6ACCD;"> </span><span style="color:#FFCB6B;">componentStyles</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
<span class="line"><span style="color:#F07178;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">challenge</span><span style="color:#89DDFF;">&quot;</span><span style="color:#F07178;">() </span><span style="color:#89DDFF;">{</span><span style="color:#89DDFF;">return</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">{</span><span style="color:#89DDFF;">&#39;</span><span style="color:#F07178;">height</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">:</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">200px</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">}},</span></span>
<span class="line"><span style="color:#F07178;"> </span><span style="color:#89DDFF;">&quot;</span><span style="color:#C3E88D;">prestige-button</span><span style="color:#89DDFF;">&quot;</span><span style="color:#F07178;">() </span><span style="color:#89DDFF;">{</span><span style="color:#89DDFF;">return</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">{</span><span style="color:#89DDFF;">&#39;</span><span style="color:#F07178;">color</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">:</span><span style="color:#F07178;"> </span><span style="color:#89DDFF;">&#39;</span><span style="color:#C3E88D;">#AA66AA</span><span style="color:#89DDFF;">&#39;</span><span style="color:#89DDFF;">}},</span></span>
<span class="line"><span style="color:#F07178;"> </span><span style="color:#89DDFF;">},</span></span>
<span class="line"></span></code></pre></div><h2 id="custom-prestige-type" tabindex="-1">Custom Prestige type <a class="header-anchor" href="#custom-prestige-type" aria-hidden="true">#</a></h2><ul><li><p>getResetGain(): <strong>For custom prestige type</strong>, Returns how many points you should get if you reset now. You can call getResetGain(this.layer, useType = &quot;static&quot;) or similar to calculate what your gain would be under another prestige type (provided you have all of the required features in the layer.)</p></li><li><p>getNextAt(canMax=false): <strong>For custom prestige type</strong>, Returns how many of the base currency you need to get to the next point. canMax is an optional variable used with Static-ish layers to differentiate between if it&#39;s looking for the first point you can reset at, or the requirement for any gain at all. (Supporting both is good). You can also call getNextAt(this.layer, canMax=false, useType = &quot;static&quot;) or similar to calculate what your next at would be under another prestige type (provided you have all of the required features in the layer.)</p></li><li><p>canReset(): <strong>For custom prestige type</strong>, return true only if you have the resources required to do a prestige here.</p></li></ul>`,18),r=[n];function l(i,p,c,u,h,y){return a(),t("div",null,r)}const g=e(o,[["render",l]]);export{f as __pageData,g as default};