Advertisement
Guest User

Spnati Cheats 2

a guest
Dec 21st, 2017
33,756
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*Instructions:
  2. To use this, simply open up the dev console (in Chrome and Firefox, this is done with CTRL+SHIFT+I)
  3. Select all in this file, then literally copy-paste it into the console that comes up, and hit enter.
  4. Call the function by writing it's name, and subbing out the parameter names for the values you want to use, for example:
  5. stripAllToLevel(2)
  6. */
  7.  
  8. var spnati_cheat_suits_list = ["heart", "clubs", "diamo", "spade"]
  9.  
  10. function validSuitOrDefault(suit, def){
  11.     /* Takes a suit as input. If the suit isn't a valid SPNATI suit name, then the specified default value is returned instead.
  12.         suit - The suit string to test.
  13.         def - The default value to return in the invalid case.
  14.     */
  15.     return  (spnati_cheat_suits_list.indexOf(suit) !== -1) ? suit : def;  
  16. }
  17.  
  18. function stripAllNaked(){
  19.     /*Strip everyone (except the PC) naked such that one round is left before they lose.*/
  20.     stripAllToLevel(1);
  21. }
  22.  
  23. function stripNaked(player){
  24.     /*Strip all layers off of a given player (0 is the PC, 1-4 are NPCs).
  25.       Params: player - Integer (0 is the PC, 1-4 are NPCs)
  26.     */
  27.     stripToLevel(player, 1);
  28. }
  29.  
  30. function autoWin(){
  31.     /*Automatically win.*/
  32.     stripAllToLevel(0);
  33. }
  34.  
  35. function stripAllToLevel(level){
  36.     /*Strip all players (except the PC) down so that they have at most _level_ number of layers left.
  37.       Params: level - Integer (The number of layers to leave left on a player.)
  38.     */
  39.     for(var i = 1; i < players.length; i++){
  40.         stripToLevel(i, level);
  41.     }
  42. }
  43.  
  44. function stripToLevel(player, level){
  45.     /*Strip a player down such that they only have (at most) a certain number of layers left.
  46.       Params: player - Integer (0 is the PC, 1-4 are NPCs)
  47.               level - Integer (The number of layers to leave left on a player.)
  48.     */
  49.     for (var c = countClothing(player); c >= level; c--){stripChoice(player);}
  50. }
  51.  
  52. function countClothing(player){
  53.     /* Count the clothing the player has remaining.
  54.        Params: Player - integer (0 is the PC, 1-4 are NPCs)
  55.     */
  56.     var clothes = 0;
  57.     for (var i = 0; i < players[player].clothing.length; i++) {
  58.         if (players[player] && players[player].clothing[i]) {
  59.             clothes++;
  60.         }
  61.     }
  62.     return clothes;
  63. }
  64.  
  65. function multiStripChoice(player, times){
  66.     /* Strip the indicated player of multiple layer.
  67.        Params: Player - integer (0 is the PC, 1-4 are NPCs)
  68.                times - integer (The number of layers to try to strip.)
  69.     */
  70.     for(var i = 0; (i < times) && (countClothing(player) != -1); i++){
  71.         stripChoice(player);
  72.     }
  73. }
  74.  
  75. function stripChoice(player){
  76.     /* Strip the indicated player of a single layer.
  77.        Params: Player - integer (0 is the PC, 1-4 are NPCs)
  78.     */
  79.     stripPlayer(player);
  80.     updateAllGameVisuals();
  81. }
  82.  
  83. function randomBackground(){
  84.     /*
  85.         Choose a random background from those available.
  86.     */
  87.     //Note this randint helper function could either be inlined or broken out into an actual function.
  88.     var randint = function(a,b){
  89.         return (function(n,x){
  90.                     return Math.floor(Math.random()*(x-n)+n);
  91.                 })(Math.min(a,b), Math.max(a,b));
  92.     };
  93.     setBackground(function(){var a = randint(0,23); console.log(a); return a;}());
  94. }
  95.  
  96. function unlockAllEndings(){
  97.     /*
  98.         Unlocks all the endings in the gallery mode.
  99.         NOTE: You can access the gallery by using the
  100.         command "loadGalleryScreen()" from the main menu.
  101.     */
  102.     for(var i = 0; i < galleryEndings.length; i++)
  103.     {
  104.         galleryEndings[i].unlocked = true;
  105.     }  
  106. }
  107.  
  108. function givePlayerRoyalStraightFlush(player_number, suit){
  109.     /*
  110.         Gives the target player a royal straight flush of any desired suit.
  111.         player_number - An integer representing the player index getting the cards (0 -> player, 1-4 -> npcs)
  112.         suit - A string representing the suit (options are shown in the suits array below)
  113.     */
  114.     var chosen_suit = validSuitOrDefault(suit, spnati_cheat_suits_list[0]);
  115.     hands[player_number].cards = [chosen_suit+"1", chosen_suit+"13", chosen_suit+"12", chosen_suit+"11", chosen_suit+"10"]
  116. }
  117.  
  118. function giveSelfRoyalStraightFlush(suit){
  119.     /*
  120.         Gives the player a royal straight flush of the target suit.
  121.         suit - suit - A string representing the suit (either "heart", "clubs", "spade" or "diamo")
  122.     */
  123.     givePlayerRoyalStraightFlush(0, suit);
  124. }
  125.  
  126. var givePlayerRoyalStraightFlushFunctorMap = function(){
  127.     //This auto-gens a lookup table for the enableAutoRoyalStraightFlush functions.
  128.     var map = {};
  129.     for(var i = 0; i < players.length; i++){
  130.         map[i] = {}
  131.         for(var j = 0; j < spnati_cheat_suits_list.length; j++){
  132.            
  133.         map[i][spnati_cheat_suits_list[j]] = function(i, j){return function(){givePlayerRoyalStraightFlush(i, spnati_cheat_suits_list[j])};}(i,j); //This double annon function is because closures in javascript are weird.
  134.         }
  135.     }
  136.     return map;
  137. }();
  138.  
  139. function enableAutoRoyalStraightFlush(player_number, suit){
  140.     /*
  141.         Constantly gives the player a royal straight flush of the chosen suit, every single turn.
  142.         Note if this is done multiple times for different suits on the same player, only one of the suits will be shown
  143.         depending on order of application.
  144.         player_number - An integer representing the player index getting the cards (0 -> player, 1-4 -> npcs)
  145.         suit - A string representing the suit (either "heart", "clubs", "spade" or "diamo")
  146.     */
  147.     suit = validSuitOrDefault(suit, spnati_cheat_suits_list[0]);
  148.     document.getElementById("main-game-button").addEventListener("click", givePlayerRoyalStraightFlushFunctorMap[player_number][suit]);
  149. }
  150.  
  151. function disableAutoRoyalStraightFlush(player_number, suit){
  152.     /*
  153.         Disables a previously set "enableAutoRoyalStraightFlush" for a particular player and suit.
  154.         player_number - An integer representing the player index getting the cards (0 -> player, 1-4 -> npcs)
  155.         suit - A string representing the suit (either "heart", "clubs", "spade" or "diamo")
  156.     */
  157.     suit = validSuitOrDefault(suit, spnati_cheat_suits_list[0]);
  158.     document.getElementById("main-game-button").removeEventListener("click", givePlayerRoyalStraightFlushFunctorMap[player_number][suit]);
  159. }
  160.  
  161. function disableAllAutoRoyalStraightFlush(player_number){
  162.         for(var i = 0; i < spnati_cheat_suits_list.length; i++){
  163.             document.getElementById("main-game-button").removeEventListener("click", givePlayerRoyalStraightFlushFunctorMap[player_number][spnati_cheat_suits_list[i]]);
  164.         }
  165. }
  166.  
  167. function enableSelfRoyalStraightFlush(){
  168.     enableAutoRoyalStraightFlush(0, "heart");
  169. }
  170.  
  171. function disableSelfRoyalStraightFlush(){
  172.     disableAutoRoyalStraightFlush(0, "heart");
  173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement