JavaScript library for calculating difficulty and performance of beatmaps and scores in a new osu!std rebalance from delta_t.
Get your osu api key from: https://osu.ppy.sh/p/api
- Node.js 8.3.0+
In your project add the dependency
npm i osu-rebalance
Require inside your javascript file
const Rebalance = require('osu-rebalance');
or for specific elements using selective require
const {Beatmap, Difficulty, Performance} = require('osu-rebalance');
To calculate difficulty and performance of the map, specify the path to previously downloaded .osu beatmap file.
const {Beatmap} = require(osu-rebalance);
const beatmap = new Beatmap('./tests/maps/1695382.osu');
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 are created as a class containing different representations of the mod combination.
const {Mods} = require(osu-rebalance);
const mods = new Mods(24);
console.log(mods.bitwise); // 24
console.log(mods.acronyms); // ['HR', 'HD']
console.log(mods.fullNames); // ['Hard Rock', 'Hidden']
console.log(mods.combination); // HRHD
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} = require(osu-rebalance);
const score = new Score({
totalHits: beatmap.objectsCount,
maxCombo: beatmap.maxCombo,
accuracy: 1,
mods: new Mods('NCHD')
});
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 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.
If you don't specify any type of user scores, you will get beatmap scores by default.
const {getUserScores} = require('osu-rebalance');
// Will return first 10 scores on specified beatmap
const scores = getUserScores({
apiKey: 'YOUR-API-KEY',
b: 124501,
limit: 10
});
const {Mods, getUserScores} = require('osu-rebalance');
// Will return all user's recent DT only scores.
const scores = getUserScores({
apiKey: 'YOUR-API-KEY',
u: 'Kionell',
scoreType: 'recent',
limit: 100,
mods: new Mods('DT');
});
const {getUserScores} = require('osu-rebalance');
// Will return all user's best scores.
const scores = getUserScores({
apiKey: 'YOUR-API-KEY',
u: 'Kionell',
scoreType: 'best',
limit: 100
});
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. |
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.
const {getUserData} = require('osu-rebalance');
const users = getUserData({
});
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. |
Name | Type |
---|---|
XH | string | number |
X | string | number |
SH | string | number |
S | string | number |
A | string | number |
Once the beatmap and score data are received, difficulty and performance can be calculated:
const {Beatmap, Mods, Score, Difficulty, Performance} = require('osu-rebalance');
// THE ORAL CIGARETTES - Mou Ii kai? (Nevo) [Rain] + NCHD
const beatmap = new Beatmap('./tests/maps/1695382.osu');
const mods = new Mods('NCHD');
const score = new Score({
totalHits: beatmap.objectsCount,
maxCombo: beatmap.maxCombo,
accuracy: 1, // or 100
mods: mods
});
const difficultyCalc = new Difficulty(beatmap, mods);
const performanceCalc = new Performance(beatmap, mods);
const difficulty = difficultyCalc.calculate();
const performance = performanceCalc.calculate(difficulty, score);
console.log(difficulty.totalStars); // 9.63355462667461
console.log(performance.totalPP); // 1366.343694809782 (for SS)
const {Difficulty, Performance, Mods, Beatmap, getUserScores} = require('osu-rebalance');
// Kionell: REOL - Endless Line (DeRandom Otaku) [Infinite] + NM
const beatmap = new Beatmap('./tests/maps/1493345.osu');
const mods = new Mods(0);
const scores = getUserScores({
apiKey: 'YOUR-API-KEY',
b: '1493345',
u: 'Kionell',
mods: mods
});
scores.then(score => {
const dfCalc = new Difficulty(beatmap, mods);
const ppCalc = new Performance(beatmap, mods);
const difficulty = dfCalc.calculate();
const performance = ppCalc.calculate(difficulty, score[0]);
console.log(difficulty.totalStars); // 5.641330225101718
console.log(performance.totalPP); // 241.47355804117475
});
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. |
Name | Type |
---|---|
tapDiff | number |
streamNoteCount | number |
mashTapDiff | number |
strainHistory | number[] |
Name | Type |
---|---|
fcProbTp | number |
hiddenFactor | number |
comboTps | number[] |
missTps | number[] |
missCounts | number[] |
cheeseNoteCount | number |
cheeseLevels | number[] |
cheeseFactors | number[] |
Name | Type | Description |
---|---|---|
totalPP | number | Total performance. |
aimPP | number | Aim performance. |
tapPP | number | Tap performance. |
accPP | number | Accuracy performance. |
This project is licensed under the MIT License - see the LICENSE file for details