Achievements, fix no. 2
This commit is contained in:
parent
f83e9f0fb8
commit
4685f813e8
|
@ -27,8 +27,6 @@ export class AchievementProxy {
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sliceTime = 0;
|
this.sliceTime = 0;
|
||||||
this.sliceIteration = 1;
|
|
||||||
this.sliceIterationLimit = 10;
|
|
||||||
|
|
||||||
this.root.signals.postLoadHook.add(this.onLoad, this);
|
this.root.signals.postLoadHook.add(this.onLoad, this);
|
||||||
}
|
}
|
||||||
|
@ -88,15 +86,6 @@ export class AchievementProxy {
|
||||||
ACHIEVEMENTS.play20h,
|
ACHIEVEMENTS.play20h,
|
||||||
this.sliceTime
|
this.sliceTime
|
||||||
);
|
);
|
||||||
|
|
||||||
if (this.sliceIteration === this.sliceIterationLimit) {
|
|
||||||
this.sliceIteration = 1;
|
|
||||||
if (this.provider.collection) {
|
|
||||||
this.provider.collection.clean();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.sliceIteration++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
|
|
|
@ -150,10 +150,6 @@ export class Achievement {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
isRelevant() {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
unlock() {
|
unlock() {
|
||||||
if (!this.activatePromise) {
|
if (!this.activatePromise) {
|
||||||
this.activatePromise = this.activate(this.key);
|
this.activatePromise = this.activate(this.key);
|
||||||
|
@ -198,7 +194,6 @@ export class AchievementCollection {
|
||||||
this.add(ACHIEVEMENTS.level100, this.createLevelOptions(100));
|
this.add(ACHIEVEMENTS.level100, this.createLevelOptions(100));
|
||||||
this.add(ACHIEVEMENTS.level50, this.createLevelOptions(50));
|
this.add(ACHIEVEMENTS.level50, this.createLevelOptions(50));
|
||||||
this.add(ACHIEVEMENTS.logoBefore18, {
|
this.add(ACHIEVEMENTS.logoBefore18, {
|
||||||
isRelevant: this.isLogoBefore18Relevant,
|
|
||||||
isValid: this.isLogoBefore18Valid,
|
isValid: this.isLogoBefore18Valid,
|
||||||
signal: "itemProduced",
|
signal: "itemProduced",
|
||||||
});
|
});
|
||||||
|
@ -206,17 +201,14 @@ export class AchievementCollection {
|
||||||
isValid: this.isMamValid,
|
isValid: this.isMamValid,
|
||||||
});
|
});
|
||||||
this.add(ACHIEVEMENTS.mapMarkers15, {
|
this.add(ACHIEVEMENTS.mapMarkers15, {
|
||||||
isRelevant: this.isMapMarkers15Relevant,
|
|
||||||
isValid: this.isMapMarkers15Valid,
|
isValid: this.isMapMarkers15Valid,
|
||||||
});
|
});
|
||||||
this.add(ACHIEVEMENTS.noBeltUpgradesUntilBp, {
|
this.add(ACHIEVEMENTS.noBeltUpgradesUntilBp, {
|
||||||
isRelevant: this.isNoBeltUpgradesUntilBpRelevant,
|
|
||||||
isValid: this.isNoBeltUpgradesUntilBpValid,
|
isValid: this.isNoBeltUpgradesUntilBpValid,
|
||||||
signal: "storyGoalCompleted",
|
signal: "storyGoalCompleted",
|
||||||
});
|
});
|
||||||
this.add(ACHIEVEMENTS.noInverseRotater, {
|
this.add(ACHIEVEMENTS.noInverseRotater, {
|
||||||
init: this.initNoInverseRotater,
|
init: this.initNoInverseRotater,
|
||||||
isRelevant: this.isNoInverseRotaterRelevant,
|
|
||||||
isValid: this.isNoInverseRotaterValid,
|
isValid: this.isNoInverseRotaterValid,
|
||||||
signal: "storyGoalCompleted",
|
signal: "storyGoalCompleted",
|
||||||
});
|
});
|
||||||
|
@ -251,7 +243,6 @@ export class AchievementCollection {
|
||||||
});
|
});
|
||||||
this.add(ACHIEVEMENTS.stackShape);
|
this.add(ACHIEVEMENTS.stackShape);
|
||||||
this.add(ACHIEVEMENTS.store100Unique, {
|
this.add(ACHIEVEMENTS.store100Unique, {
|
||||||
isRelevant: this.isStore100UniqueRelevant,
|
|
||||||
isValid: this.isStore100UniqueValid,
|
isValid: this.isStore100UniqueValid,
|
||||||
signal: "shapeDelivered",
|
signal: "shapeDelivered",
|
||||||
});
|
});
|
||||||
|
@ -284,11 +275,6 @@ export class AchievementCollection {
|
||||||
achievement.init();
|
achievement.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!achievement.isRelevant()) {
|
|
||||||
this.remove(key);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (achievement.signal) {
|
if (achievement.signal) {
|
||||||
achievement.receiver = this.unlock.bind(this, key);
|
achievement.receiver = this.unlock.bind(this, key);
|
||||||
this.root.signals[achievement.signal].add(achievement.receiver);
|
this.root.signals[achievement.signal].add(achievement.receiver);
|
||||||
|
@ -305,7 +291,6 @@ export class AchievementCollection {
|
||||||
* @param {string} key - Maps to an Achievement
|
* @param {string} key - Maps to an Achievement
|
||||||
* @param {object} [options]
|
* @param {object} [options]
|
||||||
* @param {function} [options.init]
|
* @param {function} [options.init]
|
||||||
* @param {function} [options.isRelevant]
|
|
||||||
* @param {function} [options.isValid]
|
* @param {function} [options.isValid]
|
||||||
* @param {string} [options.signal]
|
* @param {string} [options.signal]
|
||||||
*/
|
*/
|
||||||
|
@ -326,10 +311,6 @@ export class AchievementCollection {
|
||||||
achievement.isValid = options.isValid.bind(this);
|
achievement.isValid = options.isValid.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options.isRelevant) {
|
|
||||||
achievement.isRelevant = options.isRelevant.bind(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.signal) {
|
if (options.signal) {
|
||||||
achievement.signal = options.signal;
|
achievement.signal = options.signal;
|
||||||
}
|
}
|
||||||
|
@ -394,18 +375,6 @@ export class AchievementCollection {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Intended to be called on occasion to prune achievements that became
|
|
||||||
* irrelevant during a play session.
|
|
||||||
*/
|
|
||||||
clean() {
|
|
||||||
for (let [key, achievement] of this.map.entries()) {
|
|
||||||
if (!achievement.activatePromise && !achievement.isRelevant()) {
|
|
||||||
this.remove(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the collection-level achievementCheck receivers are still
|
* Check if the collection-level achievementCheck receivers are still
|
||||||
* necessary.
|
* necessary.
|
||||||
|
@ -452,7 +421,6 @@ export class AchievementCollection {
|
||||||
|
|
||||||
createLevelOptions(level) {
|
createLevelOptions(level) {
|
||||||
return {
|
return {
|
||||||
isRelevant: () => this.root.hubGoals.level < level,
|
|
||||||
isValid: currentLevel => currentLevel >= level,
|
isValid: currentLevel => currentLevel >= level,
|
||||||
signal: "storyGoalCompleted",
|
signal: "storyGoalCompleted",
|
||||||
};
|
};
|
||||||
|
@ -482,7 +450,6 @@ export class AchievementCollection {
|
||||||
|
|
||||||
createSpeedOptions(level, time) {
|
createSpeedOptions(level, time) {
|
||||||
return {
|
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",
|
signal: "storyGoalCompleted",
|
||||||
};
|
};
|
||||||
|
@ -496,7 +463,6 @@ export class AchievementCollection {
|
||||||
|
|
||||||
createUpgradeOptions(tier) {
|
createUpgradeOptions(tier) {
|
||||||
return {
|
return {
|
||||||
isRelevant: () => !this.hasAllUpgradesAtLeastAtTier(tier),
|
|
||||||
isValid: () => this.hasAllUpgradesAtLeastAtTier(tier),
|
isValid: () => this.hasAllUpgradesAtLeastAtTier(tier),
|
||||||
signal: "upgradePurchased",
|
signal: "upgradePurchased",
|
||||||
};
|
};
|
||||||
|
@ -552,11 +518,6 @@ export class AchievementCollection {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
|
||||||
isLogoBefore18Relevant() {
|
|
||||||
return this.root.hubGoals.level < 18;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param {ShapeItem} item @returns {boolean} */
|
/** @param {ShapeItem} item @returns {boolean} */
|
||||||
isLogoBefore18Valid(item) {
|
isLogoBefore18Valid(item) {
|
||||||
return this.root.hubGoals.level < 18 && this.isShape(item, SHAPE_LOGO);
|
return this.root.hubGoals.level < 18 && this.isShape(item, SHAPE_LOGO);
|
||||||
|
@ -567,21 +528,11 @@ export class AchievementCollection {
|
||||||
return this.root.hubGoals.level > 27 && !this.root.savegame.currentData.stats.failedMam;
|
return this.root.hubGoals.level > 27 && !this.root.savegame.currentData.stats.failedMam;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
|
||||||
isMapMarkers15Relevant() {
|
|
||||||
return this.root.hud.parts.waypoints.waypoints.length < 16; // 16 - HUB
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @param {number} count @returns {boolean} */
|
/** @param {number} count @returns {boolean} */
|
||||||
isMapMarkers15Valid(count) {
|
isMapMarkers15Valid(count) {
|
||||||
return count >= 15;
|
return count >= 15;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
|
||||||
isNoBeltUpgradesUntilBpRelevant() {
|
|
||||||
return this.root.hubGoals.level <= 12 && this.root.hubGoals.upgradeLevels.belt === 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {number} level
|
* @param {number} level
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
|
@ -610,11 +561,6 @@ export class AchievementCollection {
|
||||||
this.root.savegame.currentData.stats.usedInverseRotater = usedInverseRotater;
|
this.root.savegame.currentData.stats.usedInverseRotater = usedInverseRotater;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
|
||||||
isNoInverseRotaterRelevant() {
|
|
||||||
return this.root.hubGoals.level < 14 && !this.root.savegame.currentData.stats.usedInverseRotater;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @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;
|
||||||
|
@ -649,11 +595,6 @@ export class AchievementCollection {
|
||||||
return item.getItemType() === ITEM_SHAPE && item.definition.layers.length === 4;
|
return item.getItemType() === ITEM_SHAPE && item.definition.layers.length === 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @returns {boolean} */
|
|
||||||
isStore100UniqueRelevant() {
|
|
||||||
return Object.keys(this.root.hubGoals.storedShapes).length < 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @returns {boolean} */
|
/** @returns {boolean} */
|
||||||
isStore100UniqueValid() {
|
isStore100UniqueValid() {
|
||||||
return Object.keys(this.root.hubGoals.storedShapes).length >= 100;
|
return Object.keys(this.root.hubGoals.storedShapes).length >= 100;
|
||||||
|
|
Loading…
Reference in New Issue