Rebalance-Calculator
JavaScript library for calculating difficulty and performance of beatmaps and scores in a new osu!std rebalance from delta_t.
Getting Started
Get your osu api key from: https://osu.ppy.sh/p/api
Requirements
- Node.js 8.3.0+
Installing
In your project add the dependency
npm i osu-rebalance
Require inside your javascript file
const Rebalance = ;
or for specific elements using selective require
const Beatmap Difficulty Performance = ;
Beatmaps
To calculate difficulty and performance of the map, specify the path to previously downloaded .osu beatmap file.
const Beatmap = ; const beatmap = './tests/maps/1695382.osu';
Beatmap object:
Name | Type | Description |
---|---|---|
CS | number | Beatmap circles size. |
HP | number | Beatmap hp drain. |
OD | number | Beatmap overall difficulty. |
AR | number | Beatmap approach rate. |
circleCount | number | Beatmap circles count. |
sliderCount | number | Beatmap sliders count. |
spinnerCount | number | Beatmap spinners count. |
objectsCount | number | Beatmap total objects count. |
maxCombo | number | Beatmap max combo. |
bpmMin | number | Beatmap minimum BPM. |
bpmMax | number | Beatmap maximum BPM. |
mapID | number | string | Beatmap id. |
setID | number | string | Beatmap set id. |
artist | string | Beatmap artist. |
creator | string | Beatmap creator. |
title | string | Beatmap title. |
version | string | Beatmap difficulty name. |
hitObjects | HitObject[] | Beatmap hit objects data. |
fileFormat | number | Beatmap file version. |
Mods
Mods are created as a class containing different representations of the mod combination.
const Mods = ; const mods = 24; console; // 24console; // ['HR', 'HD']console; // ['Hard Rock', 'Hidden']console; // HRHD
Scores
Basic score templates
Performance calculator requires a score to work. A simple score template created by the Score
class is suitable for beatmap calculations. To create a new score, you need to specify at least max combo, accuracy and total hits. Mods are optional and by default they are equals to 0 (NM).
const Score = ; const score = totalHits: beatmapobjectsCount maxCombo: beatmapmaxCombo accuracy: 1 mods: 'NCHD';
Score object:
Name | Type | Description |
---|---|---|
mods | Mods | Score mods. |
count300 | number | Score 300s. |
count100 | number | Score 100s. |
count50 | number | Score 50s. |
countMiss | number | Score misses. |
totalHits | number | Score total hits (not to be confused with combo). |
maxCombo | number | Score max combo. |
accuracy | number | Score accuracy. |
User scores
User scores information is obtained from the osu api. Therefore, for use it is necessary to transfer the api key. The data for the request is passed as an object, each key of which has the same name as the keys in osu api. You can also specify scores type and filter scores by mods.
Requesting beatmap scores
If you don't specify any type of user scores, you will get beatmap scores by default.
const getUserScores = ; // Will return first 10 scores on specified beatmapconst scores = ;
Requesting recent user scores
const Mods getUserScores = ; // Will return all user's recent DT only scores.const scores = ;
Requesting user best scores
const getUserScores = ; // Will return all user's best scores.const scores = ;
UserScore object:
Name | Type | Description |
---|---|---|
mods | Mods | Score mods. |
count300 | number | Score 300s. |
count100 | number | Score 100s. |
count50 | number | Score 50s. |
countMiss | number | Score misses. |
totalHits | number | Score total hits (not to be confused with combo). |
maxCombo | number | Score max combo. |
accuracy | number | Score accuracy. |
username | string | Nickname of the player who set this record. |
userId | string | number | User ID of the player who set this record. |
date | string; | Score publishing date. |
livePP | string | number | Performance of the score with current pp meta. |
rank | string | number | Score rank (S, A, B...). |
score | string | number | Score points. |
mapId | string | number | Score map id. |
position | string | number | Score position in api. |
Users
As in the examples above with scores, you can also get information about users. This feature will come in handy later, since the calculation of the top 100 is not yet supported.
Requesting user data
const getUserData = ; const users = ;
User object:
Name | Type | Description |
---|---|---|
userId | string | number | User ID. |
username | string | Username. |
joined | string | Date | null | User join Date. |
playTime | string | number | User total play time in seconds. |
playCount | string | number | User total play count. |
worldRank | string | number | User world rank. |
countryRank | string | number | User country rank. |
country | string | User country. |
rankedScore | string | number | User ranked score. |
totalScore | string | number | User total score. |
level | string | number | User level. |
livePP | string | number | User total performance in current pp meta. |
accuracy | string | number | User total accuracy. |
count300 | string | number | User total count of 300s. |
count100 | string | number | User total count of 100s. |
count50 | string | number | User total count of 50s. |
ranks | object | User total count of ranks. |
events | string[] | User latest events. |
User ranks object:
Name | Type |
---|---|
XH | string | number |
X | string | number |
SH | string | number |
S | string | number |
A | string | number |
Calculations
Once the beatmap and score data are received, difficulty and performance can be calculated:
Map calculation
const Beatmap Mods Score Difficulty Performance = ; // THE ORAL CIGARETTES - Mou Ii kai? (Nevo) [Rain] + NCHDconst beatmap = './tests/maps/1695382.osu';const mods = 'NCHD'; const score = totalHits: beatmapobjectsCount maxCombo: beatmapmaxCombo accuracy: 1 // or 100 mods: mods; const difficultyCalc = beatmap mods;const performanceCalc = beatmap mods; const difficulty = difficultyCalc;const performance = performanceCalc; console; // 9.63355462667461console; // 1366.343694809782 (for SS)
Score calculation
const Difficulty Performance Mods Beatmap getUserScores = ; // Kionell: REOL - Endless Line (DeRandom Otaku) [Infinite] + NMconst beatmap = './tests/maps/1493345.osu';const mods = 0; const scores = ; scores;
Difficulty object:
Name | Type | Description |
---|---|---|
totalStars | number | Beatmap total stars. |
tapStars | number | Beatmap tap stars. |
aimStars | number | Beatmap aim stars. |
fingerStars | number | Beatmap finger control stars. |
tapAtts | object | Beatmap tap attributes. |
aimAtts | object | Beatmap aim attributes. |
fingerDiff | number | Beatmap finger control difficulty. |
clockRate | number | Beatmap clock rate. |
mapLength | number | Beatmap calculated length. |
mods | Mods | Beatmap mods. |
CS | number | Beatmap circle size. |
HP | number | Beatmap hp drain. |
OD | number | Beatmap overall difficulty. |
AR | number | Beatmap approach rate. |
Tap attributes:
Name | Type |
---|---|
tapDiff | number |
streamNoteCount | number |
mashTapDiff | number |
strainHistory | number[] |
Aim attributes:
Name | Type |
---|---|
fcProbTp | number |
hiddenFactor | number |
comboTps | number[] |
missTps | number[] |
missCounts | number[] |
cheeseNoteCount | number |
cheeseLevels | number[] |
cheeseFactors | number[] |
Performance object:
Name | Type | Description |
---|---|---|
totalPP | number | Total performance. |
aimPP | number | Aim performance. |
tapPP | number | Tap performance. |
accPP | number | Accuracy performance. |
License
This project is licensed under the MIT License - see the LICENSE file for details