From 790e404556fb6efa1f6fe9170bc03fc9cb7d7058 Mon Sep 17 00:00:00 2001 From: isaisstillalive Date: Sun, 28 Jun 2020 07:17:14 +0900 Subject: [PATCH] Get shape rate with shape key --- src/js/game/hud/parts/statistics_handle.js | 4 ++-- src/js/game/production_analytics.js | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/js/game/hud/parts/statistics_handle.js b/src/js/game/hud/parts/statistics_handle.js index 76d892bc..7bfd49d3 100644 --- a/src/js/game/hud/parts/statistics_handle.js +++ b/src/js/game/hud/parts/statistics_handle.js @@ -87,7 +87,7 @@ export class HUDShapeStatisticsHandle { case enumAnalyticsDataSource.produced: case enumAnalyticsDataSource.deliveredToStorage: { let rate = - (this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.definition) / + (this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.shapeKey) / globalConfig.analyticsSliceDurationSeconds) * 60; this.counter.innerText = T.ingame.statistics.shapesPerMinute.replace( @@ -136,7 +136,7 @@ export class HUDShapeStatisticsHandle { for (let i = 0; i < globalConfig.statisticsGraphSlices - 2; ++i) { const value = this.root.productionAnalytics.getPastShapeRate( dataSource, - this.definition, + this.shapeKey, globalConfig.statisticsGraphSlices - i - 2 ); if (value > maxValue) { diff --git a/src/js/game/production_analytics.js b/src/js/game/production_analytics.js index ec44978f..5c05d85f 100644 --- a/src/js/game/production_analytics.js +++ b/src/js/game/production_analytics.js @@ -98,27 +98,27 @@ export class ProductionAnalytics extends BasicSerializableObject { /** * Returns the current rate of a given shape * @param {enumAnalyticsDataSource} dataSource - * @param {ShapeDefinition} definition + * @param {string} shapeKey */ - getCurrentShapeRate(dataSource, definition) { + getCurrentShapeRate(dataSource, shapeKey) { const slices = this.history[dataSource]; - return slices[slices.length - 2][definition.getHash()] || 0; + return slices[slices.length - 2][shapeKey] || 0; } /** * Returns the rate of a given shape, frames ago * @param {enumAnalyticsDataSource} dataSource - * @param {ShapeDefinition} definition + * @param {string} shapeKey * @param {number} historyOffset */ - getPastShapeRate(dataSource, definition, historyOffset) { + getPastShapeRate(dataSource, shapeKey, historyOffset) { assertAlways( historyOffset >= 0 && historyOffset < globalConfig.statisticsGraphSlices - 1, "Invalid slice offset: " + historyOffset ); const slices = this.history[dataSource]; - return slices[slices.length - 2 - historyOffset][definition.getHash()] || 0; + return slices[slices.length - 2 - historyOffset][shapeKey] || 0; } /**