PageSourceSearch

https://sgdlist.pages.dev/js/score.js

js sgdlist.pages.dev collected 2026-10-03 05:33:14 UTC 2,614 bytes, 87 lines download raw bytes

1/**
2 * Numbers of decimal digits to round to
3 */
4const scale = 2;
5
6/**
7 * Calculate the score awarded when having a certain percentage on a list level
8 * @param {Number} rank Position on the list
9 * @param {Number} percent Percentage of completion
10 * @param {Number} minPercent Minimum percentage required
11 * @returns {Number}
12 */
13export function star(diff) {
14        if (diff.includes("Demon")){
15                return 10;//might want to update these for troll difficulties but works for now
16            }
17        else if (diff.includes("Insane")){
18                return 9;
19            }
20        else if (diff.includes("Harder")){
21                return 7;
22            }
23        else if (diff.includes("Hard")){
24                return 5;
25            }
26        else if (diff.includes("Normal")){
27                return 3;
28            }
29        else if (diff.includes("Easy")){
30                return 2;
31            }
32        else if (diff.includes("Auto")){
33                return 1;
34            }
35}
36export function score(rank, percent, minPercent) {
37    if (rank > 150) {
38        return 0;
39    }
40    if (rank > 75 && percent < 100) {
41        return 0;
42    }
43
44    // Old formula
45    /*
46    let score = (100 / Math.sqrt((rank - 1) / 50 + 0.444444) - 50) *
47        ((percent - (minPercent - 1)) / (100 - (minPercent - 1)));
48    */
49    // New formula
50		let score = 0;
51        if(56<=rank && rank<=150){
52			score=1.039035131 * ((185.7 * Math.exp(-0.02715 * rank)) + 14.84)
53		}else if(36<=rank && rank<=55){
54			score=1.0371139743 * ((212.61 * Math.pow(1.036,(1 - rank))) + 25.071)
55		}else if(21<=rank && rank<=35){
56			score=((250 - 83.389) * Math.pow(1.0099685,(2 - rank)) - 31.152) * 1.0371139743
57		}else if(4<=rank && rank<=20){
58			score=((326.1 * Math.exp(-0.0871 * rank)) + 51.09) * 1.037117142
59		}else if(1<=rank && rank<=3){
60			score=(-18.2899079915 * rank) + 368.2899079915
61        }else{
62            score=0;
63        }
64    if(percent !== 100){
65        score = commonProgress(score, percent, 67);
66    }
67    return Math.max(round(score), 0);
68}
69export function commonProgress(score, progress, requirement) {
70		return score * Math.pow(5,  ((progress - requirement)/(100 - requirement))  )   /10;
71	}
72export function round(num) {
73    if (!('' + num).includes('e')) {
74        return +(Math.round(num + 'e+' + scale) + 'e-' + scale);
75    } else {
76        var arr = ('' + num).split('e');
77        var sig = '';
78        if (+arr[1] + scale > 0) {
79            sig = '+';
80        }
81        return +(
82            Math.round(+arr[0] + 'e' + sig + (+arr[1] + scale)) +
83            'e-' +
84            scale
85        );
86    }
87}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.