2023-04-23 16:35:03 +00:00
import { _ as s , c as e , o as a , N as n } from "./chunks/framework.0799945b.js" ; const F = JSON . parse ( '{"title":"Prestige Mechanic","description":"","frontmatter":{},"headers":[],"relativePath":"guide/recipes/prestige.md","lastUpdated":1682267650000}' ) , o = { name : "guide/recipes/prestige.md" } , t = n ( ` <h1 id="prestige-mechanic" tabindex="-1">Prestige Mechanic <a class="header-anchor" href="#prestige-mechanic" aria-label="Permalink to "Prestige Mechanic""> </a></h1><p>Prestige mechanics are a common feature in incremental games. They involve resetting a portion of the game's progress in exchange for a new currency that persists between these resets. Many games even have multiple layers of reset mechanics, each resetting everything that came before them.</p><h2 id="create-a-conversion" tabindex="-1">Create a conversion <a class="header-anchor" href="#create-a-conversion" aria-label="Permalink to "Create a conversion""> </a></h2><p>The first step is to create a conversion that will handle calculating the amount of prestige currency generated. In our example, let's assume there's a base layer called <code>main</code> and a prestige layer called <code>prestige</code>. This conversion will be based on the amount of <code>points</code> the player has, a resource within <code>main</code>. Here's an example conversion, using the formula from <a href="https://jacorb90.me/Prestige-Tree/" target="_blank" rel="noreferrer">The Prestige Tree</a>'s prestige layer:</p><div class="language-ts"><button title="Copy Code" class="copy"></button><span class="lang">ts</span><pre class="shiki material-theme-palenight"><code><span class="line"><span style="color:#C792EA;">const</span><span style="color:#A6ACCD;"> conversion </span><span style="color:#89DDFF;">=</span><span style="color:#A6ACCD;"> </span><span style="color:#82AAFF;">createCumulativeConversion</span><span style="color:#A6ACCD;">(</span><span style="color:#89DDFF;">()</span><span style="color:#A6ACCD;"> </span><span style="color:#C792EA;">=></span><span style="color:#A6ACCD;"> (</span><span style="color:#89DDFF;">{</span></span>
2023-04-19 05:06:57 +00:00
< span class = "line" > < span style = "color:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > b a s e R e s o u r c e < / 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 ; " > m a i n < / 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 >
< span class = "line" > < span style = "color:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > g a i n R e s o u r c e < / 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 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > n o P e r s i s t < / 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 >
< span class = "line" > < span style = "color:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > f o r m u l a < / 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 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; f o n t - s t y l e : i t a l i c ; " > x < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > = & g t ; < / 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 : # 8 2 A A F F ; " > d i v < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > ( < / 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 0 < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 : # 8 2 A A F F ; " > s q r t < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > ( ) < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#89DDFF;" > } < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 > < / c o d e > < / p r e > < / d i v > < p > I n t h i s c a s e , < c o d e > p o i n t s < / c o d e > r e f e r s t o < c o d e > p r e s t i g e . p o i n t s < / c o d e > , a s i t & # 3 9 ; s w i t h i n t h e < c o d e > p r e s t i g e < / c o d e > l a y e r . < / p > < h 2 i d = " c r e a t e - a - r e s e t - b u t t o n " t a b i n d e x = " - 1 " > C r e a t e a r e s e t b u t t o n < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # c r e a t e - a - r e s e t - b u t t o n " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; C r e a t e a r e s e t b u t t o n & q u o t ; " > < / a > < / h 2 > < p > N e x t , c r e a t e a b u t t o n t h a t w i l l p e r f o r m t h e r e s e t a n d g e n e r a t e p o i n t s . C r e a t e a c l i c k a b l e l i k e t h i s : < / p > < d i v c l a s s = " l a n g u a g e - t s " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > t s < / s p a n > < p r e c l a s s = " s h i k i m a t e r i a l - t h e m e - p a l e n i g h t " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > c o n s t < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > c o n v e r t B u t t o n < / 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 ; " > < / 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 r e a t e C l i c k a b l e < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 : # A 6 A C C D ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > = & g t ; < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 >
< span class = "line" > < span style = "color:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > r e q u i r e m e 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 : # A 6 A C C D ; " > < / 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 r e a t e B o o l e a n R e q u i r e m e n t < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 : # A 6 A C C D ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > = & g t ; < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > 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 : # 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 < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > ( < / s p a n > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > u n r e 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 ; " > ( c o n v e r s i o n < / 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 ; " > a c t u a l G a i n ) < / 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 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # F 7 8 C 6 C ; " > 0 < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 >
< span class = "line" > < span style = "color:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > d i s p l a y < / 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 ; " > < / 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:#A6ACCD;" > < / 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 s c r i p t i o n < / 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 ; " > < / 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 ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > = & g t ; < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 : # C 3 E 8 8 D ; " > R e s e t f o 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 : # 8 2 A A F F ; " > f o r m a t W h o l e < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > ( c o n v e r s i o n < / 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 ; " > c u r r e n t G a i n ) < / 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 : # C 3 E 8 8 D ; " > p r e s t i g e 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 >
< span class = "line" > < span style = "color:#A6ACCD;" > < / 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:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > o n C l i c k < / 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 ; " > < / 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 ; " > c o n v e r s i o n < / 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 ; " > c o n v e r 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;" > < / 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:#89DDFF;" > } < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 > < / c o d e > < / p r e > < / d i v > < p > T h i s c r e a t e s a s i m p l e c l i c k a b l e t h a t c a n o n l y b e c l i c k e d w h e n t h e p l a y e r w i l l g a i n s o m e a m o u n t o f t h e p r e s t i g e c u r r e n c y , a n d i t d i s p l a y s h o w m u c h t h e y & # 3 9 ; l l g e t . T h i s c a n b e f u r t h e r i m p r o v e d b y d i s p l a y i n g h o w m a n y p o i n t s t h e p l a y e r w i l l n e e d t o g e n e r a t e o n e m o r e p r e s t i g e p o i n t . < / p > < h 2 i d = " r e s e t t i n g - p r e v i o u s - c o n t e n t " t a b i n d e x = " - 1 " > R e s e t t i n g p r e v i o u s c o n t e n t < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # r e s e t t i n g - p r e v i o u s - c o n t e n t " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; R e s e t t i n g p r e v i o u s c o n t e n t & q u o t ; " > < / a > < / h 2 > < p > N o w , r e t u r n t o t h e < c o d e > m a i n < / c o d e > l a y e r . C r e a t e a < c o d e > r e s e t < / c o d e > f e a t u r e t h a t r e c e i v e s a l i s t o f a l l t h e t h i n g s i t n e e d s t o r e s e t - i n t h i s e x a m p l e , w e & # 3 9 ; l l j u s t r e s e t t h e e n t i r e l a y e r : < / p > < d i v c l a s s = " l a n g u a g e - t s " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > t s < / s p a n > < p r e c l a s s = " s h i k i m a t e r i a l - t h e m e - p a l e n i g h t " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > c o n s t < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > r e s e t < / 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 ; " > < / 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 r e a t e R e s e t < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 : # A 6 A C C D ; " > < / s p a n > < s p a n s t y l e = " c o l o r : # C 7 9 2 E A ; " > = & g t ; < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 >
< span class = "line" > < span style = "color:#A6ACCD;" > < / s p a n > < s p a n s t y l e = " c o l o r : # F 0 7 1 7 8 ; " > t h i n g s T o R e s e t < / 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 ; " > [ l a y e r ] < / s p a n > < / s p a n >
< span class = "line" > < span style = "color:#89DDFF;" > } < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 > < / c o d e > < / p r e > < / d i v > < p > T h e n , m o d i f y t h e c o n v e r t b u t t o n t o t r i g g e r t h e r e s e t : < / p > < d i v c l a s s = " l a n g u a g e - t s " > < b u t t o n t i t l e = " C o p y C o d e " c l a s s = " c o p y " > < / b u t t o n > < s p a n c l a s s = " l a n g " > t s < / s p a n > < p r e c l a s s = " s h i k i m a t e r i a l - t h e m e - p a l e n i g h t " > < c o d e > < s p a n c l a s s = " l i n e " > < s p a n s t y l e = " c o l o r : # 8 2 A A F F ; " > o n C l i c k < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C 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 >
< 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 ; " > c o n v e r s i o n < / 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 ; " > c o n v e r 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;" > < / s p a n > < s p a n s t y l e = " c o l o r : # A 6 A C C D ; " > r e s e t < / 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 ; " > r e s e 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:#89DDFF;" > } < / s p a n > < / s p a n > < / c o d e > < / p r e > < / d i v > < p > I f y o u h a v e m u l t i p l e t i e r s o f r e s e t s , y o u m a y a d d a n < c o d e > o n R e s e t < / c o d e > f u n c t i o n t o e a c h r e s e t t h a t t r i g g e r s t h e n e x t r e s e t b e f o r e i t , c a u s i n g t h e r e s e t s t o c a s c a d e . < / p > < h 2 i d = " b r a n c h i n g - r e s e t s " t a b i n d e x = " - 1 " > B r a n c h i n g r e s e t s < a c l a s s = " h e a d e r - a n c h o r " h r e f = " # b r a n c h i n g - r e s e t s " a r i a - l a b e l = " P e r m a l i n k t o & q u o t ; B r a n c h i n g r e s e t s & q u o t ; " > < / a > < / h 2 > < p > A c o m m o n p a t t e r n f o r r e s e t m e c h a n i c s i s t o d i s p l a y t h e s e v a r i o u s l a y e r s i n a t r e e a n d h a v e t h e t r e e p r o p a g a t e t h e r e s e t s f o r y o u . T h e r e a r e a c o u p l e o f u t i l i t y f u n c t i o n s t o h e l p y o u a c c o m p l i s h t h i s : < a h r e f = " . / . . / . . / a p i / m o d u l e s / d a t a / c o m m o n # c r e a t e r e s e t b u t t o n " > c r e a t e R e s e t B u t t o n < / a > a n d < a h r e f = " . / . . / . . / a p i / m o d u l e s / d a t a / c o m m o n # c r e a t e l a y e r t r e e n o d e " > c r e a t e L a y e r T r e e N o d e < / a > . Y o u & # 3 9 ; l l t y p i c a l l y p l a c e t h e t r e e i t s e l f i n t h e < c o d e > m a i n < / c o d e > l a y e r a n d c r e a t e a t r e e n o d e f o r e a c h l a y e r . T h e n y o u c a n c a l l t h e t r e e & # 3 9 ; s < c o d e > r e s e t < / c o d e > f u n c t i o n w i t h t h e l a y e r t h a t & # 3 9 ; s r e s e t t i n g , a n d i t w i l l p r o p a g a t e t h e r e s e t a s a p p r o p r i a t e . < / p > ` , 1 8 ) , l = [ t ] ; f u n c t i o n p ( r , c , i , y , D , A ) { r e t u r n a ( ) , e ( " d i v " , n u l l , l ) } c o n s t h = s ( o , [ [ " r e n d e r " , p ] ] ) ; e x p o r t { F a s _ _ p a g e D a t a , h a s d e f a u l t } ;