forked from goldenyoshi22/PulsusKorean
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscoring.js
123 lines (111 loc) · 4.63 KB
/
scoring.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
const weightFunctions = {
"old": (k) => {
return topPlayMults[k];
},
"new": (k) => {
return (Math.pow((k/12) - 2, 2) / 4);
}
}
function userFindKoreanPulse() {
for (let i = 0; i < users.length; i++) {
const user = users[i];
user.scores = user.scores.sort(function(a, b){return b.pulse - a.pulse})
const scores = user.scores;
for (let k = 0; k < scores.length && k < topPlayMults.length; k++) {
user.pulse += scores[k].pulse * weightFunctions["new"](k);
}
}
}
function handleUserModifiers(kidscore, i) {
kidscore.scores = [];
for (let k = 0; kidscore["score" + k] != undefined; k++) {
kidscore.scores.push({
username: kidscore["score" + k].split("/")[0],
mods: kidscore["score" + k].split("/")[2] == undefined ? undefined : kidscore["score" + k].split("/")[2].split(","),
hits: kidscore["score" + k].split("/")[1].split(",").map(function(item) {return parseFloat(item)}),
kid: kidscore.kid,
pulse: calculate(i, kidscore["score" + k].split("/")[1].split(",").map(function(item) {return parseFloat(item)})),
accuracy: calculate(i, kidscore["score" + k].split("/")[1].split(",").map(function(item) {return parseFloat(item)}), "accuracy")
})
//mods
/*
bpm:
pulse*((5 ^ bpm)/5) if <1x
pulse*bpm if >=1x
fs:
if less than 1.0x
pulse * (1 + ((1.0 - (fs - 1.0) * 2) ^ 2 / 4) * 0.06)
hw:
pulse / hw if hw > 1
pulse / (hw^0.5) if hw <= 1
at: nuh uh
nf: 0.8x
nr: 0.8x
hd: 1.02x
fl: 1.1x
rd: Math.random() * 1.2 (jk)
*/
if (kidscore.scores[k].mods != undefined) {
finalMult = 1;
finalExponent = 1;
finalString = "";
let modArray = kidscore.scores[k].mods;
console.log(modArray);
for (let modIndex = 0; modIndex < modArray.length; modIndex++) {
if (modArray[modIndex].startsWith("bpm")) {
let bpmMod = modArray[modIndex].slice(3);
if (bpmMod >= 1) finalMult *= bpmMod; else finalExponent = 1 - (1 - bpmMod)/2;
finalString += `BPM ${bpmMod}x, `;
continue;
}
if (modArray[modIndex].startsWith("fs")) {
let fsMod = modArray[modIndex].slice(2);
//if (fsMod <= 0.5) finalMult *= 1.06;
//else if (fsMod <= 0.8) finalMult *= 1.03;
if (fsMod < 1.0) finalMult *= 1 + (Math.pow(1.0 - (fsMod - 1.0) * 2, 2) / 4) * 0.06;
finalString += `FS ${fsMod}x, `;
continue;
}
if (modArray[modIndex].startsWith("hw")) {
let hwMod = modArray[modIndex].slice(2);
if (hwMod > 1) finalMult /= hwMod;
else finalMult /= (hwMod ** 0.5);
finalString += `HW ${hwMod}x, `;
continue;
}
if (modArray[modIndex] == "nf") {
finalMult *= 0.8;
}
if (modArray[modIndex] == "nr") {
finalMult *= 0.8;
}
if (modArray[modIndex] == "hd") {
finalMult *= 1.02;
}
if (modArray[modIndex] == "fl") {
finalMult *= 1.1;
}
finalString += modArray[modIndex].toUpperCase() + ", ";
}
kidscore.scores[k].modMult = finalMult;
kidscore.scores[k].modExponent = finalExponent;
if (finalString == "") kidscore.scores[k].modInfo = "None";
else kidscore.scores[k].modInfo = finalString.slice(0, finalString.length - 2);
} else {
kidscore.scores[k].modMult = 1;
kidscore.scores[k].modExponent = 1;
kidscore.scores[k].modInfo = "";
}
kidscore.scores[k].pulse *= kidscore.scores[k].modMult;
kidscore.scores[k].pulse **= kidscore.scores[k].modExponent;
let userNames = [];
for (let m = 0; m < users.length; m++) {
userNames.push(users[m].username);
}
if (!userNames.includes(kidscore.scores[k].username)) {
users.push({ username: kidscore.scores[k].username, scores: [], pulse: 0 });
}
users[users.findIndex(item => item.username === kidscore.scores[k].username)].scores.push(kidscore.scores[k]);
kidscore.scores.sort(function(a, b){return b.pulse - a.pulse});
}
}