1
0
mirror of https://github.com/tobspr/shapez.io.git synced 2024-10-27 20:34:29 +00:00

Multiple fixes to the achievements

This commit is contained in:
Tobias Springer 2021-03-10 11:59:47 +01:00
parent c6e18e9beb
commit f83e9f0fb8
7 changed files with 52 additions and 59 deletions

View File

@ -66,12 +66,9 @@ export class AchievementProxy {
startSlice() { startSlice() {
this.sliceTime = this.root.time.now(); 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( this.root.signals.bulkAchievementCheck.dispatch(
ACHIEVEMENTS.storeShape,
this.sliceTime,
ACHIEVEMENTS.throughputBp25, ACHIEVEMENTS.throughputBp25,
this.sliceTime, this.sliceTime,
ACHIEVEMENTS.throughputBp50, ACHIEVEMENTS.throughputBp50,
@ -83,13 +80,7 @@ export class AchievementProxy {
ACHIEVEMENTS.throughputRocket10, ACHIEVEMENTS.throughputRocket10,
this.sliceTime, this.sliceTime,
ACHIEVEMENTS.throughputRocket20, ACHIEVEMENTS.throughputRocket20,
this.sliceTime this.sliceTime,
);
}
// Every 3rd slice
if (this.sliceIteration % 3 === 0) {
this.root.signals.bulkAchievementCheck.dispatch(
ACHIEVEMENTS.play1h, ACHIEVEMENTS.play1h,
this.sliceTime, this.sliceTime,
ACHIEVEMENTS.play10h, ACHIEVEMENTS.play10h,
@ -97,17 +88,12 @@ export class AchievementProxy {
ACHIEVEMENTS.play20h, ACHIEVEMENTS.play20h,
this.sliceTime this.sliceTime
); );
}
// Every 10th slice
if (this.sliceIteration % 10 === 0) {
if (this.provider.collection) {
this.provider.collection.clean();
}
}
if (this.sliceIteration === this.sliceIterationLimit) { if (this.sliceIteration === this.sliceIterationLimit) {
this.sliceIteration = 1; this.sliceIteration = 1;
if (this.provider.collection) {
this.provider.collection.clean();
}
} else { } else {
this.sliceIteration++; this.sliceIteration++;
} }

View File

@ -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

View File

@ -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;

View File

@ -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;
} }
} }

View File

@ -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(

View File

@ -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

View File

@ -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} */