Advertisement
Cicco23

matrix.js

May 20th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /** @author=Cicco23 */
  2. /*
  3. Parameters:
  4. > u = $(user);
  5. > qs = $(query);
  6. > c = $(count);
  7. > alive = true;
  8. */
  9. /*Clear ueless spaces ("%20")*/
  10. function trimmer(x){
  11.     x = x.trim();
  12.     while(x.startsWith("%20")){
  13.         x=x.replace("%20","");
  14.     }
  15.     return x.trim();
  16. }
  17. /*Clear the "%20" space bug*/
  18. qs = trimmer(qs);
  19. /*q -> string array of qs (querystring).*/
  20. var q = qs.split("%20");
  21. /*move saves the moves the player have chosen.*/
  22. var move = [0,0,0];
  23. /*nbMooves are the moves NB chooses.*/
  24. var nbMoves = [0,0,0];
  25. /*The fundamental string.*/
  26. var str = "";
  27. /*Result*/
  28. var hits = 0;
  29. /*Let's check if player have chosen correctly.*/
  30. var flag = q.length>=3;
  31. for(int i=0;flag && i<3;i++{
  32.     if(isNaN(q[i])||q[i]<1||q[i]>3) "ERROR. "+qs+" is NOT a valid number. Please re-try with a number between 1 and 3, next time! (correct sintax: !nbshoot [number] [number] [number].";
  33.     else move[i]=q[i];
  34.     var x = Math.random()*3;
  35.     x = 1+Math.floor(x);
  36.     nbMoves[i]=x;
  37. }
  38.  
  39. /* TESTING */
  40. /*  str = "Hai inserito \" "+qs+" \"\t"+str;*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement