Add quick repair stat
This commit is contained in:
parent
b2a52fd4f5
commit
8979e42150
13
src/main.ts
13
src/main.ts
@ -79,6 +79,15 @@ export const loop = ErrorMapper.wrapLoop(() => {
|
||||
const room = _.first(Object.values(Game.rooms));
|
||||
if (room) {
|
||||
console.log('Room', room.name, room.energyCapacityAvailable, room.energyAvailable);
|
||||
const roads = room.find(FIND_STRUCTURES, {
|
||||
filter: (s) => s.structureType === STRUCTURE_ROAD && s.hits < s.hitsMax
|
||||
});
|
||||
const minRoadHits = _.min(roads.map((r) => r.hits));
|
||||
const structures = room.find(FIND_STRUCTURES, {
|
||||
filter: (s) => s.structureType !== STRUCTURE_ROAD && s.hits < s.hitsMax
|
||||
});
|
||||
const minStructHits = _.min(structures.map((r) => r.hits));
|
||||
console.log('Repairs', 'roads', minRoadHits, 'structs', minStructHits);
|
||||
}
|
||||
|
||||
// Automatically delete memory of missing creeps
|
||||
@ -118,9 +127,7 @@ export const loop = ErrorMapper.wrapLoop(() => {
|
||||
});
|
||||
|
||||
function runTower(tower: StructureTower) {
|
||||
console.log('Tower', tower.id);
|
||||
const room = tower.room;
|
||||
|
||||
const hostile = room.find(FIND_HOSTILE_CREEPS);
|
||||
if (hostile.length > 0) {
|
||||
const res = tower.attack(_.first(hostile));
|
||||
@ -148,7 +155,6 @@ function runTower(tower: StructureTower) {
|
||||
if (roads.length > 0) {
|
||||
roads.sort((r1, r2) => r1.hits - r2.hits);
|
||||
let road = _.first(roads);
|
||||
console.log('Broken road', road.hits);
|
||||
const res = tower.repair(road);
|
||||
console.log('Repair', res);
|
||||
return;
|
||||
@ -160,7 +166,6 @@ function runTower(tower: StructureTower) {
|
||||
if (structures.length > 0) {
|
||||
structures.sort((r1, r2) => r1.hits - r2.hits);
|
||||
let structure = _.first(structures);
|
||||
console.log('Broken structure', structure.hits);
|
||||
const res = tower.repair(structure);
|
||||
console.log('Repair', res);
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user