Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
/* typehints:start */
|
|
|
|
import { Entity } from "./entity";
|
|
|
|
import { GameRoot } from "./root";
|
|
|
|
/* typehints:end */
|
|
|
|
|
|
|
|
import { globalConfig } from "../core/config";
|
|
|
|
import { createLogger } from "../core/logging";
|
|
|
|
import { ACHIEVEMENTS } from "../platform/achievement_provider";
|
|
|
|
import { getBuildingDataFromCode } from "./building_codes";
|
|
|
|
|
|
|
|
const logger = createLogger("achievement_proxy");
|
|
|
|
|
|
|
|
const ROTATER = "rotater";
|
|
|
|
const DEFAULT = "default";
|
|
|
|
|
|
|
|
export class AchievementProxy {
|
|
|
|
/** @param {GameRoot} root */
|
|
|
|
constructor(root) {
|
|
|
|
this.root = root;
|
|
|
|
this.provider = this.root.app.achievementProvider;
|
|
|
|
this.disabled = true;
|
|
|
|
|
|
|
|
if (G_IS_DEV && globalConfig.debug.testAchievements) {
|
|
|
|
// still enable the proxy
|
|
|
|
} else if (!this.provider.hasAchievements()) {
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.sliceTime = 0;
|
|
|
|
|
|
|
|
this.root.signals.postLoadHook.add(this.onLoad, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
onLoad() {
|
|
|
|
this.provider
|
|
|
|
.onLoad(this.root)
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
.then(() => {
|
|
|
|
this.disabled = false;
|
|
|
|
logger.log("Recieving achievement signals");
|
|
|
|
this.initialize();
|
|
|
|
})
|
|
|
|
.catch(err => {
|
|
|
|
this.disabled = true;
|
|
|
|
logger.error("Ignoring achievement signals", err);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
initialize() {
|
|
|
|
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.darkMode, null);
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
|
|
|
|
if (this.has(ACHIEVEMENTS.mam)) {
|
|
|
|
this.root.signals.entityAdded.add(this.onMamFailure, this);
|
|
|
|
this.root.signals.entityDestroyed.add(this.onMamFailure, this);
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
this.root.signals.storyGoalCompleted.add(this.onStoryGoalCompleted, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.has(ACHIEVEMENTS.noInverseRotater)) {
|
|
|
|
this.root.signals.entityAdded.add(this.onEntityAdded, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.startSlice();
|
|
|
|
}
|
|
|
|
|
|
|
|
startSlice() {
|
|
|
|
this.sliceTime = this.root.time.now();
|
|
|
|
|
|
|
|
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
|
|
|
|
);
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
|
|
|
if (this.disabled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.root.time.now() - this.sliceTime > globalConfig.achievementSliceDuration) {
|
|
|
|
this.startSlice();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param {string} key
|
|
|
|
* @returns {boolean}
|
|
|
|
*/
|
|
|
|
has(key) {
|
|
|
|
if (!this.provider.collection) {
|
|
|
|
return false;
|
|
|
|
}
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
return this.provider.collection.map.has(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @param {Entity} entity */
|
|
|
|
onEntityAdded(entity) {
|
|
|
|
if (!entity.components.StaticMapEntity) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const building = getBuildingDataFromCode(entity.components.StaticMapEntity.code);
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
|
|
|
|
if (building.metaInstance.id !== ROTATER) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (building.variant === DEFAULT) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.root.savegame.currentData.stats.usedInverseRotater = true;
|
|
|
|
this.root.signals.entityAdded.remove(this.onEntityAdded);
|
|
|
|
}
|
|
|
|
|
|
|
|
/** @param {number} level */
|
|
|
|
onStoryGoalCompleted(level) {
|
|
|
|
if (level > 26) {
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
this.root.signals.entityAdded.add(this.onMamFailure, this);
|
|
|
|
this.root.signals.entityDestroyed.add(this.onMamFailure, this);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.root.signals.achievementCheck.dispatch(ACHIEVEMENTS.mam, null);
|
|
|
|
|
|
|
|
// reset on every level
|
|
|
|
this.root.savegame.currentData.stats.failedMam = false;
|
Achievements (#1087)
* [WIP] Add boilerplate for achievement implementation
* Add config.local.template.js and rm cached copy of config.local.js
* [WIP] Implement painting, cutting, rotating achievements (to log only)
* [WIP] Refactor achievements, jsdoc fixes, add npm script
- Refactor achievements to make use of Signals
- Move implemented achievement interfaces to appropriate
platform folders (SteamAchievements in currently in use
in browser wrapper for testing)
- Fix invalid jsdocs
- Add dev-standalone script to package.json scripts
* Add steam/greenworks IPC calls and optional private-artifact dependency
* Include private artifacts in standalone builds
* Uncomment appid include
* [WIP] Add steam overlay fix, add hash to artifact dependency
* Update electron, greenworks. Add task to add local config if not present
* Add more achievements, refactor achievement code
* Add receiver flexibility and more achievements
- Add check to see if necessary to create achievement and add receiver
- Add remove receiver functionality when achievement is unlocked
* Add achievements and accommodations for switching states
- Fix startup code to avoid clobbering achievements on state switch
- Add a few more achievements
* Add achievements, ids. Update names, keys for consistency
* Add play time achievements
* [WIP] Add more achievements
* Add more achievements. Add bulk achievement check signal
* [WIP] Add achievements. Start savefile migration
* Add achievements. Add savefile migration
* Remove superfluous achievement stat
* Update lock files, fix merge conflict
4 years ago
|
|
|
}
|
|
|
|
|
|
|
|
onMamFailure() {
|
|
|
|
this.root.savegame.currentData.stats.failedMam = true;
|
|
|
|
}
|
|
|
|
}
|