2016-09-28 08:37:28 -05:00
|
|
|
let buildparts = {
|
|
|
|
tick: function(roomname,role) {
|
2017-06-06 13:17:26 -05:00
|
|
|
Game.rooms[roomname].memory.tickssincespawn=0
|
2016-09-28 08:37:28 -05:00
|
|
|
let tobuild=[]
|
2017-06-06 13:17:26 -05:00
|
|
|
let myspawns=Game.rooms[roomname].find(FIND_MY_SPAWNS)
|
|
|
|
Game.rooms[roomname].memory.CreepNum++
|
|
|
|
let CreepName = role + "_" + roomname + "_" + (Game.rooms[roomname].memory.CreepNum)
|
2016-09-28 08:37:28 -05:00
|
|
|
switch(role){
|
|
|
|
case 'builder':
|
2017-06-06 13:17:26 -05:00
|
|
|
|
2016-09-28 08:37:28 -05:00
|
|
|
for(let spawn of myspawns){
|
2017-06-06 13:17:26 -05:00
|
|
|
if(!spawn.spawning){
|
2016-09-28 08:37:28 -05:00
|
|
|
for(let totry of [
|
2020-11-09 19:31:39 -06:00
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY],
|
|
|
|
[MOVE,WORK,CARRY,CARRY]
|
2017-06-06 13:17:26 -05:00
|
|
|
|
|
|
|
]){
|
2016-09-28 08:37:28 -05:00
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
2017-06-06 13:17:26 -05:00
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'nrbuilder':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
2020-11-09 19:31:39 -06:00
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY],
|
2017-06-06 13:17:26 -05:00
|
|
|
[MOVE,WORK,CARRY]
|
|
|
|
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}
|
2016-09-28 08:37:28 -05:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'hauler':
|
2017-06-06 13:17:26 -05:00
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
2020-11-09 19:31:39 -06:00
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE]
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE],
|
2017-06-06 13:17:26 -05:00
|
|
|
[CARRY,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'hauler3':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
|
|
|
[CARRY,CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE,MOVE],
|
|
|
|
[CARRY,CARRY,CARRY,CARRY,CARRY,MOVE,MOVE,MOVE],
|
|
|
|
[CARRY,CARRY,CARRY,CARRY,MOVE,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,MOVE],
|
|
|
|
[CARRY,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 'miner':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,MOVE],
|
|
|
|
[WORK,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'miner2':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,WORK,MOVE,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,MOVE],
|
|
|
|
[WORK,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'nrminer':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
|
|
|
[WORK,WORK,WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,WORK,MOVE],
|
|
|
|
[WORK,WORK,MOVE],
|
|
|
|
[WORK,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'hauler2':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
2020-11-09 19:31:39 -06:00
|
|
|
for(let totry of [
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE]
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE,CARRY,CARRY,MOVE],
|
|
|
|
[CARRY,CARRY,MOVE],
|
2017-06-06 13:17:26 -05:00
|
|
|
[CARRY,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'towerrecharger':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [[CARRY,CARRY,CARRY,MOVE,MOVE]]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'repairbot':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
2020-11-09 19:31:39 -06:00
|
|
|
[WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE]//RCL3
|
|
|
|
[WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE],
|
|
|
|
[WORK,CARRY,MOVE,WORK,CARRY,MOVE],
|
2017-06-06 13:17:26 -05:00
|
|
|
[WORK,CARRY,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'upgrader':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
2017-07-13 23:24:42 -05:00
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL8
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL7
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL6
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL5
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL4
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL3
|
|
|
|
[MOVE,WORK,CARRY,MOVE,WORK,CARRY],//RCL2
|
|
|
|
[MOVE,WORK,CARRY]//RCL1
|
2017-06-06 13:17:26 -05:00
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'warrior':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
|
|
|
[ATTACK,ATTACK,RANGED_ATTACK,RANGED_ATTACK,MOVE,MOVE],
|
|
|
|
[ATTACK,ATTACK,RANGED_ATTACK,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
|
|
|
case 'claimer':
|
|
|
|
|
|
|
|
for(let spawn of myspawns){
|
|
|
|
if(!spawn.spawning){
|
|
|
|
for(let totry of [
|
|
|
|
[CLAIM,CLAIM,CLAIM,CLAIM,CLAIM,MOVE,MOVE],
|
|
|
|
[CLAIM,MOVE]
|
|
|
|
]){
|
|
|
|
let ispossible = spawn.canCreateCreep(totry)
|
|
|
|
if(ispossible==OK){
|
|
|
|
tobuild=totry
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(tobuild)
|
|
|
|
let newcreep = spawn.createCreep(tobuild,CreepName,{role:role})
|
|
|
|
console.log('Spawning new ' + role + ': ' + newcreep );
|
|
|
|
}}
|
|
|
|
break;
|
2016-09-28 08:37:28 -05:00
|
|
|
default:
|
2017-06-06 13:17:26 -05:00
|
|
|
console.log('no match')
|
2016-09-28 08:37:28 -05:00
|
|
|
}
|
2017-06-06 13:17:26 -05:00
|
|
|
|
2016-09-28 08:37:28 -05:00
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
module.exports = buildparts;
|