@fnlb-project/fnbr
Version:
A library to interact with Epic Games' Fortnite HTTP and XMPP services
181 lines • 7.46 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const Meta_1 = tslib_1.__importDefault(require("../../util/Meta"));
/**
* Represents a party member meta
*/
class PartyMemberMeta extends Meta_1.default {
/**
* Internal helper to get the primary loadout slots object
*/
get loadoutSlots() {
var _a, _b;
return ((_b = (_a = this.get('Default:MpLoadout1_j')) === null || _a === void 0 ? void 0 : _a.MpLoadout1) === null || _b === void 0 ? void 0 : _b.s) || {};
}
/**
* The currently equipped outfit CID
*/
get outfit() {
var _a, _b;
return (_b = (_a = this.loadoutSlots) === null || _a === void 0 ? void 0 : _a.ac) === null || _b === void 0 ? void 0 : _b.i;
}
/**
* The currently equipped pickaxe ID
*/
get pickaxe() {
var _a, _b;
return (_b = (_a = this.loadoutSlots) === null || _a === void 0 ? void 0 : _a.ap) === null || _b === void 0 ? void 0 : _b.i;
}
/**
* The current emote EID
*/
get emote() {
var _a, _b;
const emoteAsset = (_b = (_a = this.get('Default:FrontendEmote_j')) === null || _a === void 0 ? void 0 : _a.FrontendEmote) === null || _b === void 0 ? void 0 : _b.pickable;
if (emoteAsset === 'None' || !emoteAsset)
return undefined;
const match = emoteAsset.match(/\w*\.(\w*)/);
return match === null || match === void 0 ? void 0 : match[1];
}
/**
* The currently equipped backpack BID
*/
get backpack() {
var _a, _b;
return (_b = (_a = this.loadoutSlots) === null || _a === void 0 ? void 0 : _a.ab) === null || _b === void 0 ? void 0 : _b.i;
}
/**
* The currently equipped shoes
*/
get shoes() {
var _a, _b;
return (_b = (_a = this.loadoutSlots) === null || _a === void 0 ? void 0 : _a.as) === null || _b === void 0 ? void 0 : _b.i;
}
/**
* The currently equipped sidekick ID
*/
get sidekick() {
var _a, _b, _c;
return (_c = (_b = (_a = this.loadoutSlots) === null || _a === void 0 ? void 0 : _a.mm) === null || _b === void 0 ? void 0 : _b.i) === null || _c === void 0 ? void 0 : _c.replace('CosmeticMimosa:', '');
}
/**
* Whether the member is ready
*/
get isReady() {
var _a, _b;
return ((_b = (_a = this.get('Default:MatchmakingInfo_j')) === null || _a === void 0 ? void 0 : _a.MatchmakingInfo) === null || _b === void 0 ? void 0 : _b.readyStatus) === 'Ready';
}
/**
* Whether the member is sitting out
*/
get isSittingOut() {
var _a, _b;
return ((_b = (_a = this.get('Default:MatchmakingInfo_j')) === null || _a === void 0 ? void 0 : _a.MatchmakingInfo) === null || _b === void 0 ? void 0 : _b.readyStatus) === 'SittingOut';
}
/**
* The current input method
*/
get input() {
var _a, _b;
return (_b = (_a = this.get('Default:MatchmakingInfo_j')) === null || _a === void 0 ? void 0 : _a.MatchmakingInfo) === null || _b === void 0 ? void 0 : _b.currentInputType;
}
/**
* The cosmetic variants
*/
get variants() {
var _a, _b, _c, _d;
const slots = this.loadoutSlots;
return {
athenaCharacter: ((_a = slots.ac) === null || _a === void 0 ? void 0 : _a.v) ? { i: slots.ac.v.map((v) => `${v}`) } : undefined,
athenaBackpack: ((_b = slots.ab) === null || _b === void 0 ? void 0 : _b.v) ? { i: slots.ab.v.map((v) => `${v}`) } : undefined,
athenaPickaxe: ((_c = slots.ap) === null || _c === void 0 ? void 0 : _c.v) ? { i: slots.ap.v.map((v) => `${v}`) } : undefined,
athenaShoes: ((_d = slots.as) === null || _d === void 0 ? void 0 : _d.v) ? { i: slots.as.v.map((v) => `${v}`) } : undefined,
};
}
/**
* The banner info
*/
get banner() {
var _a, _b, _c, _d;
const slots = this.loadoutSlots;
if (!((_a = slots.li) === null || _a === void 0 ? void 0 : _a.i) && !((_b = slots.lc) === null || _b === void 0 ? void 0 : _b.i))
return undefined;
return {
bannerIconId: (_c = slots.li) === null || _c === void 0 ? void 0 : _c.i,
bannerColorId: (_d = slots.lc) === null || _d === void 0 ? void 0 : _d.i,
};
}
/**
* The battle pass info
*/
get battlepass() {
var _a;
const info = (_a = this.get('Default:BattlePassInfo_j')) === null || _a === void 0 ? void 0 : _a.BattlePassInfo;
if (!info)
return undefined;
return {
bHasPurchasedPass: !!info.bHasPurchasedPass,
passLevel: info.passLevel || 0,
};
}
/**
* The platform
*/
get platform() {
var _a, _b, _c, _d;
return (_d = (_c = (_b = (_a = this.get('Default:PlatformData_j')) === null || _a === void 0 ? void 0 : _a.PlatformData) === null || _b === void 0 ? void 0 : _b.platform) === null || _c === void 0 ? void 0 : _c.platformDescription) === null || _d === void 0 ? void 0 : _d.name;
}
/**
* The match info
*/
get match() {
var _a, _b, _c, _d;
const location = (_b = (_a = this.get('Default:PackedState_j')) === null || _a === void 0 ? void 0 : _a.PackedState) === null || _b === void 0 ? void 0 : _b.location;
const hasPreloadedAthena = (_d = (_c = this.get('Default:MatchmakingInfo_j')) === null || _c === void 0 ? void 0 : _c.MatchmakingInfo) === null || _d === void 0 ? void 0 : _d.hasPreloadedAthena;
const playerCount = this.get('Default:NumAthenaPlayersLeft_U');
const matchStartedAt = this.get('Default:UtcTimeStartedMatchAthena_s');
return {
hasPreloadedAthena,
location,
matchStartedAt: matchStartedAt && new Date(matchStartedAt),
playerCount,
};
}
/**
* The current island info
*/
get island() {
var _a, _b, _c;
const island = (_c = (_b = (_a = this.get('Default:MatchmakingInfo_j')) === null || _a === void 0 ? void 0 : _a.MatchmakingInfo) === null || _b === void 0 ? void 0 : _b.currentIsland) === null || _c === void 0 ? void 0 : _c.island;
if (typeof island === 'string')
return JSON.parse(island);
return island;
}
/**
* Whether a marker has been set
*/
get isMarkerSet() {
var _a, _b;
return !!((_b = (_a = this.get('Default:FrontEndMapMarker_j')) === null || _a === void 0 ? void 0 : _a.FrontEndMapMarker) === null || _b === void 0 ? void 0 : _b.bIsSet);
}
/**
* The marker location [x, y] tuple. [0, 0] if there is no marker set
*/
get markerLocation() {
var _a, _b;
const marker = (_b = (_a = this.get('Default:FrontEndMapMarker_j')) === null || _a === void 0 ? void 0 : _a.FrontEndMapMarker) === null || _b === void 0 ? void 0 : _b.markerLocation;
if (!marker)
return [0, 0];
return [marker.y, marker.x];
}
/**
* Whether the member owns Save The World
*/
get hasPurchasedSTW() {
var _a, _b;
return !!((_b = (_a = this.get('Default:PackedState_j')) === null || _a === void 0 ? void 0 : _a.PackedState) === null || _b === void 0 ? void 0 : _b.hasPurchasedSTW);
}
}
exports.default = PartyMemberMeta;
//# sourceMappingURL=PartyMemberMeta.js.map