mirror of
https://github.com/wassname/cardsforscience.git
synced 2026-09-09 11:19:16 +08:00
Get new outreach engine working.
This commit is contained in:
+17
-4
@@ -62,7 +62,7 @@
|
||||
}, 1000);
|
||||
}]);
|
||||
|
||||
app.controller('ResearchController', function() {
|
||||
app.controller('ResearchController', ['$compile', function($compile) {
|
||||
this.research = research;
|
||||
this.doResearch = function(item) {
|
||||
var cost = item.research();
|
||||
@@ -72,9 +72,19 @@
|
||||
achievements.update('research', item.name, 1);
|
||||
UI.showUpdateValue("#update-data", -cost);
|
||||
UI.showUpdateValue("#update-reputation", item.reputation);
|
||||
analytics.sendEvent(
|
||||
analytics.events.categoryResearch,
|
||||
analytics.events.actionResearch,
|
||||
item.name,
|
||||
item.level
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
||||
this.showInfo = function(r) {
|
||||
UI.showModal(r.name, r.getInfo());
|
||||
UI.showLevels(r.level);
|
||||
};
|
||||
}]);
|
||||
|
||||
app.controller('HRController', function() {
|
||||
this.workers = workers;
|
||||
@@ -107,7 +117,8 @@
|
||||
this.achievementsAll = achievements.list;
|
||||
});
|
||||
|
||||
app.controller('SaveController', ['$scope', '$interval', function($scope, $interval) {
|
||||
app.controller('SaveController',
|
||||
['$scope', '$interval', function($scope, $interval) {
|
||||
$scope.lastSaved = new Date();
|
||||
$scope.saveNow = function() {
|
||||
GameObjects.saveAll();
|
||||
@@ -115,7 +126,9 @@
|
||||
achievements.lastSave = $scope.lastSaved.getTime();
|
||||
};
|
||||
$scope.restart = function() {
|
||||
if (window.confirm('Do you really want to restart the game? All progress will be lost.')) {
|
||||
if (window.confirm(
|
||||
'Do you really want to restart the game? All progress will be lost.'
|
||||
)) {
|
||||
ObjectStorage.clear();
|
||||
window.location.reload(true);
|
||||
}
|
||||
|
||||
+6
-4
@@ -61,6 +61,7 @@ var GameObjects = (function() {
|
||||
*/
|
||||
var researchPrototype = {
|
||||
level: 0,
|
||||
interesting: false,
|
||||
is_visible: function() {
|
||||
return this.level > 0 || lab.data >= this.cost * .7;
|
||||
},
|
||||
@@ -70,7 +71,10 @@ var GameObjects = (function() {
|
||||
research: function() {
|
||||
if (lab.research(this.cost, this.reputation)) {
|
||||
this.level++;
|
||||
analytics.sendEvent(analytics.events.categoryResearch, analytics.events.actionResearch, this.name, this.level);
|
||||
if (this.info_levels.length > 0 && this.level === this.info_levels[0]) {
|
||||
this.interesting = true;
|
||||
this.info_levels.splice(0, 1);
|
||||
}
|
||||
var oldCost = this.cost;
|
||||
this.cost = Math.round(this.cost * this.cost_increase);
|
||||
return oldCost;
|
||||
@@ -81,11 +85,9 @@ var GameObjects = (function() {
|
||||
if (!this._info) {
|
||||
this._info = Helpers.loadFile(this.info);
|
||||
}
|
||||
this.interesting = false;
|
||||
return this._info;
|
||||
},
|
||||
showInfo: function() {
|
||||
UI.showModal(this.name, this.getInfo());
|
||||
}
|
||||
};
|
||||
var research = $.extend([], Helpers.loadFile('json/research.json'),
|
||||
ObjectStorage.load('research'));
|
||||
|
||||
@@ -21,13 +21,26 @@ var UI = (function () {
|
||||
});
|
||||
|
||||
/** Show a bootstrap modal with dynamic content. */
|
||||
var showModal = function(title, text) {
|
||||
var showModal = function(title, text, level) {
|
||||
var $modal = $('#infoBox');
|
||||
$modal.find('#infoBoxLabel').html(title);
|
||||
$modal.find('.modal-body').html(text);
|
||||
$modal.modal({show: true});
|
||||
};
|
||||
|
||||
/** Display only the elements with data-min-level above a certain
|
||||
* threshold.
|
||||
*/
|
||||
var showLevels = function(level) {
|
||||
$('#infoBox').find('[data-min-level]').each(function() {
|
||||
if (level >= $(this).data('min-level')) {
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var showUpdateValue = function(ident, num) {
|
||||
if (num != 0) {
|
||||
var formatted = Helpers.formatNumberPostfix(num);
|
||||
@@ -92,6 +105,7 @@ var UI = (function () {
|
||||
|
||||
return {
|
||||
showModal: showModal,
|
||||
showLevels: showLevels,
|
||||
showUpdateValue: showUpdateValue,
|
||||
validateVersion: validateVersion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user