Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <button class="muchFancy" onclick="buySword()"> Buy a fucking Sword </button>
- var Swords = 0;
- function autoSoul(number) {
- souls = souls + number;
- document.getElementById('souls').innerHTML = souls;
- }
- function buySword() {
- var swordCost = Math.floor(30 * Math.pow(1.25, Swords));
- if (souls >= swordCost) {
- Swords = Swords + 1;
- souls = souls - swordCost;
- document.getElementById("Swords").innerHTML = Swords;
- document.getElementById("souls").innerHTML = souls;
- };
- var nextSword = Math.floor(30 * Math.pow(1.25, Swords));
- document.getElementById('swordCost').innerHTML = nextSword;
- };
- window.setInterval(function(){
- autoSoul(Swords);
- }, 1000);
- <button class="muchFancy" id="muchFancy">Buy a fucking Sword</button><br>
- Swords: <div id="Swords">1</div>
- souls: <div id="souls">150</div>
- Cost: <div id="swordCost">5</div>
- var Swords = 1;
- var souls = 150;
- function autoSoul(number) {
- souls = souls + number;
- document.getElementById('souls').innerHTML = souls;
- }
- function buySword() {
- var swordCost = Math.floor(30 * Math.pow(1.25, Swords));
- if (souls >= swordCost) {
- Swords = Swords + 1;
- souls = souls - swordCost;
- document.getElementById("Swords").innerHTML = Swords;
- document.getElementById("souls").innerHTML = souls;
- }
- var nextSword = Math.floor(30 * Math.pow(1.25, Swords));
- document.getElementById('swordCost').innerHTML = nextSword;
- }
- window.setInterval(function () {
- autoSoul(Swords);
- }, 1000);
- document.getElementById("muchFancy").addEventListener("click", function(){
- buySword();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement