This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

osu-rebalance

1.2.0 • Public • Published

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:

NameTypeDescription
CSnumberBeatmap circles size.
HPnumberBeatmap hp drain.
ODnumberBeatmap overall difficulty.
ARnumberBeatmap approach rate.
circleCountnumberBeatmap circles count.
sliderCountnumberBeatmap sliders count.
spinnerCountnumberBeatmap spinners count.
objectsCountnumberBeatmap total objects count.
maxCombonumberBeatmap max combo.
bpmMinnumberBeatmap minimum BPM.
bpmMaxnumberBeatmap maximum BPM.
mapIDnumber | stringBeatmap id.
setIDnumber | stringBeatmap set id.
artiststringBeatmap artist.
creatorstringBeatmap creator.
titlestringBeatmap title.
versionstringBeatmap difficulty name.
hitObjectsHitObject[]Beatmap hit objects data.
fileFormatnumberBeatmap file version.

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:

NameTypeDescription
modsModsScore mods.
count300numberScore 300s.
count100numberScore 100s.
count50numberScore 50s.
countMissnumberScore misses.
totalHitsnumberScore total hits (not to be confused with combo).
maxCombonumberScore max combo.
accuracynumberScore 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} = 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:

NameTypeDescription
modsModsScore mods.
count300numberScore 300s.
count100numberScore 100s.
count50numberScore 50s.
countMissnumberScore misses.
totalHitsnumberScore total hits (not to be confused with combo).
maxCombonumberScore max combo.
accuracynumberScore accuracy.
usernamestringNickname of the player who set this record.
userIdstring | numberUser ID of the player who set this record.
datestring;Score publishing date.
livePPstring | numberPerformance of the score with current pp meta.
rankstring | numberScore rank (S, A, B...).
scorestring | numberScore points.
mapIdstring | numberScore map id.
positionstring | numberScore 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} = require('osu-rebalance');
 
const users = getUserData({
 
});

User object:

NameTypeDescription
userIdstring | numberUser ID.
usernamestringUsername.
joinedstring | Date | nullUser join Date.
playTimestring | numberUser total play time in seconds.
playCountstring | numberUser total play count.
worldRankstring | numberUser world rank.
countryRankstring | numberUser country rank.
countrystringUser country.
rankedScorestring | numberUser ranked score.
totalScorestring | numberUser total score.
levelstring | numberUser level.
livePPstring | numberUser total performance in current pp meta.
accuracystring | numberUser total accuracy.
count300string | numberUser total count of 300s.
count100string | numberUser total count of 100s.
count50string | numberUser total count of 50s.
ranksobjectUser total count of ranks.
eventsstring[]User latest events.

User ranks object:

NameType
XHstring | number
Xstring | number
SHstring | number
Sstring | number
Astring | number

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:

NameTypeDescription
totalStarsnumberBeatmap total stars.
tapStarsnumberBeatmap tap stars.
aimStarsnumberBeatmap aim stars.
fingerStarsnumberBeatmap finger control stars.
tapAttsobjectBeatmap tap attributes.
aimAttsobjectBeatmap aim attributes.
fingerDiffnumberBeatmap finger control difficulty.
clockRatenumberBeatmap clock rate.
mapLengthnumberBeatmap calculated length.
modsModsBeatmap mods.
CSnumberBeatmap circle size.
HPnumberBeatmap hp drain.
ODnumberBeatmap overall difficulty.
ARnumberBeatmap approach rate.

Tap attributes:

NameType
tapDiffnumber
streamNoteCountnumber
mashTapDiffnumber
strainHistorynumber[]

Aim attributes:

NameType
fcProbTpnumber
hiddenFactornumber
comboTpsnumber[]
missTpsnumber[]
missCountsnumber[]
cheeseNoteCountnumber
cheeseLevelsnumber[]
cheeseFactorsnumber[]

Performance object:

NameTypeDescription
totalPPnumberTotal performance.
aimPPnumberAim performance.
tapPPnumberTap performance.
accPPnumberAccuracy performance.

License

This project is licensed under the MIT License - see the LICENSE file for details

Package Sidebar

Install

npm i osu-rebalance

Weekly Downloads

3

Version

1.2.0

License

MIT

Unpacked Size

731 kB

Total Files

74

Last publish

Collaborators

  • kionell