-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.ts
226 lines (203 loc) · 8.05 KB
/
game.ts
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
const story: HTMLElement | null = document.getElementById("story")
let lollies: number = 0;
const lollyButton: HTMLElement | null = document.getElementById("lButton")
const lollyCount: HTMLElement | null = document.getElementById("lollies")
let clickPower: number = 1;
let increment: number = 1.3;
const passiveLollyCount: HTMLElement | null = document.getElementById("lolliesPSec")
let passiveLollies: number = 0;
const gSnakeButton: HTMLElement | null = document.getElementById("gSnake")
const gSnakeCost: HTMLElement | null = document.getElementById("gSnake-price")
let gSnakeCount: HTMLElement | null = document.getElementById("gSnake-count")
let gSnakesOwned: number = 0;
let gSnakeRate: number = 0.2;
let gSnakePrice: number = 10;
const hmLollyButton: HTMLElement | null = document.getElementById("hmLolly")
const hmLollyCost: HTMLElement | null = document.getElementById("hmLolly-price")
let hmLollyCount: HTMLElement | null = document.getElementById("hmLolly-count")
let hmLolliesOwned: number = 0;
let hmLollyRate: number = 3;
let hmLollyPrice: number = 100;
const lollyArtistButton: HTMLElement | null = document.getElementById("lollyArtist")
const lollyArtistCost: HTMLElement | null = document.getElementById("lollyArtist-price")
let lollyArtistCount: HTMLElement | null = document.getElementById("lollyArtist-count")
let lollyArtistsOwned: number = 0;
let lollyArtistRate: number = 17.5;
let lollyArtistPrice: number = 750;
const facButton: HTMLElement | null = document.getElementById("fac")
const facCost: HTMLElement | null = document.getElementById("fac-price")
let facCount: HTMLElement | null = document.getElementById("fac-count")
let facsOwned: number = 0;
let facRate: number = 175;
let facPrice: number = 5000;
const sugarButton: HTMLElement | null = document.getElementById("sugar")
let sugarPrice: number = 1000;
const fakeSugarButton: HTMLElement | null = document.getElementById("fakeSugar")
let fakeSugarPrice: number = 1000;
const betterMouseButton: HTMLElement | null = document.getElementById("betterMouse")
let betterMousePrice: number = 15000;
lollyButton?.addEventListener("click", () => {
if (lollyCount == null) {
console.log("Lolly Count is null")
} else {
lollies += clickPower;
lollyCount.textContent = String(lollies);
}
});
function buygSnake() {
if (gSnakeCost == null || lollyCount == null || passiveLollyCount == null || gSnakeCount == null) {
return
}
if (lollies >= gSnakePrice) {
console.log("Sufficient lollies")
gSnakesOwned++
lollies -= gSnakePrice;
gSnakePrice *= increment;
passiveLollies += gSnakeRate;
gSnakeCost.textContent = gSnakePrice.toFixed(1);
lollyCount.textContent = lollies.toFixed(1);
passiveLollyCount.textContent = passiveLollies.toFixed(1);
gSnakeCount.textContent = String(gSnakesOwned);
}
}
function buyHmLolly() {
if (hmLollyCost == null || lollyCount == null || passiveLollyCount == null || hmLollyCount == null) {
return
}
if (lollies >= hmLollyPrice) {
console.log("Sufficient lollies")
hmLolliesOwned++
lollies -= hmLollyPrice;
hmLollyPrice *= increment;
passiveLollies += hmLollyRate;
hmLollyCost.textContent = hmLollyPrice.toFixed(1);
lollyCount.textContent = lollies.toFixed(1);
passiveLollyCount.textContent = passiveLollies.toFixed(1);
hmLollyCount.textContent = String(hmLolliesOwned);
}
}
function buyLollyArtist() {
if (lollyArtistCost == null || lollyCount == null || passiveLollyCount == null || lollyArtistCount == null) {
return
}
if (lollies >= lollyArtistPrice) {
console.log("Sufficient lollies")
lollyArtistsOwned++
lollies -= lollyArtistPrice;
lollyArtistPrice *= increment;
passiveLollies += lollyArtistRate;
lollyArtistCost.textContent = lollyArtistPrice.toFixed(1);
lollyCount.textContent = lollies.toFixed(1);
passiveLollyCount.textContent = passiveLollies.toFixed(1);
lollyArtistCount.textContent = String(lollyArtistsOwned);
}
}
function buyFac() {
if (facCost == null || lollyCount == null || passiveLollyCount == null || facCount == null) {
return
}
if (lollies >= facPrice) {
console.log("Sufficient lollies")
facsOwned++
lollies -= facPrice;
facPrice *= increment;
passiveLollies += facRate;
facCost.textContent = facPrice.toFixed(1);
lollyCount.textContent = lollies.toFixed(1);
passiveLollyCount.textContent = passiveLollies.toFixed(1);
facCount.textContent = String(facsOwned);
}
}
function buySugar() {
if (lollyCount == null || passiveLollyCount == null || sugarButton == null) {
return
}
if (lollies >= sugarPrice) {
console.log("Sufficient lollies")
lollies -= sugarPrice;
passiveLollies += 50;
lollyCount.textContent = lollies.toFixed(1);
sugarButton.style.display = "none"
}
}
function buyFakeSugar() {
if (lollyCount == null || passiveLollyCount == null || fakeSugarButton == null || hmLollyCount == null || hmLollyCost == null) {
return
}
if (lollies >= sugarPrice) {
console.log("Sufficient lollies")
lollies -= sugarPrice;
passiveLollies += 50;
for (let i = 0; i <= 2; i++) {
console.log("Sufficient lollies")
hmLolliesOwned++
lollies -= hmLollyPrice;
hmLollyPrice *= increment;
passiveLollies += hmLollyRate;
hmLollyCost.textContent = hmLollyPrice.toFixed(1);
lollyCount.textContent = lollies.toFixed(1);
passiveLollyCount.textContent = passiveLollies.toFixed(1);
hmLollyCount.textContent = String(hmLolliesOwned);
}
lollyCount.textContent = lollies.toFixed(1);
fakeSugarButton.style.display = "none"
}
}
function buyBetterMouse() {
if (lollyCount == null || passiveLollyCount == null || betterMouseButton == null) {
return
}
if (lollies >= sugarPrice) {
console.log("Sufficient lollies")
lollies -= sugarPrice;
clickPower = 20;
lollyCount.textContent = lollies.toFixed(1);
betterMouseButton.style.display = "none"
}
}
gSnakeButton?.addEventListener("click", buygSnake)
hmLollyButton?.addEventListener("click", buyHmLolly)
lollyArtistButton?.addEventListener("click", buyLollyArtist)
facButton?.addEventListener("click", buyFac)
sugarButton?.addEventListener("click", buySugar)
fakeSugarButton?.addEventListener("click", buyFakeSugar)
betterMouseButton?.addEventListener("click", buyBetterMouse)
setInterval(() => {
if (lollyCount == null) {
console.log("Lolly Count is null")
} else {
lollies += passiveLollies;
lollyCount.textContent = lollies.toFixed(1);
}
}, 1000);
setInterval(() => {
if (lollies < 100 && story != null) {
const stories: string[] = [
"You decide to start making lollies.",
"You offer your family some of your lollies. They leave without a response.",
"Your first batch goes straight into the bin. Not even flies go near it."
]
story.textContent = stories[Math.floor(Math.random() * stories.length)]
} else if (lollies < 500 && lollies > 100 && story != null) {
const stories: string[] = [
"You start selling lollies to your neighbour. You suspect he is giving them to his cats.",
"You offer your family some of your lollies. They decide to try one.",
"You think your friends are selling your lollies on eBay."
]
story.textContent = stories[Math.floor(Math.random() * stories.length)]
} else if (lollies < 10000 && lollies > 500 && story != null) {
const stories: string[] = [
"Your lollies are getting popular in your town.",
"Your family now asks for lollies because they say they taste good.",
"Your friends are making mysterious profits. Maybe they did sell your lollies..."
]
story.textContent = stories[Math.floor(Math.random() * stories.length)]
} else if (lollies > 10000 && story != null) {
const stories: string[] = [
"People come from far away to get a taste of your lollies.",
"You decided to put one of your lollies up for auction. Someone bidded $43 000 for one.",
"There is a museum with your first ever lolly. It isn't popular, but it is there. You go every day."
]
story.textContent = stories[Math.floor(Math.random() * stories.length)]
}
}, 10000);