2020-08-27 13:09:35 +01:00
|
|
|
const osu = require("osu-packet"),
|
2022-01-04 03:39:53 +00:00
|
|
|
getUserById = require("../util/getUserById.js");
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2021-01-26 12:26:46 +00:00
|
|
|
module.exports = function(currentUser, id = 0, sendImmidiate = true) {
|
2022-01-04 03:39:53 +00:00
|
|
|
if (id == 3) return; // Ignore Bot
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Create new osu packet writer
|
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Get user's class
|
|
|
|
const User = getUserById(id);
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
if (User == null) return;
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
let UserStatusObject = {
|
|
|
|
userId: User.id,
|
|
|
|
status: User.actionID,
|
|
|
|
statusText: User.actionText,
|
|
|
|
beatmapChecksum: User.beatmapChecksum,
|
|
|
|
currentMods: User.currentMods,
|
|
|
|
playMode: User.playMode,
|
|
|
|
beatmapId: User.beatmapID,
|
|
|
|
rankedScore: User.rankedScore,
|
2022-05-10 12:36:48 +01:00
|
|
|
accuracy: User.accuracy * 0.01, // Scale from 0:100 to 0:1
|
2022-01-04 03:39:53 +00:00
|
|
|
playCount: User.playCount,
|
|
|
|
totalScore: User.totalScore,
|
|
|
|
rank: User.rank,
|
|
|
|
performance: (User.rankingMode == 0 ? User.pp : 0)
|
|
|
|
};
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
osuPacketWriter.HandleOsuUpdate(UserStatusObject);
|
2020-08-27 13:09:35 +01:00
|
|
|
|
2022-01-04 03:39:53 +00:00
|
|
|
// Send data to user's queue
|
|
|
|
if (sendImmidiate) currentUser.addActionToQueue(osuPacketWriter.toBuffer);
|
|
|
|
else return osuPacketWriter.toBuffer;
|
2020-08-27 13:09:35 +01:00
|
|
|
}
|