Path: blob/main/projects/particle-clicker/js/app.js
1834 views
"use strict";!function(){Helpers.validateSaveVersion();var e=new Game.Game;e.load();var t,r=e.lab,n=e.research,i=e.workers,o=e.upgrades,a=e.achievements,l=e.allObjects,s=angular.module("particleClicker",[]);s.filter("niceNumber",["$filter",function(e){return Helpers.formatNumberPostfix}]),s.filter("niceTime",["$filter",function(e){return Helpers.formatTime}]),s.filter("currency",["$filter",function(e){return function(t){return"JTN "+e("niceNumber")(t)}}]),s.filter("reverse",["$filter",function(e){return function(e){return e.slice().reverse()}}]),s.controller("DetectorController",(function(){this.click=function(){return r.clickDetector(),detector.addEvent(),UI.showUpdateValue("#update-data",r.state.detector),!1}})),document.getElementById("detector").addEventListener("mousedown",(function(e){e.preventDefault()})),s.controller("LabController",["$interval",function(e){this.lab=r,this.showDetectorInfo=function(){this._detectorInfo||(this._detectorInfo=Helpers.loadFile("html/detector.html")),UI.showModal("Detector",this._detectorInfo)},e((function(){var e=r.getGrant();UI.showUpdateValue("#update-funding",e);for(var t=0,n=0;n<i.length;n++)t+=i[n].state.hired*i[n].state.rate;t>0&&(r.acquireData(t),UI.showUpdateValue("#update-data",t),detector.addEventExternal(i.map((function(e){return e.state.hired})).reduce((function(e,t){return e+t}),0)))}),1e3)}]),s.controller("ResearchController",["$compile",function(e){this.research=n,this.isVisible=function(e){return e.isVisible(r)},this.isAvailable=function(e){return e.isAvailable(r)},this.doResearch=function(e){var t=e.research(r);t>0&&(UI.showUpdateValue("#update-data",-t),UI.showUpdateValue("#update-reputation",e.state.reputation))},this.showInfo=function(e){UI.showModal(e.name,e.getInfo()),UI.showLevels(e.state.level)}}]),s.controller("HRController",(function(){this.workers=i,this.isVisible=function(e){return e.isVisible(r)},this.isAvailable=function(e){return e.isAvailable(r)},this.hire=function(e){var t=e.hire(r);t>0&&UI.showUpdateValue("#update-funding",-t)}})),s.controller("UpgradesController",(function(){this.upgrades=o,this.isVisible=function(e){return e.isVisible(r,l)},this.isAvailable=function(e){return e.isAvailable(r,l)},this.upgrade=function(e){e.buy(r,l)&&UI.showUpdateValue("#update-funding",e.cost)}})),s.controller("AchievementsController",(function(e){e.achievements=a,e.progress=function(){return a.filter((function(e){return e.validate(r,l,t)})).length}})),s.controller("SaveController",["$scope","$interval",function(r,n){t=(new Date).getTime(),r.lastSaved=t,r.saveNow=function(){var n=(new Date).getTime();e.lab.state.time+=n-t,e.save(),t=n,r.lastSaved=t},r.restart=function(){window.confirm("Do you really want to restart the game? All progress will be lost.")&&(ObjectStorage.clear(),window.location.reload(!0))},n(r.saveNow,1e4)}]),s.controller("StatsController",(function(e){e.lab=r})),analytics.init(),analytics.sendScreen(analytics.screens.main)}();123