UNPKG

@jovo-community/plugin-playfab

Version:

A Jovo Framework plugin for PlayFab LiveOps game backend.

101 lines 4.27 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.PlayFabPlugin = void 0; const framework_1 = require("@jovotech/framework"); const JovoPlayFab_1 = require("./JovoPlayFab"); class PlayFabPlugin extends framework_1.Plugin { mount(parent) { if (!(parent instanceof framework_1.HandleRequest)) { throw new framework_1.InvalidParentError(this.constructor.name, framework_1.HandleRequest); } parent.middlewareCollection.use('dialogue.start', async (jovo) => { jovo.$playfab = new JovoPlayFab_1.JovoPlayFab(this.config, jovo); if (!this.config.titleId) { throw new framework_1.JovoError({ message: `Can not connect to PlayFab. Title-ID is missing.`, }); } if (!this.config.developerSecretKey) { throw new framework_1.JovoError({ message: `Can not connect to PlayFab. Developer-SECRET-KEY is missing.`, }); } if (!jovo.$user.id) { throw new framework_1.JovoError({ message: `Can not send request to PlayFab. User-ID is missing.`, }); } if (this.config.login.maxNewProfileRetries < 0 || this.config.login.maxNewProfileRetries > 10) { throw new framework_1.JovoError({ message: `The value for login.maxNewProfileRetries must be between 0-10. Each retry is an API call.`, }); } if (this.config.leaderboard.topMax < 0 || this.config.leaderboard.topMax > 100) { throw new framework_1.JovoError({ message: `The value for leaderboard.topMax must be between 0-100.`, }); } if (this.config.leaderboard.neighborMax < 0 || this.config.leaderboard.neighborMax > 100) { throw new framework_1.JovoError({ message: `The value for leaderboard.neighborMax must be between 0-100.`, }); } jovo.$playfab.init(); if (this.config.login.autoLogin) { await jovo.$playfab.login(); } }); } getDefaultConfig() { return { titleId: '', developerSecretKey: '', login: { autoLogin: true, extendedProfileKey: '', maxNewProfileRetries: 2, infoRequestParameters: { GetCharacterInventories: false, GetCharacterList: false, GetPlayerProfile: false, GetPlayerStatistics: false, GetTitleData: false, GetUserAccountInfo: false, GetUserData: false, GetUserInventory: false, GetUserReadOnlyData: false, GetUserVirtualCurrency: false, }, }, leaderboard: { topMax: 5, neighborMax: 2, userDataKeys: [], profileConstraints: { ShowAvatarUrl: false, ShowBannedUntil: false, ShowCampaignAttributions: false, ShowContactEmailAddresses: false, ShowCreated: false, ShowDisplayName: false, ShowExperimentVariants: false, ShowLastLogin: false, ShowLinkedAccounts: false, ShowLocations: false, ShowMemberships: false, ShowOrigination: false, ShowPushNotificationRegistrations: false, ShowStatistics: false, ShowTags: false, ShowTotalValueToDateInUsd: false, ShowValuesToDate: false, }, }, }; } } exports.PlayFabPlugin = PlayFabPlugin; //# sourceMappingURL=PlayFabPlugin.js.map