adding ability to pass roomnames or not as appropriate

This commit is contained in:
Dan Hamik 2022-05-11 08:40:08 -05:00
parent c0ec265a2d
commit 2a94fffaae
3 changed files with 67 additions and 23 deletions

View File

@ -39,58 +39,93 @@ module.exports = {
} }
return 'Spawning initiated' return 'Spawning initiated'
}, },
spawnnrworker: function(){ spawnnrworker: function(name){
if(name==null || name== undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) { for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name let name = myroom.name
require('proc.spawning').spawnnrworker(name) require('proc.spawning').spawnnrworker(name)
} }
} else {
require('proc.spawning').spawnnrworker(name)
}
return 'Spawning initiated' return 'Spawning initiated'
}, },
spawnworker: function(){ spawnworker: function(name){
if(name!=null && name!= undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) { for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name let name = myroom.name
require('proc.spawning').spawnworker(name) require('proc.spawning').spawnworker(name)
} }
} else {
require('proc.spawning').spawnworker(name)
}
return 'Spawning initiated' return 'Spawning initiated'
}, },
spawnminer: function(){ spawnminer: function(name){
if(name!=null && name!= undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) { for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name let name = myroom.name
require('proc.spawning').spawnsourceminer(name) require('proc.spawning').spawnsourceminer(name)
} }
} else {
require('proc.spawning').spawnsourceminer(name)
}
return 'Spawning initiated' return 'Spawning initiated'
}, },
spawnmover: function(){ spawnmover: function(name){
if(name!=null && name!= undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) { for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name let name = myroom.name
require('proc.spawning').spawnmover(name) require('proc.spawning').spawnmover(name)
} }
} else {
require('proc.spawning').spawnmover(name)
}
return 'Spawning initiated' return 'Spawning initiated'
}, },
spawnclaimer: function(){ spawnclaimer: function(name){
if(name!=null && name!= undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) { for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name let name = myroom.name
require('proc.spawning').spawnclaimer(name) require('proc.spawning').spawnclaimer(name)
} }
} else {
require('proc.spawning').spawnclaimer(name)
}
return 'Spawning initiated' return 'Spawning initiated'
}, },
removeConstruction: function(roomname){ removeConstruction: function(name){
_.invoke(Game.rooms[roomname].find(FIND_MY_CONSTRUCTION_SITES), 'remove') if(name==null || name== undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name
_.invoke(Game.rooms[name].find(FIND_MY_CONSTRUCTION_SITES), 'remove')
}
} else {
_.invoke(Game.rooms[name].find(FIND_MY_CONSTRUCTION_SITES), 'remove')
}
}, },
removeAllConstruction: function(){ removeAllConstruction: function(){
_.invoke(_.map(Game.constructionSites, (x)=>x), 'remove') _.invoke(_.map(Game.constructionSites, (x)=>x), 'remove')
}, },
removeWalls: function(roomname){ removeWalls: function(name){
Game.rooms[roomname].find(FIND_STRUCTURES, {filter: s => s.structureType === STRUCTURE_WALL}).forEach(s => s.destroy()) if(name==null || name== undefined){
for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name
Game.rooms[name].find(FIND_STRUCTURES, {filter: s => s.structureType === STRUCTURE_WALL}).forEach(s => s.destroy())
}
} else {
Game.rooms[name].find(FIND_STRUCTURES, {filter: s => s.structureType === STRUCTURE_WALL}).forEach(s => s.destroy())
}
}, },
removeRoads: function(roomname,hitsleft){ removeRoads: function(name,hitsleft){
Game.rooms[roomname].find(FIND_STRUCTURES, {filter: s => (s.structureType === STRUCTURE_ROAD && s.hits < hitsleft)}).forEach(s => s.destroy()) Game.rooms[name].find(FIND_STRUCTURES, {filter: s => (s.structureType === STRUCTURE_ROAD && s.hits < hitsleft)}).forEach(s => s.destroy())
return "done" return "done"
}, },
sellEnergy: function(roomname){ sellEnergy: function(name){
let myorders = Game.market.getAllOrders(order=>order.resourceType == RESOURCE_ENERGY && order.type == ORDER_SELL) let myorders = Game.market.getAllOrders(order=>order.resourceType == RESOURCE_ENERGY && order.type == ORDER_SELL)
}, },
computeSourceAccess: function(){ computeSourceAccess: function(){
for(let myroom of _.filter(Game.rooms, 'controller.my')) { for(let myroom of _.filter(Game.rooms, 'controller.my')) {
let name = myroom.name let name = myroom.name
let minablepositions = 0 let minablepositions = 0

5
proc.creepfunctions.js Normal file
View File

@ -0,0 +1,5 @@
module.exports = {
spawnwarrior: function(){
}
}

View File

@ -94,7 +94,11 @@ let buildparts = {
break; break;
} }
} }
if(tobuild != null && tobuild != undefined){
let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"phase" + Game.rooms[roomname].memory.phase +"worker"}) let newcreep = spawn.createCreep(tobuild,CreepName,{spawnedat: Game.time,role:"phase" + Game.rooms[roomname].memory.phase +"worker"})
} else {
console.log("not enough e in " + roomname + " to spawn")
}
}} }}
}, },