Properly activate Puzzle DLC on steam version (Fixes having to activate it manually in some cases)

pull/1252/head
tobspr 3 years ago
parent b6de716bee
commit 479539d9b8

@ -95,6 +95,15 @@ export class ShapezGameAnalytics extends GameAnalyticsInterface {
);
}
/**
* Makes sure a DLC is activated on steam
* @param {string} dlc
*/
activateDlc(dlc) {
logger.log("Activating dlc:", dlc);
return this.sendToApi("/v1/activate-dlc/" + dlc, {});
}
/**
* Sends a request to the api
* @param {string} endpoint Endpoint without base url

@ -83,6 +83,17 @@ export class PlatformWrapperImplElectron extends PlatformWrapperImplBrowser {
res => {
logger.log("Got DLC ownership:", res);
this.dlcs.puzzle = Boolean(res);
if (this.dlcs.puzzle && !G_IS_DEV) {
this.app.gameAnalytics.activateDlc("puzzle").then(
() => {
logger.log("Puzzle DLC successfully activated");
},
error => {
logger.error("Failed to activate puzzle DLC:", error);
}
);
}
},
err => {
logger.error("Failed to get DLC ownership:", err);

@ -39,4 +39,13 @@ export class GameAnalyticsInterface {
* @param {number} level
*/
handleUpgradeUnlocked(id, level) {}
/**
* Activates a DLC
* @param {string} dlc
*/
activateDlc(dlc) {
abstract;
return Promise.resolve();
}
}

Loading…
Cancel
Save