HV - Item World Cost Calculator

Calculates various numbers related to IW service

As of 2018-03-26. See the latest version.

  1. // ==UserScript==
  2. // @name HV - Item World Cost Calculator
  3. // @grant none
  4. // @include http://hentaiverse.org/pages/showequip.php?eid=*&key=*
  5. // @version 0.0.1.20180326024541
  6. // @namespace https://greasyfork.org/users/2233
  7. // @description Calculates various numbers related to IW service
  8. // ==/UserScript==
  9.  
  10. /*** Settings ***/
  11. var price_per_pxp = 12
  12. var pxp_multiplier = 16.0
  13.  
  14. /*** Enf of Settings ***/
  15.  
  16. var wnd = window
  17. var doc = wnd.document
  18. var loc = location
  19. var href = loc.href
  20.  
  21. var $ = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelector(css) }
  22. var $$ = function(e, css) { if(!css) { css=e; e=doc }; return e.querySelectorAll(css) }
  23.  
  24. var m = $('#equipment').textContent.match(/Potency Tier:(.*?)\((.*?)\)/)
  25. if(m) {
  26. var lv = parseInt(m[1])
  27. if(lv == 10) { console.log('The equipment is already Lv.10.') }
  28. else {
  29. var p_now = parseInt(m[2].match(/(\d+).*?\//)[1])
  30. var p_max = parseInt(m[2].match(/\/.*?(\d+)/)[1])
  31.  
  32. // PXP(1)
  33. var p1
  34. if(lv == 0) { p1 = p_max }
  35. else {
  36. for(var i=1, p_test=1, smallest=Infinity, tmp; i<=1000; i++) {
  37. p_test = i * Math.pow((1 + i/1000), lv)
  38. tmp = Math.abs(p_test - p_max)
  39. if(tmp < smallest) { smallest = tmp; p1 = i }
  40. }
  41. }
  42.  
  43. // PXP(2), PXP(3), ... , PXP(10)
  44. var p = { 1:p1 }
  45. for(var i=2; i<=10; i++) { p[i] = Math.ceil(p1 * Math.pow((1 + p1/1000), i-1)) }
  46. console.log('PXP(i) = ' + JSON.stringify(p))
  47.  
  48. // Sum of PXP(i), where i = 1 to 10
  49. var p_all = 0
  50. for(var i=1; i<=10; i++) { p_all += p[i] }
  51. console.log('PXP(1)+PXP(2)+...+PXP(10) = ' + p_all)
  52. console.log('PXP(1)+PXP(2)+...+PXP(10) = ' + Math.ceil(1000 * (Math.pow((1 + p1/1000), 10) - 1)))
  53.  
  54. // Sum of PXP(i), where i = now to 10
  55. var p_partial = p_max - p_now
  56. for(var i=lv+2; i<=10; i++) { p_partial += p[i] }
  57. console.log('PXP(' + lv + ')+...+PXP(10) = ' + p_partial)
  58.  
  59. // The quality of the equipment
  60. var q = (p1 - 100) / 250
  61. console.log('The quality of the equipment = ' + q)
  62.  
  63. // Number of rounds in one run
  64. var round = Math.ceil(75 * Math.pow(q, 3))
  65. if(round < 10) { round = 10 }
  66. if(round > 100) { round = 100 }
  67. console.log('Number of rounds in one run = ' + round)
  68.  
  69. // PXP per run
  70. var p_gain = Math.ceil(round * pxp_multiplier * ($('#equipment').textContent.indexOf('Soulbound') != -1 ? 2 : 1))
  71. console.log('PXP per run = ' + p_gain)
  72.  
  73. // Price per run
  74. var price_per_run = p_gain * price_per_pxp
  75. console.log('Price per run = ' + price_per_run)
  76.  
  77. // Number of runs (Lv.0 to Lv.10)
  78. var run_all = Math.ceil(p_all / p_gain)
  79. console.log('Number of runs (Lv.0 to Lv.10) = ' + run_all)
  80.  
  81. // Total cost (Lv.0 to Lv.10)
  82. var cost_all = price_per_run * run_all
  83. console.log('Total cost (Lv.0 to Lv.10) = ' + cost_all)
  84.  
  85. // Number of runs (Lv.now to Lv.10)
  86. var run_partial = Math.ceil(p_partial / p_gain)
  87. console.log('Number of runs (Lv.now to Lv.10) = ' + run_partial)
  88.  
  89. // Total cost (Lv.now to Lv.10)
  90. var cost_partial = price_per_run * run_partial
  91. console.log('Total cost (Lv.now to Lv.10) = ' + cost_partial)
  92. }
  93. }