2023-04-20 22:23:08 +00:00
import { _ as s , c as a , o as n , d as e } from "./app.c95a51e0.js" ; const b = JSON . parse ( '{"title":"Buyables","description":"","frontmatter":{},"headers":[],"relativePath":"public/kronos/docs/buyables.md","lastUpdated":null}' ) , l = { name : "public/kronos/docs/buyables.md" } , o = e ( ` <h1 id="buyables" tabindex="-1">Buyables <a class="header-anchor" href="#buyables" aria-hidden="true">#</a></h1><p>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.</p><p>The amount of a buyable owned is a <code>Decimal</code>.</p><p>Useful functions for dealing with buyables and implementing their effects:</p><ul><li>getBuyableAmount(layer, id): get the amount of the buyable the player has</li><li>setBuyableAmount(layer, id, amount): set the amount of the buyable the player has</li><li>buyableEffect(layer, id): Returns the current effects of the buyable, if any.</li></ul><p>Buyables should be formatted like this:</p><div class="language-js"><button title="Copy Code" class="copy"></button><span class="lang">js</span><pre class="shiki"><code><span class="line"><span style="color:#FFCB6B;">buyables</span><span style="color:#89DDFF;">:</span><span style="color:#A6ACCD;"> </span><span style="color:#89DDFF;">{</span></span>
2022-10-05 00:48:27 +00:00
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 1 1 < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > : < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > cost < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > x < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > n e w < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > D e c i m a l < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 1 < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > m u l < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > x < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > display < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > ( ) < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " c o l o r : # C 3 E 8 8 D ; " > B l a h < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > & q u o t ; < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > canAfford < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > ( ) < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > r e t u r n < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > [ < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ] < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p o i n t s < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > g t e < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > c o s t < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( ) ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > buy < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > ( ) < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > { < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > [ < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ] < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p o i n t s < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > = < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > [ < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ] < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > p o i n t s < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > s u b < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > c o s t < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( ) ) < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > s e t B u y a b l e A m o u n t < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > g e t B u y a b l e A m o u n t < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > l a y e r < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > , < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > t h i s . < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > i d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > . < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > a d d < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 1 < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > ) ) < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > e t c < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 9 D D F F ; " > } , < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#F07178;" > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > e t c < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#89DDFF;" > } < / s p a n > < / s p a n >
< span class = "line" > < / 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 p u r c h a s e . ( x i s a < c o d e > D e c i m a l < / c o d e > ) . 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 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 e f f e c t o f h a v i n g x o f t h e 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 > p u r c h a s e L i m i t : < s t r o n g > o p t i o n a l < / s t r o n g > . T h e l i m i t o n h o w m a n y o f t h e b u y a b l e c a n b e b o u g h t . T h e d e f a u l t i s n o l i m i t . < / p > < / l i > < l i > < p > m a r k e d : < s t r o n g > o p t i o n a l < / s t r o n g > A d d s a m a r k t o t h e c o r n e r o f t h e b u y a b l e . I f i t & # 3 9 ; s & q u o t ; t r u e & q u o t ; i t w i l l b e a s t a r , b u t i t c a n a l s o b e a n i m a g e U R L . < / 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 < c o d e > p l a y e r [ t h i s . l a y e r ] . p o i n t s < / c o d e > 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 < c o d e > s e l l O n e < / c o d e > o r < c o d e > s e l l A l l < / c o d e > 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 > < u l > < l i > < 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 > < / l i > < l i > < 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 > < / l i > < / u l > < p > T o a d d a r e s p e c b u t t o n , o r s o m e t h i n g s i m i l a r , a d d t h e r e s p e c B u y a b l e s f u n c t i o n t o t h e m a i n b u y a b l e s o b j e c t ( n o t i n d i v i d u a l b u y a b l e s ) . Y o u c a n u s e t h e s e f e a t u r e s a l o n g w i t h i t : < / p > < u l > < l i > < p > r e s p e c ( ) : < s t r o n g > o p t i o n a l < / s t r o n g > . T h i s i s 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 ( a f t e r a t o g g l e a b l e c o n f i r m a t i o n m e s s a g e ) . < / p > < / l i > < l i > < p > r e s p e c T e x t : < s t r o n g > o p t i o n a l < / s t r o n g > . T e x t t o d i s p l a y o n t h e r e s p e c B u t t o n . < / p > < / l i > < l i > < p > s h o w R e s p e c ( ) : < 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 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 , i f r e s p e c B u y a b l e s i s d e f i n e d . D e f a u l t s t o t r u e i f a b s e n t . < / p > < / l i > < l i > < p > r e s p e c M e s s a g e : < s t r o n g > o p t i o n a l < / s t r o n g > . A c u s t o m c o n f i r m a t i o n m e s s a g e o n r e s p e c , i n p l a c e o f t h e d e f a u l t o n e . < / p > < / l i > < / u l > ` , 1 4 ) , t = [ o ] ; f u n c t i o n p ( r , c , i , y , u , F ) { r e t u r n n ( ) , a ( " d i v " , n u l l , t ) } c o n s t D = s ( l , [ [ " r e n d e r " , p ] ] ) ; e x p o r t { b a s _ _ p a g e D a t a , D a s d e f a u l t } ;