</svg></a><!--]--></div></div></div><!--]--><!--]--></div></div></div><!--[--><!--]--><buttontype="button"class="VPNavBarHamburger hamburger"aria-label="mobile navigation"aria-expanded="false"aria-controls="VPNavScreen"data-v-a0fd61f4data-v-e5dd9c1c><spanclass="container"data-v-e5dd9c1c><spanclass="top"data-v-e5dd9c1c></span><spanclass="middle"data-v-e5dd9c1c></span><spanclass="bottom"data-v-e5dd9c1c></span></span></button></div></div></div></div><!----></header><divclass="VPLocalNav fixed reached-top"data-v-5a346dfedata-v-79c8c1df><!----><divclass="VPLocalNavOutlineDropdown"style="--vp-vh:0px;"data-v-79c8c1dfdata-v-1c15a60a><buttondata-v-1c15a60a>Return to top</button><!----></div></div><!----><divclass="VPContent"id="VPContent"data-v-5a346dfedata-v-669faec9><divclass="VPDoc has-aside"data-v-669faec9data-v-6b87e69f><!--[--><!--]--><divclass="container"data-v-6b87e69f><divclass="aside"data-v-6b87e69f><divclass="aside-curtain"data-v-6b87e69f></div><divclass="aside-container"data-v-6b87e69f><divclass="aside-content"data-v-6b87e69f><divclass="VPDocAside"data-v-6b87e69fdata-v-3f215769><!--[--><!--]--><!--[--><!--]--><divclass="VPDocAsideOutline"role="navigation"data-v-3f215769data-v-d330b1bb><divclass="content"data-v-d330b1bb><divclass="outline-marker"data-v-d330b1bb></div><divclass="outline-title"role="heading"aria-level="2"data-v-d330b1bb>On this page</div><navaria-labelledby="doc-outline-aria-label"data-v-d330b1bb><spanclass="visually-hidden"id="doc-outline-aria-label"data-v-d330b1bb> Table of Contents for current page </span><ulclass="root"data-v-d330b1bbdata-v-d0ee3533><!--[--><!--]--></ul></nav></div></div><!--[--><!--]--><divclass="spacer"data-v-3f215769></div><!--[--><!--]--><!----><!--[--><!--]--><!--[--><!--]--></div></div></div></div><divclass="content"data-v-6b87e69f><divclass="content-container"data-v-6b87e69f><!--[--><!--]--><!----><mainclass="main"data-v-6b87e69f><divstyle="position:relative;"class="vp-doc _public_kronos_docs_upgrades"data-v-6b87e69f><div><h1id="upgrades"tabindex="-1">Upgrades <aclass="header-anchor"href="#upgrades"aria-label="Permalink to "Upgrades""></a></h1><p>Useful functions for dealing with Upgrades and implementing their effects:</p><ul><li>hasUpgrade(layer, id): determine if the player has the upgrade</li><li>upgradeEffect(layer, id): Returns the current effects of the upgrade, if any</li><li>buyUpgrade(layer, id): Buys an upgrade directly (if affordable)</li></ul><p>Hint: Basic point gain is calculated in <ahref="/js/mod.js">mod.js</a>'s "getPointGen" function.</p><p>Upgrades are stored in the following format:</p><divclass="language-js vp-adaptive-theme"><buttontitle="Copy Code"class="copy"></button><spanclass="lang">js</span><preclass="shiki github-dark vp-code-dark"><code><spanclass="line"><spanstyle="color:#B392F0;">upgrades</span><spanstyle="color:#E1E4E8;">: {</span></span>
<spanclass="line"><spanstyle="color:#24292E;">}</span></span></code></pre></div><p>Usually, upgrades should have an id where the first digit is the row and the second digit is the column.</p><p>Individual upgrades can have these features:</p><ul><li><p>title: <strong>optional</strong>. Displayed at the top in a larger font. It can also be a function that returns updating text. Can use basic HTML.</p></li><li><p>description: A description of the upgrade's effect. <em>You will also have to implement the effect where it is applied.</em> It can also be a function that returns updating text. Can use basic HTML.</p></li><li><p>effect(): <strong>optional</strong>. A function that calculates and returns the current values of any bonuses from the upgrade. Can return a value or an object containing multiple values.</p></li><li><p>effectDisplay(): <strong>optional</strong>. A function that returns a display of the current effects of the upgrade with formatting. Default displays nothing. Can use basic HTML.</p></li><li><p>fullDisplay(): <strong>OVERRIDE</strong>. Overrides the other displays and descriptions, and lets you set the full text for the upgrade. Can use basic HTML.</p></li><li><p>cost: A Decimal for the cost of the upgrade. By default, upgrades cost the main prestige currency for the layer.</p></li><li><p>unlocked(): <strong>optional</strong>. A function returning a bool to determine if the upgrade is visible or not. Default is unlocked.</p></li><li><p>onPurchase(): <strong>optional</strong>. This function will be called when the upgrade is purchased. Good for upgrades like "makes this layer act like it was unlocked first".</p></li><li><p>style: <strong>optional</strong>. Applies CSS to this upgrade, in the form of an object where the keys are CSS attributes, and the values are the values for those attributes (both as strings).</p></li><li><p>layer: <strong>assigned automagically</strong>. It's the same value as the name of this layer, so you can do <code>player[this.layer].points</code> or similar.</p></li><li><p>id: <strong>assigned automagically</strong>. It's the "key" which the upgrade was stored under, for convenient access. The upgrade in the example's id is 11.</p></li></ul><p>By default, upgrades use the main prestige currency for the layer. You can include these to change them (but it needs to be a Decimal):</p><ul><li><p>currencyDisplayName: <strong>optional</strong>. The name to display for the currency for the upgrade.</p></li><li><p>currencyInternalName: <strong>optional</strong>. The internal name for that currency.</p></li><li><p>currencyLayer: <strong>optional</strong>. The internal name of the layer that currency is stored in. If it's not in a layer (like Points), omit. If it's not stored directly in a layer, instead use the next feature.</p></li><li><p>currencyLocation: <strong>optional</strong>. If your currency is stored in something inside a layer (e.g. a buyable's amount), you can access it this way. This is a function returning the object in "player" that contains the value (like <code>player[this.layer].buyables</code>)</p></li></ul><p>If you want to do something more complicated like upgrades that cost two currencies, you can override the purchase system with these (and you need to use fullDisplay as well)</p><ul><li><p>canAfford(): <strong>OVERRIDE</strong>, a function determining if you are able to buy the upgrade</p></li><li><p>pay(): <strong>OVERRIDE</strong>, a function that reduces your currencies when you buy the upgrade</p></li></ul></div></div></main><footerclass="VPDocFooter"data-v-6b87e69fdata-v-ef5dee53><!--[--><!--]--><divclass="edit-info"data-v-ef5dee53><!----><divclass="last-updated"data-v-ef5dee53><pclass="VPLastUpdated"data-v-ef5dee53data-v-7e05ebdb>Last updated: <timedatetime="2023-11-28T02:02:57.000Z"data-v-7e05ebdb></time></p></div></div><!----></footer><!--[--><!--]--></div></div></div><!--[--><!--]--></div></div><!----><!--[--><!--]--></div></div>