Improved upgrade system. Needs content!

This commit is contained in:
Kevin Dungs
2014-08-11 16:03:59 +02:00
parent 8b007637a3
commit 18de4cd070
5 changed files with 85 additions and 595 deletions
+11 -8
View File
@@ -83,7 +83,7 @@
<div class="container-fluid">
<div class="col-xs-3 scrollable" id="Research" ng-controller="ResearchController as rc">
<h3><span class="glyphicon glyphicon-cog"></span> Research</h3>
<h3><i class="fa fa-cogs"></i> Research</h3>
<hr>
<ul class="media-list" ng-cloak>
<li class="media" ng-repeat="r in rc.research" ng-show="r.is_visible()">
@@ -91,7 +91,8 @@
<img ng-hide="r.level > 0" class="pull-left" class="media-object" src="assets/icons/png/unknown.png" alt="">
<div class="media-body">
<h4 class="media-heading">{{ r.level > 0 ? r.name : '?????' }} <span ng-show="r.level > 0" class="badge">Level {{ r.level }}</span></h4>
<p ng-show="r.level > 0">{{ r.description }} Researching it will give you {{ r.reputation | niceNumber }} reputation.</p>
<p ng-show="r.level > 0">{{ r.description }}</p>
<p ng-show="r.level > 0" class="small">Research yields <strong>{{ r.reputation | niceNumber }}</strong> reputation.</p>
<div class="btn-group">
<button class="btn btn-primary" ng-disabled="!r.is_available()" ng-click="rc.doResearch(r)">Research <small>({{ r.cost | niceNumber }} data)</small></button>
<button class="btn btn-info" ng-show="r.level > 0" ng-click="r.showInfo()"><span class="glyphicon glyphicon-exclamation-sign"></span></button>
@@ -136,13 +137,14 @@
</div>
<div class="col-xs-2 scrollable" id="HR" ng-controller="HRController as hrc">
<h3><span class="glyphicon glyphicon-user"></span> HR</h3>
<h3><i class="fa fa-users"></i> HR</h3>
<hr>
<ul class="media-list" ng-cloak>
<li class="media" ng-repeat="w in hrc.workers" ng-show="w.is_visible()">
<div class="media-body">
<h4 class="media-heading">{{ w.name }} <span ng-show="w.hired > 0" class="badge">{{ w.hired | niceNumber }}</span></h4>
<p ng-show="w.hired > 0">{{ w.description }} They produce {{ w.rate | niceNumber }} data per second.</p>
<p ng-show="w.hired > 0">{{ w.description }}</p>
<p ng-show="w.hired > 0" class="small">Produce <strong>{{ w.rate | niceNumber }}</strong> data per second.</p>
<button class="btn btn-primary" ng-disabled="!w.is_available()" ng-click="hrc.hire(w)">Hire <small>({{ w.cost | currency }})</small></button>
</div>
</li>
@@ -150,14 +152,15 @@
</div>
<div class="col-xs-2 scrollable" id="Upgrades" ng-controller="UpgradesController as uc">
<h3><span class="glyphicon glyphicon-wrench"></span> Upgrades</h3>
<h3><i class="fa fa-wrench"></i> Upgrades</h3>
<hr>
<ul class="media-list" ng-cloak>
<li class="media" ng-repeat="u in uc.upgrades" ng-show="u.is_visible()">
<li class="media" ng-repeat="u in uc.upgrades" ng-show="u.isVisible()">
<div class="media-body">
<h4 class="media-heading">{{ u.name }}</h4>
<h4 class="media-heading">{{ u.name }} <i class="fa {{ u.icon }}" class="media-object"></i></h4>
<p>{{ u.description }}</p>
<button class="btn btn-primary" ng-disabled="!u.is_available()" ng-click="uc.upgrade(u)">Buy <small>({{ u.cost | currency }})</small></button>
<p class="small">{{ u.effect }}</p>
<button class="btn btn-primary" ng-disabled="!u.isAvailable()" ng-click="uc.upgrade(u)">Buy <small>({{ u.cost | currency }})</small></button>
</div>
</li>
</ul>
+1
View File
@@ -94,6 +94,7 @@
this.upgrade = function(upgrade) {
if (upgrade.buy()) {
achievements.update('count', 'moneyUpgrades', upgrade.cost);
UI.showUpdateValue("#update-funding", upgrade.cost);
}
}
});
+36 -37
View File
@@ -5,6 +5,14 @@
* found in the localStorage.
*/
var GameObjects = (function() {
var allObjects = {
push: function(key_property, list) {
for (var i = 0; i < list.length; i++) {
this[list[i][key_property]] = list[i];
}
}
};
/** Lab
*/
var labPrototype = {
@@ -47,6 +55,7 @@ var GameObjects = (function() {
}
};
var lab = $.extend({}, labPrototype, ObjectStorage.load('lab'));
allObjects['lab'] = lab;
/** Research
*/
@@ -83,6 +92,7 @@ var GameObjects = (function() {
research = research.map(function(item) {
return $.extend({}, researchPrototype, item);
});
allObjects.push('name', research);
/** Workers
@@ -111,58 +121,46 @@ var GameObjects = (function() {
workers = workers.map(function(worker) {
return $.extend({}, workersPrototype, worker);
});
allObjects.push('name', workers);
/** Upgrades
*/
var upgradesPrototype = {
getReceiver: function() {
if (this.type === "detector") {
return lab.detector;
} else if (this.type === "reputation"){
return lab.factor;
} else {
var context;
if (this.type === "research") { context = research; }
else if (this.type === "hr") { context = workers; }
else { return null; }
for (var i = 0; i < context.length; i++) {
if (context[i].name === this.receiver) {
return context[i];
}
_visible: false,
_used: false,
meetsRequirements: function() {
for (var i = 0; i < this.requirements.length; i++) {
var req = this.requirements[i];
if (allObjects[req.key][req.property] < req.threshold) {
return false;
}
return null;
}
return true;
},
hasReceiver: function() {
if (this.type === "detector" || this.type === "reputation") {
isAvailable: function() {
if (!this._used && lab.money >= this.cost && this.meetsRequirements()) {
return true;
}
var rec = this.getReceiver();
if (this.type === "research") {
return rec.level > 0;
} else if (this.type === "hr") {
return rec.hired > 0;
}
return false;
},
is_visible: function() {
return !this.used && this.hasReceiver() && lab.money >= this.cost * .7;
},
is_available: function() {
return !this.used && this.hasReceiver() && lab.money >= this.cost;
isVisible: function() {
if (!this._used && (this._visible || lab.money >= this.cost * .7 && this.meetsRequirements())) {
this._visible = true;
return true;
}
return false;
},
buy: function() {
if (!this.used && lab.buy(this.cost)) {
this.used = true;
analytics.sendEvent(analytics.events.categoryUpgrades, analytics.events.actionBuy, this.name, 1);
var rec = this.getReceiver();
if (rec) {
rec[this.property] = rec[this.property] * this.factor + this.constant;
if (!this._used && lab.buy(this.cost)) {
for (var i = 0; i < this.targets.length; i++) {
var t = this.targets[i];
allObjects[t.key][t.property] *= this.factor || 1;
allObjects[t.key][t.property] += this.constant || 0;
}
return true;
this._used = true;
this._visible = false;
}
return false;
}
};
var upgrades = $.extend([], Helpers.loadFile('json/upgrades.json'),
@@ -170,6 +168,7 @@ var GameObjects = (function() {
upgrades = upgrades.map(function(upgrade) {
return $.extend({}, upgradesPrototype, upgrade);
});
allObjects.push('name', upgrades);
/** Save all the game objects at once.
@@ -187,6 +186,6 @@ var GameObjects = (function() {
research: research,
workers: workers,
upgrades: upgrades,
saveAll: saveAll
saveAll: saveAll,
}
})();
+29 -545
View File
@@ -1,556 +1,40 @@
[
{
"name": "Free beer",
"description": "The work is easier when the worker is happy. Your PhD Students will produce +2 data.",
"cost": 1000,
"used": false,
"type": "hr",
"receiver": "PhD Students",
"property": "rate",
"factor": 1,
"constant": 2
},
{
"name": "Extra coffee",
"description": "Sleeping is the coffee of the weak. Your PhD Students will produce 1.3 times more data.",
"cost": 3000,
"used": false,
"type": "hr",
"receiver": "PhD Students",
"property": "rate",
"factor": 1.5,
"constant": 0
},
{
"name": "Motivation",
"description": "There are other, you know... more diligent Students... Your PhD Students will produce 2 times more data.",
"cost": 10000,
"used": false,
"type": "hr",
"receiver": "PhD Students",
"property": "rate",
"name": "Thesis supervision",
"description": "Somebody takes care of your PhD Students.",
"effect": "PhD Students produce twice as much data per second.",
"icon": "fa-group",
"cost": 100,
"targets": [{"key": "PhD Students", "property": "rate"}],
"requirements": [{"key": "PhD Students", "property": "hired", "threshold": 1}],
"factor": 2,
"constant": 0
},
{
"name": "Division of labor",
"description": "Teamwork between PhD Students is a great invention. Your PhD Students will produce much more data.",
"cost": 175000,
"used": false,
"type": "hr",
"receiver": "PhD Students",
"property": "rate",
"factor": 3,
"constant": 3
},
{
"name": "Free beer",
"description": "The work is easier when the worker is happy. Your Postdocs will produce +4 data.",
"cost": 5000,
"used": false,
"type": "hr",
"receiver": "Postdocs",
"property": "rate",
"factor": 1,
"constant": 4
},
{
"name": "Extra coffee",
"description": "Sleeping is the coffee of the weak. Your Postdocs will produce 1.5 times more data.",
"cost": 20000,
"used": false,
"type": "hr",
"receiver": "Postdocs",
"property": "rate",
"factor": 1.5,
"constant": 0
},
{
"name": "Motivation",
"description": "There are other, you know... more diligent Postdocs... Your Postdocs will produce 2 times more data.",
"cost": 500000,
"used": false,
"type": "hr",
"receiver": "Postdocs",
"property": "rate",
"factor": 2,
"constant": 0
},
{
"name": "Division of labor",
"description": "Teamwork between Postdocs is a great invention. Your Postdocs will produce much more data.",
"cost": 2000000,
"used": false,
"type": "hr",
"receiver": "Postdocs",
"property": "rate",
"factor": 1.5,
"constant": 18
},
{
"name": "Increased budget",
"description": "Your Research Fellows get a little more money. They will produce +25 more data.",
"cost": 200000,
"used": false,
"type": "hr",
"receiver": "Research Fellows",
"property": "rate",
"factor": 1,
"constant": 25
},
{
"name": "New gadgets",
"description": "Your Research Fellows receive new techs. They will produce 1.2 times more data.",
"cost": 800000,
"used": false,
"type": "hr",
"receiver": "Research Fellows",
"property": "rate",
"factor": 1.2,
"constant": 0
},
{
"name": "More PhD Students",
"description": "Your Mighty Professors get some Students to work. They will produce +75 more data.",
"cost": 20000000,
"used": false,
"type": "hr",
"receiver": "Tenured Professors",
"property": "rate",
"factor": 1,
"constant": 75
},
{
"name": "2. Nobel Prize",
"description": "So your Brightest Minds are now demigods... They will produce 1.7 times more data.",
"cost": 100000000,
"used": false,
"type": "hr",
"receiver": "Nobel Prize Winners",
"property": "rate",
"factor": 1.7,
"constant": 0
},
{
"name": "Accelerator upgrade",
"description": "Increases the luminosity (you get 3 times more data with clicks).",
"cost": 1000,
"used": false,
"type": "detector",
"receiver": "",
"property": "rate",
"factor": 3,
"constant": 0
},
{
"name": "Accelerator upgrade 2",
"description": "Increases the luminosity (you get 3 times more data with clicks).",
"name": "Own desk",
"description": "Not having to share one is a blessing.",
"effect": "PhD Students produce twice as much data per second.",
"icon": "fa-group",
"cost": 10000,
"used": false,
"type": "detector",
"receiver": "",
"property": "rate",
"factor": 3,
"constant": 0
},
{
"name": "Accelerator upgrade 3",
"description": "Increases the luminosity (you get 3 times more data with clicks).",
"cost": 100000,
"used": false,
"type": "detector",
"receiver": "",
"property": "rate",
"factor": 3,
"constant": 0
},
{
"name": "Detector upgrade",
"description": "Your amazing detector works with better efficiency (you get +4 data with clicks).",
"cost": 500,
"used": false,
"type": "detector",
"receiver": "detector",
"property": "rate",
"factor": 1,
"constant": 4
},
{
"name": "Detector upgrade 2",
"description": "Your amazing detector works with better efficiency (you get +12 data with clicks).",
"cost": 5000,
"used": false,
"type": "detector",
"receiver": "",
"property": "rate",
"factor": 1,
"constant": 12
},
{
"name": "Detector upgrade 3",
"description": "Your amazing detector works with better efficiency (you get +42 data with clicks).",
"cost": 50000,
"used": false,
"type": "detector",
"receiver": "detector",
"property": "rate",
"factor": 1,
"constant": 42
},
{
"name": "Public Relations, lvl 1",
"description": "Mainstream press writes about your research of the CP violation. Future research yields 1.2 times more reputation.",
"cost": 5000,
"used": false,
"type": "research",
"receiver": "CP violation",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Science is cool!! lvl 1",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 700,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.2,
"constant": 0
},
{
"name": "Science is cool!! lvl 2",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 50000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.18,
"constant": 0
},
{
"name": "Science is cool!! lvl 3",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 200000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.16,
"constant": 0
},
{
"name": "Science is cool!! lvl 4",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 800000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.14,
"constant": 0
},
{
"name": "Science is cool!! lvl 5",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 1200000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.12,
"constant": 0
},
{
"name": "Science is cool!! lvl 6",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 1800000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.12,
"constant": 0
},
{
"name": "Science is cool!! lvl 7",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 3000000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.12,
"constant": 0
},
{
"name": "Science is cool!! lvl 8",
"description": "Because your science is so popular, you get 1.1 times more money for your reputation.",
"cost": 10000000,
"used": false,
"type": "reputation",
"receiver": "",
"property": "rate",
"factor": 1.12,
"constant": 0
},
{
"name": "Public Relations, lvl 1",
"description": "Mainstream press writes about your research of the CP violation. Future research yields 1.2 times more reputation.",
"cost": 5000,
"used": false,
"type": "research",
"receiver": "CP violation",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "Mainstream press writes about your research of the CP violation. Future research yields 1.2 times more reputation.",
"cost": 100000,
"used": false,
"type": "research",
"receiver": "CP violation",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "Your research on J/ψ is featured on national television. Future research yields 1.2 times more reputation.",
"cost": 40000,
"used": false,
"type": "research",
"receiver": "J/ψ",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "Your research on J/ψ is featured on national television. Future research yields 1.2 times more reputation.",
"cost": 130000,
"used": false,
"type": "research",
"receiver": "J/ψ",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "In a scientific documentary you speak about the τ lepton. Future research yields 1.2 times more reputation.",
"cost": 100000,
"used": false,
"type": "research",
"receiver": "τ lepton",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "In a scientific documentary you speak about the τ lepton. Future research yields 1.2 times more reputation.",
"cost": 250000,
"used": false,
"type": "research",
"receiver": "τ lepton",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "You just discovered the most beautiful quark ever! Future research yields 1.2 times more reputation.",
"cost": 100000,
"used": false,
"type": "research",
"receiver": "Beauty quark",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "You discovered the most beautiful quark ever! Future research yields 1.2 times more reputation.",
"cost": 500000,
"used": false,
"type": "research",
"receiver": "Beauty quark",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "You give lectures about this very important part of the Standard Model! Future research yields 1.2 times more reputation.",
"cost": 250000,
"used": false,
"type": "research",
"receiver": "W and Z boson",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "You give lectures about this very important part of the Standard Model! Future research yields 1.2 times more reputation.",
"cost": 1000000,
"used": false,
"type": "research",
"receiver": "W and Z boson",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "This is the top of your career! Future research yields 1.2 times more reputation.",
"cost": 5000000,
"used": false,
"type": "research",
"receiver": "Top quark",
"property": "reputation",
"factor": 1.2,
"constant": 1
"targets": [{"key": "PhD Students", "property": "rate"}],
"requirements": [{"key": "Thesis supervision", "property": "_used", "threshold": 1}],
"factor": 2
},
{
"name": "Public Relations, lvl 2",
"description": "This is the top of your career! Future research yields 1.2 times more reputation.",
"cost": 7500000,
"used": false,
"type": "research",
"receiver": "Top quark",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "Hollywood makes a movie about the antihydrogen. Your future research yields 1.2 times more reputation.",
"cost": 22500000,
"used": false,
"type": "research",
"receiver": "Antihydrogen",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "Hollywood makes a movie about the antihydrogen. Your future research yields 1.2 times more reputation.",
"cost": 40000000,
"used": false,
"type": "research",
"receiver": "Antihydrogen",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "Your little daughter writes about your research on B oscillations in her homework. Future research yields 1.2 times more reputation.",
"cost": 75000000,
"used": false,
"type": "research",
"receiver": "B oscillations",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "Your little daughter writes about your research on B oscillations in her homework. Future research yields 1.2 times more reputation.",
"cost": 90000000,
"used": false,
"type": "research",
"receiver": "B oscillations",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "You know more about Top quark than everybody else. Future research yields 1.2 times more reputation.",
"cost": 50000000,
"used": false,
"type": "research",
"receiver": "Top quark",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "You know more about Top quark then everybody else. Future research yields 1.2 times more reputation.",
"cost": 120000000,
"used": false,
"type": "research",
"receiver": "Top quark",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 1",
"description": "You've found the last missing element of the Standard Model! Future research yields 1.2 times more reputation.",
"cost": 90000000,
"used": false,
"type": "research",
"receiver": "Higgs boson",
"property": "reputation",
"factor": 1.2,
"constant": 1
},
{
"name": "Public Relations, lvl 2",
"description": "You've found the last missing element of the Standard Model! Future research yields 1.2 times more reputation.",
"cost": 110000000,
"used": false,
"type": "research",
"receiver": "Higgs boson",
"property": "reputation",
"factor": 1.2,
"constant": 1
"name": "Free coffee",
"description": "Addictively delicious. Also free.",
"effect": "All workers produce twice as much data per second.",
"icon": "fa-group",
"cost": 1e6,
"targets": [
{"key": "PhD Students", "property": "rate"},
{"key": "Postdocs", "property": "rate"},
{"key": "Research Fellows", "property": "rate"},
{"key": "Tenured Professors", "property": "rate"},
{"key": "Nobel Prize Winners", "property": "rate"},
{"key": "Summer Students", "property": "rate"}
],
"requirements": [],
"factor": 2
}
]
+8 -5
View File
@@ -54,7 +54,8 @@
<img ng-hide="r.level > 0" class="pull-left" class="media-object" src="assets/icons/png/unknown.png" alt="">
<div class="media-body">
<h4 class="media-heading">{{ r.level > 0 ? r.name : '?????' }} <span ng-show="r.level > 0" class="badge">Level {{ r.level }}</span></h4>
<p ng-show="r.level > 0">{{ r.description }} Researching it will give you {{ r.reputation | niceNumber }} reputation.</p>
<p ng-show="r.level > 0">{{ r.description }}</p>
<p ng-show="r.level > 0">Research yields {{ r.reputation | niceNumber }} reputation.</p>
<div class="btn-group">
<button class="btn btn-primary" ng-disabled="!r.is_available()" ng-click="rc.doResearch(r)">Research <small>({{ r.cost | niceNumber }} data)</small></button>
<button class="btn btn-info" ng-show="r.level > 0" ng-click="r.showInfo()"><span class="glyphicon glyphicon-exclamation-sign"></span></button>
@@ -69,7 +70,8 @@
<li class="media" ng-repeat="w in hrc.workers" ng-show="w.is_visible()">
<div class="media-body">
<h4 class="media-heading">{{ w.name }} <span ng-show="w.hired > 0" class="badge">{{ w.hired | niceNumber }}</span></h4>
<p ng-show="w.hired > 0">{{ w.description }} They produce {{ w.rate | niceNumber }} data per second.</p>
<p ng-show="w.hired > 0">{{ w.description }}</p>
<p ng-show="w.hired > 0" class="small">Produce {{ w.rate | niceNumber }} data per second.</p>
<button class="btn btn-primary" ng-disabled="!w.is_available()" ng-click="hrc.hire(w)">Hire <small>({{ w.cost | currency }})</small></button>
</div>
</li>
@@ -78,11 +80,12 @@
<!-- Upgrades -->
<div class="tab-pane" id="upgrades" ng-controller="UpgradesController as uc">
<ul class="media-list" ng-cloak>
<li class="media" ng-repeat="u in uc.upgrades" ng-show="u.is_visible()">
<li class="media" ng-repeat="u in uc.upgrades" ng-show="u.isVisible()">
<div class="media-body">
<h4 class="media-heading">{{ u.name }}</h4>
<h4 class="media-heading">{{ u.name }} <i class="fa {{ u.icon }}"></i></h4>
<p>{{ u.description }}</p>
<button class="btn btn-primary" ng-disabled="!u.is_available()" ng-click="uc.upgrade(u)">Buy <small>({{ u.cost | currency }})</small></button>
<p class="small">{{ u.effect }}</p>
<button class="btn btn-primary" ng-disabled="!u.isAvailable()" ng-click="uc.upgrade(u)">Buy <small>({{ u.cost | currency }})</small></button>
</div>
</li>
</ul>