screeps/structure.tower.js

24 lines
710 B
JavaScript
Raw Normal View History

var battle = require('battle')
2016-06-30 14:59:43 +00:00
var helpers = require('helpers');
var structureTower= {
run: function(structure){
this.structure = structure;
console.log(structure, 'running Tower')
var target = battle.findEnemy(this.structure);
if(target != structure.room.controller) {
console.log('\t', this.structure, 'attacking:',target)
this.structure.attack(target);
} else {
2016-06-30 14:59:43 +00:00
var damagedStructure = helpers.findDamagedStructure(this.structure);
if(damagedStructure){
console.log("repairing", damagedStructure);
this.structure.repair(damagedStructure);
}
}
}
}
module.exports = structureTower;