Basic setup new system.
This commit is contained in:
28
Room.js
28
Room.js
@@ -1,17 +1,17 @@
|
||||
module.exports = {
|
||||
setup: function () { Room.prototype = _Room.prototype; }
|
||||
setup(){},
|
||||
|
||||
begin(room){
|
||||
if(!room.memory.jobs) room.memory.jobs = {
|
||||
harvesters: 1
|
||||
}
|
||||
},
|
||||
|
||||
tick(room){
|
||||
if(!(Game.time % 100)) calculateJobs(room);
|
||||
}
|
||||
}
|
||||
|
||||
class _Room extends Room {
|
||||
begin(){}
|
||||
|
||||
tick(){
|
||||
const creepsCount = this.find(FIND_MY_CREEPS).length;
|
||||
console.log(creepsCount);
|
||||
if(creepsCount < 5){
|
||||
const spawn = this.find(FIND_MY_STRUCTURES, {filter: {structureType: STRUCTURE_SPAWN}})[0];
|
||||
spawn.createHarvester();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function calculateJobs(room) {
|
||||
room.memory.jobs.harvesters = 10 - Object.keys(Game.creeps).length;
|
||||
}
|
||||
Reference in New Issue
Block a user