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:
parent
c6e18e9beb
commit
f83e9f0fb8
@ -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++;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -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} */
|
||||
|
Loading…
Reference in New Issue
Block a user