Advertisement
mnchngrngs

Math

Mar 29th, 2024
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. public void randomizeStatsWithinBST(Random random) {
  2. // Minimum 20 HP, 10 everything else
  3. int bst = bst() - 70;
  4.  
  5. // Make weightings
  6. double hpW = random.nextDouble(), atkW = random.nextDouble(), defW = random.nextDouble();
  7. double spaW = random.nextDouble(), spdW = random.nextDouble(), speW = random.nextDouble();
  8.  
  9. double totW = hpW + atkW + defW + spaW + spdW + speW;
  10.  
  11. hp = (int) Math.max(1, Math.round(hpW / totW * bst)) + 20;
  12. attack = (int) Math.max(1, Math.round(atkW / totW * bst)) + 10;
  13. defense = (int) Math.max(1, Math.round(defW / totW * bst)) + 10;
  14. spatk = (int) Math.max(1, Math.round(spaW / totW * bst)) + 10;
  15. spdef = (int) Math.max(1, Math.round(spdW / totW * bst)) + 10;
  16. speed = (int) Math.max(1, Math.round(speW / totW * bst)) + 10:
  17.  
  18. // Check for something we can't store
  19. if (hp > 255 || attack > 255 || defense > 255 || spatk > 255 || spdef > 255 || speed > 255) {
  20. // re roll
  21. randomizeStatsWithinBST(random);
  22. }
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement