Index154

captureCode

Oct 8th, 2019
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. note = "input is the monster name along with its rarity, retrieved from the quote system";
  2.  
  3. upnext = "Set some default values";
  4. chance = 0;
  5. forcedError = "false";
  6.  
  7. upnext = "Remove prefix if necessary";
  8. if(input.substring(0, 2) == "n "){
  9. input = input.substring(2, input.length);
  10. }
  11.  
  12. upnext = "Check if the input is valid. If it isn't, generate an error message and don't execute the remaining code";
  13. if(input == "There are no quotes added" || forcedError == "true"){
  14. output = "There is no creature to capture! Please use !encounter first";
  15. } else {
  16. upnext = "Split input into name and rarity";
  17. ainput = input.split("(");
  18. aRarity = ainput[1].split(")"); rarity = aRarity[0];
  19. monster = ainput[0].trim();
  20.  
  21. upnext = "Generate a random number between 1 and 100";
  22. check = (Math.round(Math.random() * 99 + 1));
  23.  
  24. upnext = "Check what rarity the input corresponds to and set the chance to succeed based on it";
  25. if(rarity == "Common"){chance = 50}
  26. else if(rarity == "Uncommon"){chance = 40}
  27. else if(rarity == "Rare"){chance = 30}
  28. else{chance = 20}
  29.  
  30. upnext = "Compare the randomly rolled number with the chance number and determine the result";
  31. if(check <= chance){output = "You have successfully captured the " + monster + "!"}
  32. else{output = "The capturing process failed..."}
  33. }
  34.  
  35. upnext = "Create a String telling the user what the chance to succeed was if it has been set above";
  36. if(chance > 0){
  37. output2 = " The success chance was " + chance + "%";
  38. }
  39. else{output2 = "";}
  40.  
  41. upnext = "Generate output";
  42. output = output + output2;
Add Comment
Please, Sign In to add comment