Advertisement
PapstJL4U

2W0B0xn9.js from the guiltygear character quiz

Jan 23rd, 2018
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. emotemultiplier = 1; // Multiplier for how much emotional/subjective qualities affect results - becomes 1.5 if player specifies this is important to him or her
  2. doubleplay = 0; // Value for double playstyle. To be given 0.5 if zoning or rushdown are given a positive value. If it's 1, the doubleplay question is revealed.
  3.  
  4. function addEmotion(name) {
  5.     $.each(chardata.characters, function(i, v) {
  6.         if (v.charname.indexOf(name) > -1) {
  7.             v.Points=v.Points+(1*emotemultiplier);
  8.             return;
  9.         }
  10.     });
  11. }
  12.  
  13. function hateEmotion(name) {
  14.     $.each(chardata.characters, function(i, v) {
  15.         if (v.charname.indexOf(name) > -1) {
  16.             v.Points=v.Points-(1*emotemultiplier);
  17.             return;
  18.         }
  19.     });
  20. }
  21.  
  22. $( document ).ready(function() {
  23.     $.ajaxSetup({ cache: false });
  24.     $('#doubleplay').hide(0);
  25.     $('#results').hide(0);
  26.     $.getJSON( "./profiles.json", function( data ) {
  27.       var items = "";
  28.      
  29.     $( ".storyQ img" ).click(function() {
  30.         var charname = $( this ).attr('id');
  31.         var res = charname.split(".");
  32.         var charname = res[0];
  33.         addEmotion(charname);
  34.     });
  35.     $( ".hateQ img" ).click(function() {
  36.         var charname = $( this ).attr('id');
  37.         var res = charname.split(".");
  38.         var charname = res[0];
  39.         hateEmotion(charname);
  40.     });
  41.    
  42.     $( ".question a" ).click(function() {
  43.         $(this).parent().closest('.question').hide(100);
  44.     });
  45.    
  46.     /*  // For debugging purposes
  47.     $( document ).click(function() {
  48.         getResults();
  49.     });
  50.     */
  51.  
  52.  
  53.      
  54.  
  55.    
  56.     //  for (i = 0;i < data.characters.length;i++) {
  57.     //  items = items+' '+data.characters[i].charname + ' ' + data.characters[i].Points + ' tier';     
  58.     //  }
  59.      
  60.     //  alert(items);
  61.     chardata = data;
  62.  
  63.      
  64.     });
  65. });
  66.  
  67. function upgradeTier(tier) {
  68.     $.each(chardata.characters, function(i, v) {
  69.         if (v.Tier == tier) {
  70.             v.Points++;
  71.             return;
  72.         }
  73.     });
  74. }
  75.  
  76. function pickPlaystyle(playstyle) {
  77.     if (playstyle == "Emotional") {
  78.         emotemultiplier = 1.5;
  79.         return
  80.     }
  81.     $.each(chardata.characters, function(i, v) {
  82.         if (v.Playstyle == playstyle) {
  83.             v.Points++;
  84.             return;
  85.         }
  86.     });
  87. }
  88.  
  89. function playerSkill(skill) {
  90.     $.each(chardata.characters, function(i, v) {
  91.         if (v.Skill == skill) {
  92.             v.Points++;
  93.             return;
  94.         }
  95.     });
  96. }
  97.  
  98. function playerGoal(goal) {
  99.     $.each(chardata.characters, function(i, v) {
  100.         if (v.SkillGoal == goal) {
  101.             v.Points++;
  102.             return;
  103.         }
  104.     });
  105. }
  106.  
  107. function doZoning(factor) {
  108.     if (factor > 0) {
  109.         playPriority();
  110.     }
  111.     $.each(chardata.characters, function(i, v) {
  112.         var modifier = (factor * v.Zoning);
  113.         v.Points=v.Points+modifier;
  114.         return;
  115.     });
  116. }
  117.  
  118. function doRushdown(factor) {
  119.     if (factor > 0) {
  120.         playPriority();
  121.     }
  122.     $.each(chardata.characters, function(i, v) {
  123.         var modifier = (factor * v.Rushdown);
  124.         v.Points=v.Points+modifier;
  125.         return;
  126.     });
  127. }
  128.  
  129. function playPriority() {
  130.     doubleplay = doubleplay+0.5;
  131.     if (doubleplay == 1) {
  132.         $('#doubleplay').show(0);
  133.     }
  134. }
  135.  
  136. function doDoublePlay(factor) {
  137.     $.each(chardata.characters, function(i, v) {
  138.         if (v.Zoning > 0 && v.Zoning < 1 && v.Rushdown > 0 && v.Rushdown < 1) {
  139.             var increase = (v.Zoning*factor)+(v.Rushdown*factor);
  140.             //alert("Increase of "+increase+"!");
  141.             v.Points = v.Points + increase;
  142.             return;
  143.         }
  144.     });
  145. }
  146.  
  147. function playerFocus(focus) {
  148.     $.each(chardata.characters, function(i, v) {
  149.         if (v.Focus.indexOf(focus) > -1) {
  150.             v.Points++;
  151.             return;
  152.         }
  153.     });
  154. }
  155.  
  156. function playerRange(range) {
  157.     $.each(chardata.characters, function(i, v) {
  158.         if (v.Range.indexOf(range) > -1) {
  159.             v.Points++;
  160.             return;
  161.         }
  162.     });
  163. }
  164.  
  165. function playerGender(gender,factor) {
  166.     $.each(chardata.characters, function(i, v) {
  167.         if (v.Gender.indexOf(gender) > -1) {
  168.             v.Points=v.Points+factor;
  169.             return;
  170.         }
  171.     });
  172. }
  173.  
  174. function playerCharge(charge) {
  175.     $.each(chardata.characters, function(i, v) {
  176.         if (v.Charge.indexOf(charge) > -1) {
  177.             v.Points++;
  178.             return;
  179.         }
  180.     });
  181. }
  182.  
  183. function playerGimmick(gimmick) {
  184.     $.each(chardata.characters, function(i, v) {
  185.         if (v.Gimmick.indexOf(gimmick) > -1) {
  186.             v.Points++;
  187.             return;
  188.         }
  189.     });
  190. }
  191.  
  192. function playerMixups(mixup) {
  193.     $.each(chardata.characters, function(i, v) {
  194.         if (v.Mixups.indexOf(mixup) > -1) {
  195.             v.Points++;
  196.             return;
  197.         }
  198.     });
  199. }
  200.  
  201. function playerMoral(moral) {
  202.     $.each(chardata.characters, function(i, v) {
  203.         if (v.Moral.indexOf(moral) > -1) {
  204.             v.Points = v.Points + emotemultiplier;
  205.             return;
  206.         }
  207.     });
  208. }
  209.  
  210. function playerOne(oneplayer) {
  211.     $.each(chardata.characters, function(i, v) {
  212.         if (v.OnePlayer.indexOf(oneplayer) > -1) {
  213.             v.Points++;
  214.             return;
  215.         }
  216.     });
  217. }
  218.  
  219.  
  220. function playerPriority(priority) {
  221.     $.each(chardata.characters, function(i, v) {
  222.         if (v.Priority.indexOf(priority) > -1) {
  223.             v.Points++;
  224.             return;
  225.         }
  226.     });
  227. }
  228.  
  229. function playerProjectile(projectile) {
  230.     $.each(chardata.characters, function(i, v) {
  231.         if (v.Projectile.indexOf(projectile) > -1) {
  232.             v.Points++;
  233.             return;
  234.         }
  235.     });
  236. }
  237.  
  238. function playerReliant(reliance) {
  239.     $.each(chardata.characters, function(i, v) {
  240.         if (v.Reliance.indexOf(reliance) > -1) {
  241.             v.Points++;
  242.             return;
  243.         }
  244.     });
  245. }
  246.  
  247. function playerResource(resource) {
  248.     $.each(chardata.characters, function(i, v) {
  249.         if (v.Resource.indexOf(resource) > -1) {
  250.             v.Points++;
  251.             return;
  252.         }
  253.     });
  254. }
  255.  
  256. function playerReversal(reversal) {
  257.     $.each(chardata.characters, function(i, v) {
  258.         if (v.Reversal.indexOf(reversal) > -1) {
  259.             v.Points++;
  260.             return;
  261.         }
  262.     });
  263. }
  264.  
  265. function playerSetPlay(setplay) {
  266.     $.each(chardata.characters, function(i, v) {
  267.         if (v.SetPlay.indexOf(setplay) > -1) {
  268.             v.Points++;
  269.             return;
  270.         }
  271.     });
  272. }
  273.  
  274.  
  275. function playerStances(stance) {
  276.     $.each(chardata.characters, function(i, v) {
  277.         if (v.Stances.indexOf(stance) > -1) {
  278.             v.Points++;
  279.             return;
  280.         }
  281.     });
  282. }
  283.  
  284. function playerVortex(vortex) {
  285.     $.each(chardata.characters, function(i, v) {
  286.         if (v.Vortex.indexOf(vortex) > -1) {
  287.             v.Points++;
  288.             return;
  289.         }
  290.     });
  291. }
  292.  
  293. function getResults() {
  294.     var arr = [""];
  295.     var results = [""];
  296.     var results2 = [""];
  297.     var runner = [""];
  298.     var runner2 = [""];
  299.     var inc = 0;
  300.     var cre = 0;
  301.    
  302.     for (i = 0;i < chardata.characters.length;i++) {
  303.         arr[i] = chardata.characters[i].Points;    
  304.         //alert(chardata.characters[i].Points);
  305.     }
  306.     for (i = 0;i< chardata.characters.length;i++) {
  307.         if (chardata.characters[i].Points == Math.max.apply(null, arr)) {
  308.             //alert("Doing with "+chardata.characters[i].fullname);
  309.             results[inc] = chardata.characters[i].fullname;
  310.             //alert("Name should be "+chardata.characters[i].fullname+" and it is "+results[inc]);
  311.             results2[inc] = chardata.characters[i].charname;
  312.             //alert("Secondary name should be "+chardata.characters[i].charname+" and it is "+results2[inc]);
  313.             inc++;
  314.         }
  315.         else if (chardata.characters[i].Points < Math.max.apply(null, arr) && chardata.characters[i].Points >= (Math.max.apply(null, arr)-1)) {
  316.             runner[cre] = chardata.characters[i].fullname;
  317.             runner2[cre] = chardata.characters[i].charname;
  318.             cre++;
  319.         }
  320.     }
  321.  
  322.     //alert(results[0]);
  323.     //alert(results2[0]);
  324.     //alert(arr);
  325.     //alert(runner);
  326.     title = ("<h2>You got: "+results[0]+"!</h2>");
  327.     img = ("<img src='char/"+results2[0]+".png'>");
  328.     other = "";
  329.     runners = "";
  330.     if (results.length > 1) {
  331.         other = "<p>Other characters you tied for:</p><ul>";
  332.         for (i=1;i<results.length;i++) {
  333.             other = (other+"<li>"+results[i]+"</li>");
  334.         }
  335.         other = other+"</ul>";
  336.     }
  337.     if (runner.length > 0) {
  338.         runners = "<p>Close second characters:</p><ul>";
  339.         for (i=0;i<runner.length;i++) {
  340.             runners = (runners+"<li>"+runner[i]+"</li>");
  341.         }
  342.         runners = runners+"</ul>";
  343.     }
  344.  
  345.     resultshtml = title+img+other+runners;
  346.     $('#results').html(resultshtml);
  347.     $('#results').show(500);
  348.     $('#results').promise().done(function(){
  349.         $("html, body").animate({ scrollTop: $(document).height() }, 1000);
  350.     });    
  351.    
  352. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement