2024-11-08 12:06:49 +00:00
import { _ as s , q as e , p as t , ag as a } from "./chunks/framework.Sr2_9k8k.js" ; const y = JSON . parse ( '{"title":"Buyables","description":"","frontmatter":{},"headers":[],"relativePath":"public/gamedevtree/docs/buyables.md","filePath":"public/gamedevtree/docs/buyables.md"}' ) , i = { name : "public/gamedevtree/docs/buyables.md" } , n = a ( ` <h1 id="buyables" tabindex="-1">Buyables <a class="header-anchor" href="#buyables" aria-label="Permalink to "Buyables""> </a></h1><p>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.</p><p>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.</p><p>Buyables should be formatted like this:</p><div class="language-js vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki shiki-themes github-light github-dark vp-code" tabindex="0"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;"> buyables</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">: {</span></span>
2024-06-17 04:46:30 +00:00
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > rows < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > : # < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > r o w s < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > cols < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > : # < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > o f < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > c o l u m n s < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > respec < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { } , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / * * o p t i o n a l * * , i m p l e m e n t i t t o r e s e t t h i n g s a n d g i v e b a c k y o u r c u r r e n c y . < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6A737D;--shiki-dark:#6A737D;" > // Having this function makes a respec button appear</span></span>
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > respecText < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / * * o p t i o n a l * * , t e x t t h a t a p p e a r s o n t h e r e s p e c b u t t o n < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > showRespecButton < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { } < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / * * o p t i o n a l * * , a f u n c t i o n d e t e r m i n i n g w h e t h e r o r n o t t o s h o w t h e b u t t o n . D e f a u l t s t o t r u e i f a b s e n t . < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > sellOneText , < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 F 4 2 C 1 ; - - s h i k i - d a r k : # B 3 9 2 F 0 ; " > s e l l A l l T e x t < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > : < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 6 A 7 3 7 D ; - - s h i k i - d a r k : # 6 A 7 3 7 D ; " > / / * * o p t i o n a l * * , t e x t t h a t a p p e a r s o n t h e & q u o t ; s e l l o n e & q u o t ; a n d & q u o t ; s e l l a l l & q u o t ; b u t t o n s r e s p e c t i v e l y ( i f y o u a r e u s i n g t h e m ) < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#005CC5;--shiki-dark:#79B8FF;" > 11 < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > : { < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#6F42C1;--shiki-dark:#B392F0;" > display < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > ( ) { < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # D 7 3 A 4 9 ; - - s h i k i - d a r k : # F 9 7 5 8 3 ; " > r e t u r n < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 0 3 2 F 6 2 ; - - s h i k i - d a r k : # 9 E C B F F ; " > & q u o t ; B l a h & q u o t ; < / s p a n > < s p a n s t y l e = " - - s h i k i - l i g h t : # 2 4 2 9 2 E ; - - s h i k i - d a r k : # E 1 E 4 E 8 ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > etc < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > etc < / s p a n > < / s p a n >
< span class = "line" > < span style = "--shiki-light:#24292E;--shiki-dark:#E1E4E8;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < / d i v > < p > F e a t u r e s : < / p > < u l > < l i > < p > t i t l e : < s t r o n g > o p t i o n a l < / s t r o n g > , d i s p l a y e d a t t h e t o p i n a l a r g e r f o n t I t c a n a l s o b e a f u n c t i o n t h a t r e t u r n s u p d a t i n g t e x t . < / p > < / l i > < l i > < p > c o s t ( ) : c o s t f o r b u y i n g t h e n e x t b u y a b l e . C a n h a v e a n o p t i o n a l a r g u m e n t & q u o t ; x & q u o t ; t o c a l c u l a t e t h e c o s t o f t h e x + 1 t h o b j e c t , b u t n e e d s t o u s e & q u o t ; c u r r e n t a m o u n t & q u o t ; a s a d e f a u l t v a l u e f o r x . ( x i s a D e c i m a l ) . C a n r e t u r n a n o b j e c t i f t h e r e a r e m u l t i p l e c u r r e n c i e s . < / p > < / l i > < l i > < p > e f f e c t ( ) : < s t r o n g > o p t i o n a l < / s t r o n g > , A f u n c t i o n t h a t c a l c u l a t e s a n d r e t u r n s t h e c u r r e n t v a l u e s o f b o n u s e s o f t h i s b u y a b l e . C a n r e t u r n a v a l u e o r a n o b j e c t c o n t a i n i n g m u l t i p l e v a l u e s . < / p > < / l i > < l i > < p > d i s p l a y ( ) : A f u n c t i o n r e t u r n i n g e v e r y t h i n g t h a t s h o u l d b e d i s p l a y e d o n t h e b u y a b l e a f t e r t h e t i t l e , l i k e l y i n c l u d i n g t h e d e s c r i p t i o n , a m o u n t b o u g h t , c o s t , a n d c u r r e n t e f f e c t . C a n u s e b a s i c H T M L . < / p > < / l i > < l i > < p > u n l o c k e d ( ) : < s t r o n g > o p t i o n a l < / s t r o n g > , A f u n c t i o n r e t u r n i n g a b o o l t o d e t e r m i n e i f t h e b u y a b l e i s v i s i b l e o r n o t . D e f a u l t i s u n l o c k e d . < / p > < / l i > < l i > < p > c a n A f f o r d ( ) : A f u n c t i o n r e t u r n i n g a b o o l t o d e t e r m i n e i f y o u c a n b u y o n e o f t h e b u y a b l e s . < / p > < / l i > < l i > < p > b u y ( ) : A f u n c t i o n t h a t i m p l e m e n t s b u y i n g o n e o f t h e b u y a b l e , i n c l u d i n g s p e n d i n g t h e c u r r e n c y . < / p > < / l i > < l i > < p > b u y M a x ( ) : < s t r o n g > o p t i o n a l < / s t r o n g > , A f u n c t i o n t h a t i m p l e m e n t s b u y i n g a s m a n y o f t h e b u y a b l e a s p o s s i b l e . < / p > < / l i > < l i > < p > s t y l e : < s t r o n g > O p t i o n a l < / s t r o n g > , A p p l i e s C S S t o t h i s b u y a b l e , i n t h e f o r m o f a n o b j e c t w h e r e t h e k e y s a r e C S S a t t r i b u t e s , a n d t h e v a l u e s a r e t h e v a l u e s f o r t h o s e a t t r i b u t e s ( b o t h a s s t r i n g s ) < / p > < / l i > < l i > < p > l a y e r : < s t r o n g > A s s i g n e d a u t o m a g i c a l l y < / s t r o n g > . I t & # 3 9 ; s t h e s a m e v a l u e a s t h e n a m e o f t h i s l a y e r , s o y o u c a n d o p l a y e r [ t h i s . l a y e r ] . p o i n t s o r s i m i l a r < / p > < / l i > < l i > < p > i d : < s t r o n g > A s s i g n e d a u t o m a g i c a l l y < / s t r o n g > . I t & # 3 9 ; s t h e & q u o t ; k e y & q u o t ; w h i c h t h e b u y a b l e w a s s t o r e d u n d e r , f o r c o n v e n i e n t a c c e s s . T h e b u y a b l e i n t h e e x a m p l e & # 3 9 ; s i d i s 1 1 . < / p > < / l i > < / u l > < p > S e l l O n e / S e l l A l l : < / p > < p > I n c l u d i n g a s e l l O n e o r s e l l A l l f u n c t i o n w i l l c a u s e a n a d d i t i o n a l b u t t o n t o a p p e a r b e n e a t h t h e b u y a b l e . T h e y a r e f u n c t i o n a l l y i d e n t i c a l , b u t & q u o t ; s e l l o n e & q u o t ; a p p e a r s a b o v e & q u o t ; s e l l a l l & q u o t ; . Y o u c a n a l s o u s e t h e m f o r o t h e r t h i n g s . < / p > < p > s e l l O n e / s e l l A l l ( ) : < s t r o n g > o p t i o n a l < / s t r o n g > , C a l l e d w h e n t h e b u t t o n i s p r e s s e d . T h e s t a n d a r d u s e w o u l d b e t o d e c r e a s e / r e s e t t h e a m o u n t o f t h e b u y a b l e , A n d p o s s i b l y r e t u r n s o m e c u r r e n c y t o t h e p l a y e r . < / p > < p > c a n S e l l O n e / c a n S e l l A l l ( ) : < s t r o n g > o p t i o n a l < / s t r o n g > , b o o l e a n s d e t e r m i n i n g w h e t h e r o r n o t t o s h o w t h e b u t t o n s . I f & q u o t ; c a n S e l l O n e / A l l & q u o t ; i s a b s e n t b u t & q u o t ; s e l l O n e / A l l & q u o t ; i s p r e s e n t , t h e a p p r o p r i a t e b u t t o n w i l l a l w a y s s h o w . < / p > ` , 1 1 ) , l = [ n ] ; f u n c t i o n o ( p , h , r , u , c , k ) { r e t u r n t ( ) , e ( " d i v " , n u l l , l ) } c o n s t b = s ( i , [ [ " r e n d e r " , o ] ] ) ; e x p o r t { y a s _ _ p a g e D a t a , b a s d e f a u l t } ;