-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
66 lines (52 loc) · 1.65 KB
/
script.js
File metadata and controls
66 lines (52 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
'use strict';
$(document).ready(function() {
var panCount = 0;
var adClick = 0;
var tvClick = 0;
var boardClick = 0;
function update() {
// This changes the original H4 dynamically
$("#counter").html("<h4>You've sold "+panCount+" Pan Dulces");
// This is so the title changes too
document.title = panCount + " Pan Sold";
// Update the note below the Ad
$("#adCost").html("<p>Sell " + ((adClick+1) * 15) + " more Pan");
// Update the note below the TV
$("#tvCost").html("<p>Sell " + ((tvClick+1) * 30) + " more Pan");
//Update the note below the bllboard
$("#boardCost").html("<p>Sell " + ((boardClick+1) * 80) + " more Pan");
};
function keepAdding() {
panCount = panCount + adClick;
panCount = panCount + tvClick*3;
panCount = panCount + boardClick*8
update()
};
setInterval(keepAdding, 2000);
$('#dulce').click(function add() {
panCount++;
update();
});
// If the amount of pan sold is greater than or equal to the cost to purchase an upgrade, then it will subtract the cost from the total pan
$("#upgrade1").click(function buyAd() {
if (panCount >= ((adClick+1) *15)) {
panCount = panCount - ((adClick+1) * 15);
adClick = adClick + 1;
update();
};
});
$("#upgrade2").click(function buyTvAd() {
if (panCount >= ((tvClick+1) *30)) {
panCount = panCount - ((tvClick+1) * 30);
tvClick = tvClick + 1;
update();
};
});
$("#upgrade3").click(function buyTvAd() {
if (panCount >= ((boardClick+1) *80)) {
panCount = panCount - ((boardClick+1) * 80);
boardClick = boardClick + 1;
update();
};
});
});