import{_ as s,c as e,o as t,a9 as a}from"./chunks/framework.D8PMdl4T.js";const y=JSON.parse('{"title":"Buyables","description":"","frontmatter":{},"headers":[],"relativePath":"public/gamedevtree/docs/buyables.md","filePath":"public/gamedevtree/docs/buyables.md","lastUpdated":1602964230000}'),i={name:"public/gamedevtree/docs/buyables.md"},n=a(`

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. You can get or set the amount of a buyable with getBuyableAmt(layer, id) and setBuyableAmt(layer, id, amt). You can use buyableEffect(layer, id) to get the current effects of a buyable.

Buyables should be formatted like this:

js
    buyables: {
        rows: # of rows
        cols: # of columns
        respec() {}, //**optional**, implement it to reset things and give back your currency.
                     // Having this function makes a respec button appear
        respecText:// **optional**, text that appears on the respec button
        showRespecButton(){} //**optional**, a function determining whether or not to show the button. Defaults to true if absent.
        sellOneText, sellAllText:// **optional**, text that appears on the "sell one" and "sell all" buttons respectively (if you are using them)
        11: {
            display() {return "Blah"},
            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.

sellOne/sellAll(): optional, Called when the button is pressed. The standard use would be to decrease/reset the amount of the buyable, And possibly return some currency to the player.

canSellOne/canSellAll(): optional, booleans determining whether or not to show the buttons. If "canSellOne/All" is absent but "sellOne/All" is present, the appropriate button will always show.

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