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/lit/docs/buyables.md","filePath":"public/lit/docs/buyables.md","lastUpdated":1701137263000}'),o={name:"public/lit/docs/buyables.md"},e=l(`

Buyables

Buyables are usually things that can be bought multiple times with scaling costs. If you set a respec function, the player can reset the purchases to get their currency back.

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: {
    rows: # of rows,
    cols: # of columns,
    11: {
        cost(x) { return new Decimal(1).mul(x || getBuyableAmt(this.layer, this.id)) },
        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, getBuyableAmt(this.layer, this.id).add(1))
        },
        etc
    },
    etc
}
buyables: {
    rows: # of rows,
    cols: # of columns,
    11: {
        cost(x) { return new Decimal(1).mul(x || getBuyableAmt(this.layer, this.id)) },
        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, getBuyableAmt(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.

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