jhylands

ogame trade calculation

Apr 3rd, 2014
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <table>
  2. <tr>
  3. <td>What are you selling:(M,C,D)<input type="text" maxlength="1"/></td>
  4. </tr><tr>
  5. <td>How much of that:<input type="number" id="howMuch" /></td>
  6. </tr><tr>
  7. <td>ratio of the two things you whish to get:<input id="A" type="number"><input id="B" type="number"></td>
  8. </tr><tr>
  9. <td>ratios:(something:something:what your selling)<input id="M" type="number" /><input id="C" type="number" /><input id="D" type="number" /></td>
  10. </tr><tr><td>
  11. <input type="button" onclick="calculate()" value="Calculate" />
  12. </td></tr><tr>
  13. <td>Amounts you will get: <x id="amount1"></x>:<x id="amount2"></x></td></tr>
  14. </table>
  15. <script>
  16. function calculate(){
  17. //get amount
  18. var H = document.getElementById('howMuch').value;
  19. //get rates
  20. var C = document.getElementById('M').value;
  21. var D = document.getElementById('C').value;
  22. var E = document.getElementById('D').value;
  23. //get ration of buying
  24. var A = document.getElementById('A').value;
  25. var B = document.getElementById('B').value;
  26. var G = H*C*D;
  27. var AB = A/B;
  28. var DC = Number(D)+Number(C);
  29. G = 2*G/(E*(AB+1)*(DC));
  30. var F = AB*G;
  31. document.getElementById('amount1').innerHTML = F;
  32. document.getElementById('amount2').innerHTML = G;
  33. }
  34. </script>
Advertisement
Add Comment
Please, Sign In to add comment