-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScoreboard.js
55 lines (49 loc) · 1.59 KB
/
Scoreboard.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
class Scoreboard {
lastGenScore;
bestGenScore;
lastSoloScore;
bestSoloScore;
constructor() {
this.lastGenScore = 0;
this.bestGenScore = 0;
this.lastSoloScore = 0;
this.bestSoloScore = 0;
this.lastGenScoreEl = document.getElementById("lastGenScore");
this.bestGenScoreEl = document.getElementById("bestGenScore");
this.lastSoloScoreEl = document.getElementById("lastSoloScore");
this.bestSoloScoreEl = document.getElementById("bestSoloScore");
}
draw() {
let lastSoloScorePipes =
Math.floor((this.lastSoloScore - 100) / 120) < 0
? 0
: Math.floor((this.lastSoloScore - 100) / 120);
let bestSoloScorePipes =
Math.floor((this.bestSoloScore - 100) / 120) < 0
? 0
: Math.floor((this.bestSoloScore - 100) / 120);
this.lastGenScoreEl.innerText =
"Last Generation Total Score: " + this.lastGenScore;
this.bestGenScoreEl.innerText =
"Best Generation Total Score: " + this.bestGenScore;
this.lastSoloScoreEl.innerText =
"Last Generation Best Solo Score: " +
this.lastSoloScore +
" (" +
lastSoloScorePipes +
" pipes)";
this.bestSoloScoreEl.innerText =
"Best Solo Score: " +
this.bestSoloScore +
" (" +
bestSoloScorePipes +
" pipes)";
}
update(totalScore, soloScore) {
this.lastGenScore = totalScore;
this.bestGenScore = Math.max(this.bestGenScore, totalScore);
this.lastSoloScore = soloScore;
this.bestSoloScore = Math.max(this.bestSoloScore, soloScore);
this.draw();
}
}