Advertisement
Guest User

Untitled

a guest
Apr 19th, 2014
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. <button class="muchFancy" onclick="buySword()"> Buy a fucking Sword </button>
  2.  
  3. var Swords = 0;
  4.  
  5. function autoSoul(number) {
  6. souls = souls + number;
  7. document.getElementById('souls').innerHTML = souls;
  8. }
  9.  
  10. function buySword() {
  11. var swordCost = Math.floor(30 * Math.pow(1.25, Swords));
  12. if (souls >= swordCost) {
  13. Swords = Swords + 1;
  14. souls = souls - swordCost;
  15. document.getElementById("Swords").innerHTML = Swords;
  16. document.getElementById("souls").innerHTML = souls;
  17. };
  18. var nextSword = Math.floor(30 * Math.pow(1.25, Swords));
  19. document.getElementById('swordCost').innerHTML = nextSword;
  20. };
  21.  
  22. window.setInterval(function(){
  23. autoSoul(Swords);
  24. }, 1000);
  25.  
  26. <button class="muchFancy" id="muchFancy">Buy a fucking Sword</button><br>
  27. Swords: <div id="Swords">1</div>
  28. souls: <div id="souls">150</div>
  29. Cost: <div id="swordCost">5</div>
  30.  
  31. var Swords = 1;
  32. var souls = 150;
  33.  
  34. function autoSoul(number) {
  35. souls = souls + number;
  36. document.getElementById('souls').innerHTML = souls;
  37. }
  38.  
  39. function buySword() {
  40. var swordCost = Math.floor(30 * Math.pow(1.25, Swords));
  41. if (souls >= swordCost) {
  42. Swords = Swords + 1;
  43. souls = souls - swordCost;
  44. document.getElementById("Swords").innerHTML = Swords;
  45. document.getElementById("souls").innerHTML = souls;
  46. }
  47. var nextSword = Math.floor(30 * Math.pow(1.25, Swords));
  48. document.getElementById('swordCost').innerHTML = nextSword;
  49. }
  50.  
  51. window.setInterval(function () {
  52. autoSoul(Swords);
  53. }, 1000);
  54.  
  55. document.getElementById("muchFancy").addEventListener("click", function(){
  56. buySword();
  57. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement