-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.js
142 lines (112 loc) · 3.74 KB
/
main.js
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
//huge thanks to StellarX20 for helping with code!
// variables
let time = 0;
let quarks = 0;
let gluons = 0;
let photons = 0;
let protons = 0;
let electrons = 0;
let quarkMult = 1;
let timeMult = 1;
let photonMult = 1;
let gluonMult = 1;
let difficulty = 1;
//display html element as variable or string
function displayElementAsVariable(elementId, displayVariable) {
var elementVariable = document.getElementById(elementId);
elementVariable.innerHTML = displayVariable
}
//hide html element
function hide(elementId) {
var elementVariable = document.getElementById(elementId);
elementVariable.style.display = "none";
}
//show html element
function show(elementId) {
elementId.style.display = "block";
}
//show string on log element
function log(string) {
displayElementAsVariable("log", string);
}
//increase mult variable
function increaseMult(mult, increaseAmount) {
mult += increaseAmount;
}
//change difficulty
function difficultychange(dif) {
difficulty = dif;
console.log('Difficulty set to ',difficulty,'.');
}
//increment functions
function incrementTime(IncreaseNum) {
time += IncreaseNum * timeMult;
console.log('Time: ', time);
displayElementAsVariable("timecounter", time);
}
function incrementQuarks(IncreaseNum) {
if (photons >= (IncreaseNum * difficulty)) {
quarks += (IncreaseNum * quarkMult);
photons -= (IncreaseNum * difficulty);
displayElementAsVariable('photoncounter', photons);
displayElementAsVariable('quarkcounter', quarks);
}
else {
console.log("Not enough resources to increment quarks.")
}
}
function incrementPhotons(IncreaseNum) {
photons += IncreaseNum * photonMult;
displayElementAsVariable('photoncounter', photons);
}
function incrementGluons(IncreaseNum) {
gluons += IncreaseNum * gluonMult;
displayElementAsVariable('gluoncounter', gluons);
}
function incrementElectrons(IncreaseNum) {
electrons += IncreaseNum;
displayElementAsVariable('electroncounter', electrons);
}
function incrementProtons(IncreaseNum) {
if (gluons >= (3 * difficulty) && quarks >= (3 * difficulty)) {
photons += IncreaseNum;
gluons -= (IncreaseNum * 3 * difficulty);
quarks -= (IncreaseNum * 3 * difficulty);
displayElementAsVariable('gluoncounter', gluons);
displayElementAsVariable('quarkcounter', quarks);
displayElementAsVariable('protoncounter', protons);
}
else {
console.log("Not enough resources to increment protons.");
}
}
//upgrade functions
function buyUpgrade(upgradeID) {
if (upgradeID = 'timeDilation' && quarks >= (25 * difficulty)) {
quarks -= (25 * difficulty);
displayElementAsVariable('quarkcounter', quarks);
increaseMult(timeMult, .1)
log("Somehow, after colliding a few dozen quarks, time now runs 10% faster.")
}
if (upgradeID = 'electroMagnetism' && electrons >= (5 * difficulty) && protons >= (5 * difficulty)) {
electrons -= (5 * difficulty);
protons -= (5 * difficulty);
unlockAtoms();
log("Particles now repel and attract. Maybe you can combine larger things with this?");
}
if (upgradeID = 'quarkMultiplication' && quarks >= 50) {
quarks -= (50 * difficulty);
increaseMult(quarkMult, 1);
log("After studying how quarks work (didn't you create them?), you can now turn photons into pairs of quarks.");
}
if (upgradeID = 'lighterPhotons' && photons >= (25 * difficulty) && electrons >= (25 * difficulty)) {
quarks -= (50 * difficulty);
increaseMult(photonMult, 1)
log("After tinkering with photons, you can now produce 2 per click!");
}
}
//unlock functions
function unlockAtoms() {
show('hydrogen');
show('hydrogenText');
}