import{_ as s,o as a,c as n,Q as l}from"./chunks/framework.1169fbc9.js";const b=JSON.parse('{"title":"Buyables","description":"","frontmatter":{},"headers":[],"relativePath":"public/kronos/docs/buyables.md","filePath":"public/kronos/docs/buyables.md","lastUpdated":1701136977000}'),e={name:"public/kronos/docs/buyables.md"},o=l(`

Buyables

Buyables are usually things that can be bought multiple times with scaling costs. They come with optional buttons that can be used for respeccing or selling buyables, among other things.

The amount of a buyable owned is a Decimal.

Useful functions for dealing with buyables and implementing their effects:

Buyables should be formatted like this:

js
buyables: {
    11: {
        cost(x) { return new Decimal(1).mul(x) },
        display() { return "Blah" },
        canAfford() { return player[this.layer].points.gte(this.cost()) },
        buy() {
            player[this.layer].points = player[this.layer].points.sub(this.cost())
            setBuyableAmount(this.layer, this.id, getBuyableAmount(this.layer, this.id).add(1))
        },
        etc
    },
    etc
}
buyables: {
    11: {
        cost(x) { return new Decimal(1).mul(x) },
        display() { return "Blah" },
        canAfford() { return player[this.layer].points.gte(this.cost()) },
        buy() {
            player[this.layer].points = player[this.layer].points.sub(this.cost())
            setBuyableAmount(this.layer, this.id, getBuyableAmount(this.layer, this.id).add(1))
        },
        etc
    },
    etc
}

Features:

Sell One/Sell All:

Including a sellOne or sellAll function will cause an additional button to appear beneath the buyable. They are functionally identical, but "sell one" appears above "sell all". You can also use them for other things.

To add a respec button, or something similar, add the respecBuyables function to the main buyables object (not individual buyables). You can use these features along with it:

`,14),t=[o];function p(r,c,i,y,u,E){return a(),n("div",null,t)}const d=s(e,[["render",p]]);export{b as __pageData,d as default};