Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Instructions:
- To use this, simply open up the dev console (in Chrome and Firefox, this is done with CTRL+SHIFT+I)
- Select all in this file, then literally copy-paste it into the console that comes up, and hit enter.
- Call the function by writing it's name, and subbing out the parameter names for the values you want to use, for example:
- stripAllToLevel(2)
- */
- var spnati_cheat_suits_list = ["heart", "clubs", "diamo", "spade"]
- function validSuitOrDefault(suit, def){
- /* Takes a suit as input. If the suit isn't a valid SPNATI suit name, then the specified default value is returned instead.
- suit - The suit string to test.
- def - The default value to return in the invalid case.
- */
- return (spnati_cheat_suits_list.indexOf(suit) !== -1) ? suit : def;
- }
- function stripAllNaked(){
- /*Strip everyone (except the PC) naked such that one round is left before they lose.*/
- stripAllToLevel(1);
- }
- function stripNaked(player){
- /*Strip all layers off of a given player (0 is the PC, 1-4 are NPCs).
- Params: player - Integer (0 is the PC, 1-4 are NPCs)
- */
- stripToLevel(player, 1);
- }
- function autoWin(){
- /*Automatically win.*/
- stripAllToLevel(0);
- }
- function stripAllToLevel(level){
- /*Strip all players (except the PC) down so that they have at most _level_ number of layers left.
- Params: level - Integer (The number of layers to leave left on a player.)
- */
- for(var i = 1; i < players.length; i++){
- stripToLevel(i, level);
- }
- }
- function stripToLevel(player, level){
- /*Strip a player down such that they only have (at most) a certain number of layers left.
- Params: player - Integer (0 is the PC, 1-4 are NPCs)
- level - Integer (The number of layers to leave left on a player.)
- */
- for (var c = countClothing(player); c >= level; c--){stripChoice(player);}
- }
- function countClothing(player){
- /* Count the clothing the player has remaining.
- Params: Player - integer (0 is the PC, 1-4 are NPCs)
- */
- var clothes = 0;
- for (var i = 0; i < players[player].clothing.length; i++) {
- if (players[player] && players[player].clothing[i]) {
- clothes++;
- }
- }
- return clothes;
- }
- function multiStripChoice(player, times){
- /* Strip the indicated player of multiple layer.
- Params: Player - integer (0 is the PC, 1-4 are NPCs)
- times - integer (The number of layers to try to strip.)
- */
- for(var i = 0; (i < times) && (countClothing(player) != -1); i++){
- stripChoice(player);
- }
- }
- function stripChoice(player){
- /* Strip the indicated player of a single layer.
- Params: Player - integer (0 is the PC, 1-4 are NPCs)
- */
- stripPlayer(player);
- updateAllGameVisuals();
- }
- function randomBackground(){
- /*
- Choose a random background from those available.
- */
- //Note this randint helper function could either be inlined or broken out into an actual function.
- var randint = function(a,b){
- return (function(n,x){
- return Math.floor(Math.random()*(x-n)+n);
- })(Math.min(a,b), Math.max(a,b));
- };
- setBackground(function(){var a = randint(0,23); console.log(a); return a;}());
- }
- function unlockAllEndings(){
- /*
- Unlocks all the endings in the gallery mode.
- NOTE: You can access the gallery by using the
- command "loadGalleryScreen()" from the main menu.
- */
- for(var i = 0; i < galleryEndings.length; i++)
- {
- galleryEndings[i].unlocked = true;
- }
- }
- function givePlayerRoyalStraightFlush(player_number, suit){
- /*
- Gives the target player a royal straight flush of any desired suit.
- player_number - An integer representing the player index getting the cards (0 -> player, 1-4 -> npcs)
- suit - A string representing the suit (options are shown in the suits array below)
- */
- var chosen_suit = validSuitOrDefault(suit, spnati_cheat_suits_list[0]);
- hands[player_number].cards = [chosen_suit+"1", chosen_suit+"13", chosen_suit+"12", chosen_suit+"11", chosen_suit+"10"]
- }
- function giveSelfRoyalStraightFlush(suit){
- /*
- Gives the player a royal straight flush of the target suit.
- suit - suit - A string representing the suit (either "heart", "clubs", "spade" or "diamo")
- */
- givePlayerRoyalStraightFlush(0, suit);
- }
- var givePlayerRoyalStraightFlushFunctorMap = function(){
- //This auto-gens a lookup table for the enableAutoRoyalStraightFlush functions.
- var map = {};
- for(var i = 0; i < players.length; i++){
- map[i] = {}
- for(var j = 0; j < spnati_cheat_suits_list.length; j++){
- 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.
- }
- }
- return map;
- }();
- function enableAutoRoyalStraightFlush(player_number, suit){
- /*
- Constantly gives the player a royal straight flush of the chosen suit, every single turn.
- Note if this is done multiple times for different suits on the same player, only one of the suits will be shown
- depending on order of application.
- player_number - An integer representing the player index getting the cards (0 -> player, 1-4 -> npcs)
- suit - A string representing the suit (either "heart", "clubs", "spade" or "diamo")
- */
- suit = validSuitOrDefault(suit, spnati_cheat_suits_list[0]);
- document.getElementById("main-game-button").addEventListener("click", givePlayerRoyalStraightFlushFunctorMap[player_number][suit]);
- }
- function disableAutoRoyalStraightFlush(player_number, suit){
- /*
- Disables a previously set "enableAutoRoyalStraightFlush" for a particular player and suit.
- player_number - An integer representing the player index getting the cards (0 -> player, 1-4 -> npcs)
- suit - A string representing the suit (either "heart", "clubs", "spade" or "diamo")
- */
- suit = validSuitOrDefault(suit, spnati_cheat_suits_list[0]);
- document.getElementById("main-game-button").removeEventListener("click", givePlayerRoyalStraightFlushFunctorMap[player_number][suit]);
- }
- function disableAllAutoRoyalStraightFlush(player_number){
- for(var i = 0; i < spnati_cheat_suits_list.length; i++){
- document.getElementById("main-game-button").removeEventListener("click", givePlayerRoyalStraightFlushFunctorMap[player_number][spnati_cheat_suits_list[i]]);
- }
- }
- function enableSelfRoyalStraightFlush(){
- enableAutoRoyalStraightFlush(0, "heart");
- }
- function disableSelfRoyalStraightFlush(){
- disableAutoRoyalStraightFlush(0, "heart");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement