-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstructure.Spawner.js
52 lines (42 loc) · 1.77 KB
/
structure.Spawner.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
* Module code goes here. Use 'module.exports' to export things:
* module.exports.thing = 'a thing';
*
* You can import it from another modules like this:
* var mod = require('structure.Spawner');
* mod.thing == 'a thing'; // true
*/
var Spawner = {
run: function () {
var Spawnlimit_Miner = 3;
var Spawnlimit_Upgrader = 6;
if (_(Game.creeps).filter({ memory: { role: 'Miner',role: 'Transporter' }}).value().length-Spawnlimit_Miner <= (Spawnlimit_Miner)) {
var typ = Game.spawns['Spawn1'].memory.typ;
console.log(typ);
if (typ === 1) {
if( Game.spawns['Spawn1'].createCreep([WORK, MOVE, WORK], {
role: 'Miner',
source: null
})!== ERR_NOT_ENOUGH_ENERGY){
typ = 2;
Game.spawns['Spawn1'].memory.typ = typ;
}
return;
} else if (typ === 2) {
if(Game.spawns['Spawn1'].createCreep([MOVE, MOVE, CARRY],{role: 'Transporter',client: null})!== ERR_NOT_ENOUGH_ENERGY){
typ = 1;
Game.spawns['Spawn1'].memory.typ = typ;
}
}
}else if (_(Game.creeps).filter({ memory: { role: 'Upgrader' }}).value().length < Spawnlimit_Upgrader) {
Game.spawns['Spawn1'].createCreep([WORK, MOVE, CARRY], undefined, {
role: 'Upgrader',
transporter: null
});
if(_(Game.creeps).filter({ memory: { role: 'Transporter' }}).value().length < Spawnlimit_Upgrader){
Game.spawns['Spawn1'].createCreep([MOVE, MOVE, CARRY],{role: 'Transporter',client: null});
}
}
}
};
module.exports = Spawner;