diff --git a/src/js/platform/achievement_provider.js b/src/js/platform/achievement_provider.js index 39918808..997f069f 100644 --- a/src/js/platform/achievement_provider.js +++ b/src/js/platform/achievement_provider.js @@ -58,214 +58,6 @@ export const ACHIEVEMENTS = { upgradesTier8: "upgradesTier8", }; -export const enum_achievement_mappings = { - [ACHIEVEMENTS.belt500Tiles]: function () { - return { - isValid: this.isBelt500TilesValid, - signal: "entityAdded", - }; - }, - [ACHIEVEMENTS.blueprint100k]: function () { - // @ts-ignore - return this.createBlueprintOptions(100000); - }, - [ACHIEVEMENTS.blueprint1m]: function () { - // @ts-ignore - return this.createBlueprintOptions(1000000); - }, - [ACHIEVEMENTS.completeLvl26]: function () { - // @ts-ignore - return this.createLevelOptions(26); - }, - [ACHIEVEMENTS.cutShape]: function () { - return {}; - }, - [ACHIEVEMENTS.darkMode]: function () { - return { - isValid: this.isDarkModeValid, - }; - }, - [ACHIEVEMENTS.destroy1000]: function () { - return { - isValid: this.isDestroy1000Valid, - }; - }, - [ACHIEVEMENTS.irrelevantShape]: function () { - return { - isValid: this.isIrrelevantShapeValid, - signal: "shapeDelivered", - }; - }, - [ACHIEVEMENTS.level100]: function () { - // @ts-ignore - return this.createLevelOptions(100); - }, - [ACHIEVEMENTS.level50]: function () { - // @ts-ignore - return this.createLevelOptions(50); - }, - [ACHIEVEMENTS.logoBefore18]: function () { - return { - isValid: this.isLogoBefore18Valid, - signal: "itemProduced", - }; - }, - [ACHIEVEMENTS.mam]: function () { - return { - isValid: this.isMamValid, - }; - }, - [ACHIEVEMENTS.mapMarkers15]: function () { - return { - isValid: this.isMapMarkers15Valid, - }; - }, - [ACHIEVEMENTS.noBeltUpgradesUntilBp]: function () { - return { - isValid: this.isNoBeltUpgradesUntilBpValid, - signal: "storyGoalCompleted", - }; - }, - [ACHIEVEMENTS.noInverseRotater]: function () { - return { - init: this.initNoInverseRotater, - isValid: this.isNoInverseRotaterValid, - signal: "storyGoalCompleted", - }; - }, - [ACHIEVEMENTS.oldLevel17]: function () { - // @ts-ignore - return this.createShapeOptions(SHAPE_OLD_LEVEL_17); - }, - [ACHIEVEMENTS.openWires]: function () { - return { - isValid: this.isOpenWiresValid, - signal: "editModeChanged", - }; - }, - [ACHIEVEMENTS.paintShape]: function () { - return {}; - }, - [ACHIEVEMENTS.place5000Wires]: function () { - return { - isValid: this.isPlace5000WiresValid, - }; - }, - [ACHIEVEMENTS.placeBlueprint]: function () { - return { - isValid: this.isPlaceBlueprintValid, - }; - }, - [ACHIEVEMENTS.placeBp1000]: function () { - return { - isValid: this.isPlaceBp1000Valid, - }; - }, - [ACHIEVEMENTS.play1h]: function () { - // @ts-ignore - return this.createTimeOptions(HOUR_1); - }, - [ACHIEVEMENTS.play10h]: function () { - // @ts-ignore - return this.createTimeOptions(HOUR_10); - }, - [ACHIEVEMENTS.play20h]: function () { - // @ts-ignore - return this.createTimeOptions(HOUR_20); - }, - [ACHIEVEMENTS.produceLogo]: function () { - // @ts-ignore - return this.createShapeOptions(SHAPE_LOGO); - }, - [ACHIEVEMENTS.produceRocket]: function () { - // @ts-ignore - return this.createShapeOptions(SHAPE_ROCKET); - }, - [ACHIEVEMENTS.produceMsLogo]: function () { - // @ts-ignore - return this.createShapeOptions(SHAPE_MS_LOGO); - }, - [ACHIEVEMENTS.rotateShape]: function () { - return {}; - }, - [ACHIEVEMENTS.speedrunBp30]: function () { - // @ts-ignore - return this.createSpeedOptions(12, MINUTE_30); - }, - [ACHIEVEMENTS.speedrunBp60]: function () { - // @ts-ignore - return this.createSpeedOptions(12, MINUTE_60); - }, - [ACHIEVEMENTS.speedrunBp120]: function () { - // @ts-ignore - return this.createSpeedOptions(12, MINUTE_120); - }, - [ACHIEVEMENTS.stack4Layers]: function () { - return { - isValid: this.isStack4LayersValid, - signal: "itemProduced", - }; - }, - [ACHIEVEMENTS.stackShape]: function () { - return {}; - }, - [ACHIEVEMENTS.store100Unique]: function () { - return { - init: this.initStore100Unique, - isValid: this.isStore100UniqueValid, - signal: "shapeDelivered", - }; - }, - [ACHIEVEMENTS.storeShape]: function () { - return { - init: this.initStoreShape, - isValid: this.isStoreShapeValid, - }; - }, - [ACHIEVEMENTS.throughputBp25]: function () { - // @ts-ignore - return this.createRateOptions(SHAPE_BP, 25); - }, - [ACHIEVEMENTS.throughputBp50]: function () { - // @ts-ignore - return this.createRateOptions(SHAPE_BP, 50); - }, - [ACHIEVEMENTS.throughputLogo25]: function () { - // @ts-ignore - return this.createRateOptions(SHAPE_LOGO, 25); - }, - [ACHIEVEMENTS.throughputLogo50]: function () { - // @ts-ignore - return this.createRateOptions(SHAPE_LOGO, 50); - }, - [ACHIEVEMENTS.throughputRocket10]: function () { - // @ts-ignore - return this.createRateOptions(SHAPE_ROCKET, 25); - }, - [ACHIEVEMENTS.throughputRocket20]: function () { - // @ts-ignore - return this.createRateOptions(SHAPE_ROCKET, 50); - }, - [ACHIEVEMENTS.trash1000]: function () { - return { - init: this.initTrash1000, - isValid: this.isTrash1000Valid, - }; - }, - [ACHIEVEMENTS.unlockWires]: function () { - // @ts-ignore - return this.createLevelOptions(20); - }, - [ACHIEVEMENTS.upgradesTier5]: function () { - // @ts-ignore - return this.createUpgradeOptions(5); - }, - [ACHIEVEMENTS.upgradesTier8]: function () { - // @ts-ignore - return this.createUpgradeOptions(8); - }, -}; - /** @type {keyof typeof THEMES} */ const DARK_MODE = "dark"; @@ -378,9 +170,97 @@ export class AchievementCollection { this.activate = activate; this.deactivate = deactivate; - for (const key in ACHIEVEMENTS) { - this.add(ACHIEVEMENTS[key], enum_achievement_mappings[ACHIEVEMENTS[key]].bind(this)()); - } + this.add(ACHIEVEMENTS.belt500Tiles, { + isValid: this.isBelt500TilesValid, + signal: "entityAdded", + }); + this.add(ACHIEVEMENTS.blueprint100k, this.createBlueprintOptions(100000)); + this.add(ACHIEVEMENTS.blueprint1m, this.createBlueprintOptions(1000000)); + this.add(ACHIEVEMENTS.completeLvl26, this.createLevelOptions(26)); + this.add(ACHIEVEMENTS.cutShape); + this.add(ACHIEVEMENTS.darkMode, { + isValid: this.isDarkModeValid, + }); + this.add(ACHIEVEMENTS.destroy1000, { + isValid: this.isDestroy1000Valid, + }); + this.add(ACHIEVEMENTS.irrelevantShape, { + isValid: this.isIrrelevantShapeValid, + signal: "shapeDelivered", + }); + this.add(ACHIEVEMENTS.level100, this.createLevelOptions(100)); + this.add(ACHIEVEMENTS.level50, this.createLevelOptions(50)); + this.add(ACHIEVEMENTS.logoBefore18, { + isValid: this.isLogoBefore18Valid, + signal: "itemProduced", + }); + this.add(ACHIEVEMENTS.mam, { + isValid: this.isMamValid, + }); + this.add(ACHIEVEMENTS.mapMarkers15, { + isValid: this.isMapMarkers15Valid, + }); + this.add(ACHIEVEMENTS.noBeltUpgradesUntilBp, { + isValid: this.isNoBeltUpgradesUntilBpValid, + signal: "storyGoalCompleted", + }); + this.add(ACHIEVEMENTS.noInverseRotater, { + init: this.initNoInverseRotater, + isValid: this.isNoInverseRotaterValid, + signal: "storyGoalCompleted", + }); + this.add(ACHIEVEMENTS.oldLevel17, this.createShapeOptions(SHAPE_OLD_LEVEL_17)); + this.add(ACHIEVEMENTS.openWires, { + isValid: this.isOpenWiresValid, + signal: "editModeChanged", + }); + this.add(ACHIEVEMENTS.paintShape); + this.add(ACHIEVEMENTS.place5000Wires, { + isValid: this.isPlace5000WiresValid, + }); + this.add(ACHIEVEMENTS.placeBlueprint, { + isValid: this.isPlaceBlueprintValid, + }); + this.add(ACHIEVEMENTS.placeBp1000, { + isValid: this.isPlaceBp1000Valid, + }); + this.add(ACHIEVEMENTS.play1h, this.createTimeOptions(HOUR_1)); + this.add(ACHIEVEMENTS.play10h, this.createTimeOptions(HOUR_10)); + this.add(ACHIEVEMENTS.play20h, this.createTimeOptions(HOUR_20)); + this.add(ACHIEVEMENTS.produceLogo, this.createShapeOptions(SHAPE_LOGO)); + this.add(ACHIEVEMENTS.produceRocket, this.createShapeOptions(SHAPE_ROCKET)); + this.add(ACHIEVEMENTS.produceMsLogo, this.createShapeOptions(SHAPE_MS_LOGO)); + this.add(ACHIEVEMENTS.rotateShape); + this.add(ACHIEVEMENTS.speedrunBp30, this.createSpeedOptions(12, MINUTE_30)); + this.add(ACHIEVEMENTS.speedrunBp60, this.createSpeedOptions(12, MINUTE_60)); + this.add(ACHIEVEMENTS.speedrunBp120, this.createSpeedOptions(12, MINUTE_120)); + this.add(ACHIEVEMENTS.stack4Layers, { + isValid: this.isStack4LayersValid, + signal: "itemProduced", + }); + this.add(ACHIEVEMENTS.stackShape); + this.add(ACHIEVEMENTS.store100Unique, { + init: this.initStore100Unique, + isValid: this.isStore100UniqueValid, + signal: "shapeDelivered", + }); + this.add(ACHIEVEMENTS.storeShape, { + init: this.initStoreShape, + isValid: this.isStoreShapeValid, + }); + this.add(ACHIEVEMENTS.throughputBp25, this.createRateOptions(SHAPE_BP, 25)); + this.add(ACHIEVEMENTS.throughputBp50, this.createRateOptions(SHAPE_BP, 50)); + this.add(ACHIEVEMENTS.throughputLogo25, this.createRateOptions(SHAPE_LOGO, 25)); + this.add(ACHIEVEMENTS.throughputLogo50, this.createRateOptions(SHAPE_LOGO, 50)); + this.add(ACHIEVEMENTS.throughputRocket10, this.createRateOptions(SHAPE_ROCKET, 25)); + this.add(ACHIEVEMENTS.throughputRocket20, this.createRateOptions(SHAPE_ROCKET, 50)); + this.add(ACHIEVEMENTS.trash1000, { + init: this.initTrash1000, + isValid: this.isTrash1000Valid, + }); + this.add(ACHIEVEMENTS.unlockWires, this.createLevelOptions(20)); + this.add(ACHIEVEMENTS.upgradesTier5, this.createUpgradeOptions(5)); + this.add(ACHIEVEMENTS.upgradesTier8, this.createUpgradeOptions(8)); } /** @param {GameRoot} root */