Multiple fixes to the achievements

pull/1089/head
Tobias Springer 3 years ago
parent c6e18e9beb
commit f83e9f0fb8

@ -66,48 +66,34 @@ export class AchievementProxy {
startSlice() { startSlice() {
this.sliceTime = this.root.time.now(); this.sliceTime = this.root.time.now();
// Every slice this.root.signals.bulkAchievementCheck.dispatch(
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.storeShape); ACHIEVEMENTS.storeShape,
this.sliceTime,
// Every other slice ACHIEVEMENTS.throughputBp25,
if (this.sliceIteration % 2 === 0) { this.sliceTime,
this.root.signals.bulkAchievementCheck.dispatch( ACHIEVEMENTS.throughputBp50,
ACHIEVEMENTS.throughputBp25, this.sliceTime,
this.sliceTime, ACHIEVEMENTS.throughputLogo25,
ACHIEVEMENTS.throughputBp50, this.sliceTime,
this.sliceTime, ACHIEVEMENTS.throughputLogo50,
ACHIEVEMENTS.throughputLogo25, this.sliceTime,
this.sliceTime, ACHIEVEMENTS.throughputRocket10,
ACHIEVEMENTS.throughputLogo50, this.sliceTime,
this.sliceTime, ACHIEVEMENTS.throughputRocket20,
ACHIEVEMENTS.throughputRocket10, this.sliceTime,
this.sliceTime, ACHIEVEMENTS.play1h,
ACHIEVEMENTS.throughputRocket20, this.sliceTime,
this.sliceTime ACHIEVEMENTS.play10h,
); this.sliceTime,
} ACHIEVEMENTS.play20h,
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 === this.sliceIterationLimit) {
if (this.sliceIteration % 10 === 0) { this.sliceIteration = 1;
if (this.provider.collection) { if (this.provider.collection) {
this.provider.collection.clean(); this.provider.collection.clean();
} }
}
if (this.sliceIteration === this.sliceIterationLimit) {
this.sliceIteration = 1;
} else { } else {
this.sliceIteration++; this.sliceIteration++;
} }

@ -169,7 +169,7 @@ export class HubGoals extends BasicSerializableObject {
getCurrentGoalDelivered() { getCurrentGoalDelivered() {
if (this.currentGoal.throughputOnly) { if (this.currentGoal.throughputOnly) {
return ( return (
this.root.productionAnalytics.getCurrentShapeRate( this.root.productionAnalytics.getCurrentShapeRateRaw(
enumAnalyticsDataSource.delivered, enumAnalyticsDataSource.delivered,
this.currentGoal.definition this.currentGoal.definition
) / globalConfig.analyticsSliceDurationSeconds ) / globalConfig.analyticsSliceDurationSeconds

@ -273,7 +273,7 @@ export class HUDPinnedShapes extends BaseHUDPart {
if (handle.throughputOnly) { if (handle.throughputOnly) {
currentValue = currentValue =
this.root.productionAnalytics.getCurrentShapeRate( this.root.productionAnalytics.getCurrentShapeRateRaw(
enumAnalyticsDataSource.delivered, enumAnalyticsDataSource.delivered,
handle.definition handle.definition
) / globalConfig.analyticsSliceDurationSeconds; ) / globalConfig.analyticsSliceDurationSeconds;

@ -209,7 +209,9 @@ export class HUDStatistics extends BaseHUDPart {
} }
case enumAnalyticsDataSource.produced: case enumAnalyticsDataSource.produced:
case enumAnalyticsDataSource.delivered: { case enumAnalyticsDataSource.delivered: {
entries = Object.entries(this.root.productionAnalytics.getCurrentShapeRates(this.dataSource)); entries = Object.entries(
this.root.productionAnalytics.getCurrentShapeRatesRaw(this.dataSource)
);
break; break;
} }
} }

@ -100,7 +100,7 @@ export class HUDShapeStatisticsHandle {
case enumAnalyticsDataSource.delivered: case enumAnalyticsDataSource.delivered:
case enumAnalyticsDataSource.produced: { case enumAnalyticsDataSource.produced: {
let rate = let rate =
this.root.productionAnalytics.getCurrentShapeRate(dataSource, this.definition) / this.root.productionAnalytics.getCurrentShapeRateRaw(dataSource, this.definition) /
globalConfig.analyticsSliceDurationSeconds; globalConfig.analyticsSliceDurationSeconds;
this.counter.innerText = T.ingame.statistics.shapesDisplayUnits[unit].replace( this.counter.innerText = T.ingame.statistics.shapesDisplayUnits[unit].replace(

@ -83,7 +83,7 @@ export class ProductionAnalytics extends BasicSerializableObject {
* @param {enumAnalyticsDataSource} dataSource * @param {enumAnalyticsDataSource} dataSource
* @param {ShapeDefinition} definition * @param {ShapeDefinition} definition
*/ */
getCurrentShapeRate(dataSource, definition) { getCurrentShapeRateRaw(dataSource, definition) {
const slices = this.history[dataSource]; const slices = this.history[dataSource];
return slices[slices.length - 2][definition.getHash()] || 0; return slices[slices.length - 2][definition.getHash()] || 0;
} }
@ -108,7 +108,7 @@ export class ProductionAnalytics extends BasicSerializableObject {
* Returns the rates of all shapes * Returns the rates of all shapes
* @param {enumAnalyticsDataSource} dataSource * @param {enumAnalyticsDataSource} dataSource
*/ */
getCurrentShapeRates(dataSource) { getCurrentShapeRatesRaw(dataSource) {
const slices = this.history[dataSource]; const slices = this.history[dataSource];
// First, copy current slice // First, copy current slice

@ -8,6 +8,7 @@ import { THEMES } from "../game/theme";
import { enumAnalyticsDataSource } from "../game/production_analytics"; import { enumAnalyticsDataSource } from "../game/production_analytics";
import { ShapeItem } from "../game/items/shape_item"; import { ShapeItem } from "../game/items/shape_item";
import { globalConfig } from "../core/config";
export const ACHIEVEMENTS = { export const ACHIEVEMENTS = {
belt500Tiles: "belt500Tiles", belt500Tiles: "belt500Tiles",
@ -428,7 +429,7 @@ export class AchievementCollection {
* collection. * collection.
*/ */
hasAllUpgradesAtTier(tier) { hasAllUpgradesAtLeastAtTier(tier) {
const upgrades = this.root.gameMode.getUpgrades(); const upgrades = this.root.gameMode.getUpgrades();
for (let upgradeId in upgrades) { for (let upgradeId in upgrades) {
@ -452,7 +453,7 @@ export class AchievementCollection {
createLevelOptions(level) { createLevelOptions(level) {
return { return {
isRelevant: () => this.root.hubGoals.level < level, isRelevant: () => this.root.hubGoals.level < level,
isValid: currentLevel => currentLevel === level, isValid: currentLevel => currentLevel >= level,
signal: "storyGoalCompleted", signal: "storyGoalCompleted",
}; };
} }
@ -461,10 +462,12 @@ export class AchievementCollection {
return { return {
isValid: () => { isValid: () => {
return ( return (
this.root.productionAnalytics.getCurrentShapeRate( this.root.productionAnalytics.getCurrentShapeRateRaw(
enumAnalyticsDataSource.delivered, enumAnalyticsDataSource.delivered,
this.root.shapeDefinitionMgr.getShapeFromShortKey(shape) this.root.shapeDefinitionMgr.getShapeFromShortKey(shape)
) >= rate ) /
globalConfig.analyticsSliceDurationSeconds >=
rate
); );
}, },
}; };
@ -480,22 +483,21 @@ export class AchievementCollection {
createSpeedOptions(level, time) { createSpeedOptions(level, time) {
return { return {
isRelevant: () => this.root.hubGoals.level <= level && this.root.time.now() < time, 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", signal: "storyGoalCompleted",
}; };
} }
createTimeOptions(duration) { createTimeOptions(duration) {
return { return {
isRelevant: () => this.root.time.now() < duration,
isValid: () => this.root.time.now() >= duration, isValid: () => this.root.time.now() >= duration,
}; };
} }
createUpgradeOptions(tier) { createUpgradeOptions(tier) {
return { return {
isRelevant: () => !this.hasAllUpgradesAtTier(tier), isRelevant: () => !this.hasAllUpgradesAtLeastAtTier(tier),
isValid: () => this.hasAllUpgradesAtTier(tier), isValid: () => this.hasAllUpgradesAtLeastAtTier(tier),
signal: "upgradePurchased", signal: "upgradePurchased",
}; };
} }
@ -572,7 +574,7 @@ export class AchievementCollection {
/** @param {number} count @returns {boolean} */ /** @param {number} count @returns {boolean} */
isMapMarkers15Valid(count) { isMapMarkers15Valid(count) {
return count === 15; return count >= 15;
} }
/** @returns {boolean} */ /** @returns {boolean} */
@ -580,9 +582,12 @@ export class AchievementCollection {
return this.root.hubGoals.level <= 12 && this.root.hubGoals.upgradeLevels.belt === 0; return this.root.hubGoals.level <= 12 && this.root.hubGoals.upgradeLevels.belt === 0;
} }
/** @params {number} level @returns {boolean} */ /**
* @param {number} level
* @returns {boolean}
*/
isNoBeltUpgradesUntilBpValid(level) { isNoBeltUpgradesUntilBpValid(level) {
return level === 12 && this.root.hubGoals.upgradeLevels.belt === 0; return level >= 12 && this.root.hubGoals.upgradeLevels.belt === 0;
} }
initNoInverseRotater() { initNoInverseRotater() {
@ -612,7 +617,7 @@ export class AchievementCollection {
/** @param {number} level @returns {boolean} */ /** @param {number} level @returns {boolean} */
isNoInverseRotaterValid(level) { 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} */ /** @param {string} currentLayer @returns {boolean} */
@ -625,7 +630,7 @@ export class AchievementCollection {
return ( return (
entity.components.Wire && entity.components.Wire &&
entity.registered && 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} */ /** @returns {boolean} */
isStore100UniqueValid() { isStore100UniqueValid() {
return Object.keys(this.root.hubGoals.storedShapes).length === 100; return Object.keys(this.root.hubGoals.storedShapes).length >= 100;
} }
/** @returns {boolean} */ /** @returns {boolean} */

Loading…
Cancel
Save