x8c8r

Cookie Clicker gifts explained

Mar 15th, 2023
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. 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.
  2.  
  3. How gifts get created (Note: After every parameter a pipe(|) symbol is added:
  4. - New string is created (named "str")
  5. - "MAIL" is added to it, it's used to indicate that the code, is a mail(gift) code
  6. - Current Date.now() timestamp is added, it is later used to check the gift's age when redeeming the code
  7. - 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"
  8. - Next, the giftbox design is added. If it's not specified ("none"/"-"/undefined), then 0 is used as a value (default gift).
  9. - After that, the message itself is added. It is forsibly cut to be just 4 lines long and 100 characters long.
  10. - "str" gets encrypted with Base64 and returned to the user as a gift code, they can send to other users.
  11.  
  12. 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.
  13.  
  14. Now, how the gifts are redeemed:
  15. - First the game decrypts the code from Base64 back into a string
  16. - Then it checks to see if the string is even a thing, if it's not, it returns with "false"
  17. - The game looks for the "MAIL" at the beginning, if it doesn't it returns with "false"
  18. - 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)
  19. - If it has been more than 2 days since the timestamp, it returns with -1
  20. - After that, the cookie amount is determined, once again being capped at 1 and 1000 cookies
  21. - The giftbox design is retrieved, this time not accepting "none" or undefined as potential options
  22. - Lastly, the message is retrieved, also still capped at the same limits as before
  23. - If every check is successful, a gift is returned
  24.  
  25. As for the redeem prompt itself:
  26. - It passes the giftcode to the function that returns the gift (previous paragraph)
  27. - 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
  28.  
  29. If the redeem button is pressed then the following function executes:
  30. - The game gives player the cookies via "Game.Earn()", as well as adding the amount to "Game.cookiesReceived" variable
  31. - 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