Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Cookie Clicker's 08/08/2022 update introduced a heavenly upgrade "Wrapping paper" which allows the player to make a gift with up to 1000 cookies and a note consisting of up to 100 characters and 4 lines. What is interesting, however, is that the gifts are made with a simple algorithm and are not connected to any server.
- How gifts get created (Note: After every parameter a pipe(|) symbol is added:
- - New string is created (named "str")
- - "MAIL" is added to it, it's used to indicate that the code, is a mail(gift) code
- - Current Date.now() timestamp is added, it is later used to check the gift's age when redeeming the code
- - Then, the cookie amount itself is added, it is capped at 1 and 1000 respectively, and has a hard check on both creation and redeeming to make sure it doesn't go beyond that limit. After that the specified cookie amount is deducted from player's bank using "Game.Spend()", as well as being added to "Game.cookiesSent"
- - Next, the giftbox design is added. If it's not specified ("none"/"-"/undefined), then 0 is used as a value (default gift).
- - After that, the message itself is added. It is forsibly cut to be just 4 lines long and 100 characters long.
- - "str" gets encrypted with Base64 and returned to the user as a gift code, they can send to other users.
- As you might have guessed, you can easily generate your own gifts for free and without getting the "Gifted out" debuff by just doing all the steps above.
- Now, how the gifts are redeemed:
- - First the game decrypts the code from Base64 back into a string
- - Then it checks to see if the string is even a thing, if it's not, it returns with "false"
- - The game looks for the "MAIL" at the beginning, if it doesn't it returns with "false"
- - Then the game converts the Date.now() timestamp into days using this snippet of code: "Math.abs(Date.now()-val)>1000*60*60*24*2" (where val is the timestamp)
- - If it has been more than 2 days since the timestamp, it returns with -1
- - After that, the cookie amount is determined, once again being capped at 1 and 1000 cookies
- - The giftbox design is retrieved, this time not accepting "none" or undefined as potential options
- - Lastly, the message is retrieved, also still capped at the same limits as before
- - If every check is successful, a gift is returned
- As for the redeem prompt itself:
- - It passes the giftcode to the function that returns the gift (previous paragraph)
- - If the returned value is -1 it tells the user that the code expired, if it's false, then it tells the user the code is invalid
- If the redeem button is pressed then the following function executes:
- - The game gives player the cookies via "Game.Earn()", as well as adding the amount to "Game.cookiesReceived" variable
- - The game closes the redeem prompt and opens a new gift prompt which shows the giftbox design, message and the amount of cookies received
Add Comment
Please, Sign In to add comment