diff --git a/src/js/game/achievement_proxy.js b/src/js/game/achievement_proxy.js index 05f1a0af..01ed4a86 100644 --- a/src/js/game/achievement_proxy.js +++ b/src/js/game/achievement_proxy.js @@ -66,48 +66,34 @@ export class AchievementProxy { startSlice() { this.sliceTime = this.root.time.now(); - // Every slice - this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.storeShape); - - // Every other slice - if (this.sliceIteration % 2 === 0) { - this.root.signals.bulkAchievementCheck.dispatch( - ACHIEVEMENTS.throughputBp25, - this.sliceTime, - ACHIEVEMENTS.throughputBp50, - this.sliceTime, - ACHIEVEMENTS.throughputLogo25, - this.sliceTime, - ACHIEVEMENTS.throughputLogo50, - this.sliceTime, - ACHIEVEMENTS.throughputRocket10, - this.sliceTime, - ACHIEVEMENTS.throughputRocket20, - this.sliceTime - ); - } - - // Every 3rd slice - if (this.sliceIteration % 3 === 0) { - this.root.signals.bulkAchievementCheck.dispatch( - ACHIEVEMENTS.play1h, - this.sliceTime, - ACHIEVEMENTS.play10h, - this.sliceTime, - ACHIEVEMENTS.play20h, - this.sliceTime - ); - } - - // Every 10th slice - if (this.sliceIteration % 10 === 0) { - if (this.provider.collection) { - this.provider.collection.clean(); - } - } + this.root.signals.bulkAchievementCheck.dispatch( + ACHIEVEMENTS.storeShape, + this.sliceTime, + ACHIEVEMENTS.throughputBp25, + this.sliceTime, + ACHIEVEMENTS.throughputBp50, + this.sliceTime, + ACHIEVEMENTS.throughputLogo25, + this.sliceTime, + ACHIEVEMENTS.throughputLogo50, + this.sliceTime, + ACHIEVEMENTS.throughputRocket10, + this.sliceTime, + ACHIEVEMENTS.throughputRocket20, + this.sliceTime, + ACHIEVEMENTS.play1h, + this.sliceTime, + ACHIEVEMENTS.play10h, + this.sliceTime, + ACHIEVEMENTS.play20h, + this.sliceTime + ); if (this.sliceIteration === this.sliceIterationLimit) { this.sliceIteration = 1; + if (this.provider.collection) { + this.provider.collection.clean(); + } } else { this.sliceIteration++; } diff --git a/src/js/game/hub_goals.js b/src/js/game/hub_goals.js index 9a945128..327b6da7 100644 --- a/src/js/game/hub_goals.js +++ b/src/js/game/hub_goals.js @@ -169,7 +169,7 @@ export class HubGoals extends BasicSerializableObject { getCurrentGoalDelivered() { if (this.currentGoal.throughputOnly) { return ( - this.root.productionAnalytics.getCurrentShapeRate( + this.root.productionAnalytics.getCurrentShapeRateRaw( enumAnalyticsDataSource.delivered, this.currentGoal.definition ) / globalConfig.analyticsSliceDurationSeconds diff --git a/src/js/game/hud/parts/pinned_shapes.js b/src/js/game/hud/parts/pinned_shapes.js index bf1f7525..4a9fce0d 100644 --- a/src/js/game/hud/parts/pinned_shapes.js +++ b/src/js/game/hud/parts/pinned_shapes.js @@ -273,7 +273,7 @@ export class HUDPinnedShapes extends BaseHUDPart { if (handle.throughputOnly) { currentValue = - this.root.productionAnalytics.getCurrentShapeRate( + this.root.productionAnalytics.getCurrentShapeRateRaw( enumAnalyticsDataSource.delivered, handle.definition ) / globalConfig.analyticsSliceDurationSeconds; diff --git a/src/js/game/hud/parts/statistics.js b/src/js/game/hud/parts/statistics.js index a28ed288..015e48b6 100644 --- a/src/js/game/hud/parts/statistics.js +++ b/src/js/game/hud/parts/statistics.js @@ -209,7 +209,9 @@ export class HUDStatistics extends BaseHUDPart { } case enumAnalyticsDataSource.produced: case enumAnalyticsDataSource.delivered: { - entries = Object.entries(this.root.productionAnalytics.getCurrentShapeRates(this.dataSource)); + entries = Object.entries( + this.root.productionAnalytics.getCurrentShapeRatesRaw(this.dataSource) + ); break; } } diff --git a/src/js/game/hud/parts/statistics_handle.js b/src/js/game/hud/parts/statistics_handle.js index a64a5f5b..71181c81 100644 --- a/src/js/game/hud/parts/statistics_handle.js +++ b/src/js/game/hud/parts/statistics_handle.js @@ -100,7 +100,7 @@ export class HUDShapeStatisticsHandle { case enumAnalyticsDataSource.delivered: case enumAnalyticsDataSource.produced: { let rate = - this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.definition) / + this.root.productionAnalytics.getCurrentShapeRateRaw(dataSource, this.definition) / globalConfig.analyticsSliceDurationSeconds; this.counter.innerText = T.ingame.statistics.shapesDisplayUnits[unit].replace( diff --git a/src/js/game/production_analytics.js b/src/js/game/production_analytics.js index eda79c83..16eab4b8 100644 --- a/src/js/game/production_analytics.js +++ b/src/js/game/production_analytics.js @@ -83,7 +83,7 @@ export class ProductionAnalytics extends BasicSerializableObject { * @param {enumAnalyticsDataSource} dataSource * @param {ShapeDefinition} definition */ - getCurrentShapeRate(dataSource, definition) { + getCurrentShapeRateRaw(dataSource, definition) { const slices = this.history[dataSource]; return slices[slices.length - 2][definition.getHash()] || 0; } @@ -108,7 +108,7 @@ export class ProductionAnalytics extends BasicSerializableObject { * Returns the rates of all shapes * @param {enumAnalyticsDataSource} dataSource */ - getCurrentShapeRates(dataSource) { + getCurrentShapeRatesRaw(dataSource) { const slices = this.history[dataSource]; // First, copy current slice diff --git a/src/js/platform/achievement_provider.js b/src/js/platform/achievement_provider.js index 929a0c3d..1c37b7c2 100644 --- a/src/js/platform/achievement_provider.js +++ b/src/js/platform/achievement_provider.js @@ -8,6 +8,7 @@ import { THEMES } from "../game/theme"; import { enumAnalyticsDataSource } from "../game/production_analytics"; import { ShapeItem } from "../game/items/shape_item"; +import { globalConfig } from "../core/config"; export const ACHIEVEMENTS = { belt500Tiles: "belt500Tiles", @@ -428,7 +429,7 @@ export class AchievementCollection { * collection. */ - hasAllUpgradesAtTier(tier) { + hasAllUpgradesAtLeastAtTier(tier) { const upgrades = this.root.gameMode.getUpgrades(); for (let upgradeId in upgrades) { @@ -452,7 +453,7 @@ export class AchievementCollection { createLevelOptions(level) { return { isRelevant: () => this.root.hubGoals.level < level, - isValid: currentLevel => currentLevel === level, + isValid: currentLevel => currentLevel >= level, signal: "storyGoalCompleted", }; } @@ -461,10 +462,12 @@ export class AchievementCollection { return { isValid: () => { return ( - this.root.productionAnalytics.getCurrentShapeRate( + this.root.productionAnalytics.getCurrentShapeRateRaw( enumAnalyticsDataSource.delivered, this.root.shapeDefinitionMgr.getShapeFromShortKey(shape) - ) >= rate + ) / + globalConfig.analyticsSliceDurationSeconds >= + rate ); }, }; @@ -480,22 +483,21 @@ export class AchievementCollection { createSpeedOptions(level, time) { return { isRelevant: () => this.root.hubGoals.level <= level && this.root.time.now() < time, - isValid: currentLevel => currentLevel === level && this.root.time.now() < time, + isValid: currentLevel => currentLevel >= level && this.root.time.now() < time, signal: "storyGoalCompleted", }; } createTimeOptions(duration) { return { - isRelevant: () => this.root.time.now() < duration, isValid: () => this.root.time.now() >= duration, }; } createUpgradeOptions(tier) { return { - isRelevant: () => !this.hasAllUpgradesAtTier(tier), - isValid: () => this.hasAllUpgradesAtTier(tier), + isRelevant: () => !this.hasAllUpgradesAtLeastAtTier(tier), + isValid: () => this.hasAllUpgradesAtLeastAtTier(tier), signal: "upgradePurchased", }; } @@ -572,7 +574,7 @@ export class AchievementCollection { /** @param {number} count @returns {boolean} */ isMapMarkers15Valid(count) { - return count === 15; + return count >= 15; } /** @returns {boolean} */ @@ -580,9 +582,12 @@ export class AchievementCollection { return this.root.hubGoals.level <= 12 && this.root.hubGoals.upgradeLevels.belt === 0; } - /** @params {number} level @returns {boolean} */ + /** + * @param {number} level + * @returns {boolean} + */ isNoBeltUpgradesUntilBpValid(level) { - return level === 12 && this.root.hubGoals.upgradeLevels.belt === 0; + return level >= 12 && this.root.hubGoals.upgradeLevels.belt === 0; } initNoInverseRotater() { @@ -612,7 +617,7 @@ export class AchievementCollection { /** @param {number} level @returns {boolean} */ isNoInverseRotaterValid(level) { - return level === 14 && !this.root.savegame.currentData.stats.usedInverseRotater; + return level >= 14 && !this.root.savegame.currentData.stats.usedInverseRotater; } /** @param {string} currentLayer @returns {boolean} */ @@ -625,7 +630,7 @@ export class AchievementCollection { return ( entity.components.Wire && entity.registered && - entity.root.entityMgr.componentToEntity.Wire.length === 5000 + entity.root.entityMgr.componentToEntity.Wire.length >= 5000 ); } @@ -651,7 +656,7 @@ export class AchievementCollection { /** @returns {boolean} */ isStore100UniqueValid() { - return Object.keys(this.root.hubGoals.storedShapes).length === 100; + return Object.keys(this.root.hubGoals.storedShapes).length >= 100; } /** @returns {boolean} */