Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- note = "input is the monster name along with its rarity, retrieved from the quote system";
- upnext = "Set some default values";
- chance = 0;
- forcedError = "false";
- upnext = "Remove prefix if necessary";
- if(input.substring(0, 2) == "n "){
- input = input.substring(2, input.length);
- }
- upnext = "Check if the input is valid. If it isn't, generate an error message and don't execute the remaining code";
- if(input == "There are no quotes added" || forcedError == "true"){
- output = "There is no creature to capture! Please use !encounter first";
- } else {
- upnext = "Split input into name and rarity";
- ainput = input.split("(");
- aRarity = ainput[1].split(")"); rarity = aRarity[0];
- monster = ainput[0].trim();
- upnext = "Generate a random number between 1 and 100";
- check = (Math.round(Math.random() * 99 + 1));
- upnext = "Check what rarity the input corresponds to and set the chance to succeed based on it";
- if(rarity == "Common"){chance = 50}
- else if(rarity == "Uncommon"){chance = 40}
- else if(rarity == "Rare"){chance = 30}
- else{chance = 20}
- upnext = "Compare the randomly rolled number with the chance number and determine the result";
- if(check <= chance){output = "You have successfully captured the " + monster + "!"}
- else{output = "The capturing process failed..."}
- }
- upnext = "Create a String telling the user what the chance to succeed was if it has been set above";
- if(chance > 0){
- output2 = " The success chance was " + chance + "%";
- }
- else{output2 = "";}
- upnext = "Generate output";
- output = output + output2;
Add Comment
Please, Sign In to add comment