Basic setup new system.

This commit is contained in:
Douwe Ravers
2023-08-24 01:48:31 +02:00
parent ae3812aa83
commit ccd0557339
12 changed files with 147 additions and 242 deletions

28
Room.js
View File

@@ -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;
}