Guest User

Untitled

a guest
Nov 16th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. package bot.rsps;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. /**
  7. * Bad code for testing.
  8. *
  9. * @author bot
  10. *
  11. */
  12. public class SquealOfFortune {
  13.  
  14. private static final int[] RARE = { 1, 5, 9, 12 };
  15.  
  16. private static final int[] COMMON = { 3, 343, 1329, 85, 012, 94 };
  17.  
  18. private static final int[] UNCOMMON = { 99, 2147483647, 939182, 2913219, 21 };
  19.  
  20. private static final int TYPE_COMMON = 1;
  21.  
  22. private static final int TYPE_UNCOMMON = 2;
  23.  
  24. private static final int TYPE_RARE = 3;
  25.  
  26. /**
  27. * Is this ever used?
  28. */
  29. public static int getType(int item) {
  30. for (int i : UNCOMMON) {
  31. if (item == i) {
  32. return TYPE_UNCOMMON;
  33. }
  34. }
  35. for (int i : RARE) {
  36. if (item == i) {
  37. return TYPE_RARE;
  38. }
  39. }
  40. return TYPE_COMMON;
  41. }
  42.  
  43. private static void add(int type, List<Integer> dest, int amnt) {
  44. int[] typeArray = type == TYPE_RARE ? RARE : type == TYPE_UNCOMMON ? UNCOMMON : COMMON;
  45. for (int i = 0; i < amnt; i++) {
  46. dest.add(typeArray[(int) (Math.random() * typeArray.length)]);
  47. }
  48. }
  49.  
  50. public static final List<Integer> generateRewards() {
  51. List<Integer> rewards = new ArrayList<Integer>(13);
  52. add(TYPE_COMMON, rewards, 5);
  53. add(TYPE_RARE, rewards, 1);
  54. add(TYPE_COMMON, rewards, 3);
  55. add(TYPE_RARE, rewards, 1);
  56. add(TYPE_UNCOMMON, rewards, 3);
  57. // 13 rewards, slots might be wrong, I could randomise slots.
  58. return rewards;
  59. }
  60. }
Add Comment
Please, Sign In to add comment