2016-06-30 14:37:58 +00:00
|
|
|
var battle = require('battle')
|
2016-06-30 14:59:43 +00:00
|
|
|
var helpers = require('helpers');
|
2016-06-30 14:37:58 +00:00
|
|
|
|
|
|
|
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);
|
2016-06-30 14:37:58 +00:00
|
|
|
if(damagedStructure){
|
|
|
|
console.log("repairing", damagedStructure);
|
|
|
|
this.structure.repair(damagedStructure);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = structureTower;
|