mirror of
https://github.com/wassname/cardsforscience.git
synced 2026-09-11 12:00:40 +08:00
Progress. Basic game mechanics are working.
This commit is contained in:
+12
-6
@@ -1,7 +1,4 @@
|
||||
'use strict';
|
||||
|
||||
var DEBUG = true;
|
||||
|
||||
(function () {
|
||||
var loadJsonFile = function(filename) {
|
||||
var res;
|
||||
@@ -53,20 +50,28 @@ var DEBUG = true;
|
||||
var research = loadJsonFile('json/research.json');
|
||||
research.map(function (item) { // define additional stuff on the objects
|
||||
item.level = 0;
|
||||
item.is_visible = function () {
|
||||
return this.level > 0 || lab.data >= this.cost * .9;
|
||||
};
|
||||
item.is_available = function () {
|
||||
return this.level > 0 || lab.data > item.cost * .9;
|
||||
return lab.data >= this.cost;
|
||||
};
|
||||
item.research = function () {
|
||||
if (lab.research(this.cost, this.reputation)) {
|
||||
this.level++;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
if (DEBUG) console.log(research);
|
||||
|
||||
var workers = loadJsonFile('json/workers.json');
|
||||
workers.map(function (worker) {
|
||||
worker.hired = 0;
|
||||
worker.is_visible = function () {
|
||||
return this.hired > 0 || lab.money >= this.cost * .9;
|
||||
};
|
||||
worker.is_available = function () {
|
||||
return lab.money >= this.cost;
|
||||
};
|
||||
worker.hire = function() {
|
||||
if (lab.buy(this.cost)) {
|
||||
this.hired++;
|
||||
@@ -74,6 +79,7 @@ var DEBUG = true;
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
var app = angular.module('particleClicker', []);
|
||||
|
||||
app.controller('DetectorController', function () {
|
||||
|
||||
Reference in New Issue
Block a user