Advertisement
antoshka1312

Untitled

Nov 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1.  
  2. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
  3.  
  4. <script>
  5. function randomInteger(min, max) {
  6. var rand = min + Math.random() * (max + 1 - min);
  7. rand = Math.floor(rand);
  8. return rand;
  9. }
  10.  
  11. function checkDex() {
  12. //Атакующий
  13. AttackerLevel = parseInt($('#AttackerLevel').val());
  14. AttackerDex = parseInt($('#AttackerDex').val());
  15. AttackerLuc = parseInt($('#AttackerLuc').val());
  16. AttackernPerAttack = AttackerDex * 0.5 + AttackerLevel;
  17. AttackernPerDefense = AttackerLuc * 0.125 + AttackernPerAttack;
  18.  
  19. //Атакуемый
  20. AttackedLevel = parseInt($('#AttackedLevel').val());
  21. AttackedDex = parseInt($('#AttackedDex').val());
  22. AttackedLuc = parseInt($('#AttackedLuc').val());
  23. AttackednPerAttack = AttackedDex * 0.5 + AttackedLevel;
  24. AttackednPerDefense = AttackedLuc * 0.125 + AttackednPerAttack;
  25.  
  26. //nAttackTypel = AttackednPerAttack + AttackernPerDefense;
  27. //nAttackTypem = AttackernPerAttack + AttackednPerDefense;
  28. nAttackTypem = AttackednPerAttack + AttackednPerDefense;
  29. nAttackTypek = AttackednPerAttack / (AttackernPerAttack + AttackernPerDefense);
  30. procent = AttackerLevel / (AttackerLevel + AttackedLevel) * 160.0 - (nAttackTypek * 100.0 - AttackernPerAttack / nAttackTypem * 100.0);
  31.  
  32. console.log(nAttackTypek);
  33.  
  34. if (procent >= 1) {
  35. if (procent > 99)
  36. procent = 99;
  37. }
  38. else {
  39. procent = 1;
  40. }
  41.  
  42. if (randomInteger(0, 100) >= procent) {
  43. console.log('Вы не попали: ' + procent + '% шанс.');
  44. return 0;
  45. }
  46. console.log('Вы попали: ' + procent + '% шанс.');
  47. return 1;
  48. }
  49. </script>
  50.  
  51. <table>
  52. <th>Атакующий</th>
  53. <th>Атакуемый</th>
  54. <tr>
  55. <td>
  56. <input type="text" id="AttackerLevel" placeholder="Уровень" value="60"><br>
  57. <input type="text" id="AttackerDex" placeholder="Ловкость" value="1500"><br>
  58. <input type="text" id="AttackerLuc" placeholder="Удача" value="11"><br>
  59. </td>
  60. <td>
  61. <input type="text" id="AttackedLevel" placeholder="Уровень" value="60"><br>
  62. <input type="text" id="AttackedDex" placeholder="Ловкость" value="3000"><br>
  63. <input type="text" id="AttackedLuc" placeholder="Удача" value="12"><br>
  64. </td>
  65. </tr>
  66. </table>
  67. <div id="chance"></div>
  68. <input type="submit" onclick="checkDex()">
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement