fnbr
Version:
A library to interact with Epic Games' Fortnite HTTP and XMPP services
48 lines • 2.42 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Base_1 = tslib_1.__importDefault(require("../../Base"));
/**
* Represents a friend's presence
*/
class FriendPresence extends Base_1.default {
/**
* @param client The main client
* @param data The presence data
* @param friend The friend this presence belongs to
*/
constructor(client, data, friend, show, from) {
var _a;
super(client);
this.friend = friend;
this.status = data.Status;
this.onlineType = show;
this.platform = (_a = from.match(/(?<=\/.+?:.+?:).+(?=::)/g)) === null || _a === void 0 ? void 0 : _a[0];
this.receivedAt = new Date();
this.isPlaying = data.bIsPlaying || false;
this.isJoinable = data.bIsJoinable || false;
this.hasVoiceSupport = data.bHasVoiceSupport || false;
this.sessionId = data.SessionId;
this.homebaseRating = data.Properties && data.Properties.FortBasicInfo_j ? data.Properties.FortBasicInfo_j.homeBaseRating : undefined;
this.subGame = data.Properties ? data.Properties.FortSubGame_i : undefined;
this.isInUnjoinableMatch = data.Properties ? data.Properties.InUnjoinableMatch_b : false;
this.playlist = data.Properties ? data.Properties.GamePlaylistName_s : undefined;
this.partySize = data.Properties && data.Properties.Event_PartySize_s ? parseInt(data.Properties.Event_PartySize_s, 10) : undefined;
this.partyMaxSize = data.Properties && data.Properties.Event_PartyMaxSize_s
? parseInt(data.Properties.Event_PartyMaxSize_s, 10) : undefined;
this.gameSessionJoinKey = data.Properties ? data.Properties.GameSessionJoinKey_s : undefined;
const serverPlayerCount = data.Properties && data.Properties.ServerPlayerCount_i
? parseInt(data.Properties.ServerPlayerCount_i, 10) : undefined;
this.gameplayStats = undefined;
if (data.Properties && data.Properties.FortGameplayStats_j) {
const gps = data.Properties.FortGameplayStats_j;
this.gameplayStats = {
kills: typeof gps.numKills === 'number' ? gps.numKills : undefined,
fellToDeath: gps.bFellToDeath,
serverPlayerCount,
};
}
}
}
exports.default = FriendPresence;
//# sourceMappingURL=FriendPresence.js.map