2020-08-27 13:09:35 +01:00
|
|
|
const osu = require("osu-packet"),
|
|
|
|
getUserById = require("../util/getUserById.js");
|
|
|
|
|
2021-01-26 12:26:46 +00:00
|
|
|
module.exports = function(currentUser, id = 0, sendImmidiate = true) {
|
2020-08-27 13:09:35 +01:00
|
|
|
if (id == 3) return; // Ignore Bot
|
|
|
|
|
|
|
|
// Create new osu packet writer
|
|
|
|
const osuPacketWriter = new osu.Bancho.Writer;
|
|
|
|
|
|
|
|
// Get user's class
|
|
|
|
const User = getUserById(id);
|
|
|
|
|
|
|
|
if (User == null) return;
|
|
|
|
|
|
|
|
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,
|
|
|
|
accuracy: User.accuracy / 100, // Scale of 0 to 1
|
|
|
|
playCount: User.playCount,
|
|
|
|
totalScore: User.totalScore,
|
|
|
|
rank: User.rank,
|
2021-09-03 23:47:46 +01:00
|
|
|
performance: (currentUser.rankingMode == 0 ? User.pp : 0)
|
2020-08-27 13:09:35 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
osuPacketWriter.HandleOsuUpdate(UserStatusObject);
|
|
|
|
|
|
|
|
// Send data to user's queue
|
2020-11-03 02:08:57 +00:00
|
|
|
if (sendImmidiate) currentUser.addActionToQueue(osuPacketWriter.toBuffer);
|
|
|
|
else return osuPacketWriter.toBuffer;
|
2020-08-27 13:09:35 +01:00
|
|
|
}
|