osu-rebalance v1.2.0
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 = require('osu-rebalance');
or for specific elements using selective require
const {Beatmap, Difficulty, Performance} = require('osu-rebalance');
Beatmaps
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');
Beatmap object:
Mods
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
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} = require(osu-rebalance);
const score = new Score({
totalHits: beatmap.objectsCount,
maxCombo: beatmap.maxCombo,
accuracy: 1,
mods: new Mods('NCHD')
});
Score object:
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} = require('osu-rebalance');
// Will return first 10 scores on specified beatmap
const scores = getUserScores({
apiKey: 'YOUR-API-KEY',
b: 124501,
limit: 10
});
Requesting recent user scores
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');
});
Requesting user best scores
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
});
UserScore object:
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} = require('osu-rebalance');
const users = getUserData({
});
User object:
User ranks object:
Calculations
Once the beatmap and score data are received, difficulty and performance can be calculated:
Map calculation
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)
Score calculation
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
});
Difficulty object:
Tap attributes:
Aim attributes:
Performance object:
License
This project is licensed under the MIT License - see the LICENSE file for details