diff --git a/src/Overseer.ts b/src/Overseer.ts index 68664c3b3..963c8a7e8 100644 --- a/src/Overseer.ts +++ b/src/Overseer.ts @@ -31,7 +31,14 @@ import { ROOMTYPE_SOURCEKEEPER } from './utilities/Cartographer'; import {p} from './utilities/random'; -import {canClaimAnotherRoom, getAllRooms, hasJustSpawned, minBy, onPublicServer} from './utilities/utils'; +import { + canClaimAnotherRoom, + getAllRooms, + hasJustSpawned, + isRoomAvailable, + minBy, + onPublicServer +} from './utilities/utils'; import {MUON, MY_USERNAME, USE_TRY_CATCH} from './~settings'; @@ -378,7 +385,7 @@ export class Overseer implements IOverseer { } const neighboringRooms = _.values(Game.map.describeExits(roomName)) as string[]; const isReachableFromColony = _.any(neighboringRooms, r => colony.roomNames.includes(r)); - return isReachableFromColony && Game.map.isRoomAvailable(roomName); + return isReachableFromColony && isRoomAvailable(roomName); }); } diff --git a/src/overlords/defense/npcDefense.ts b/src/overlords/defense/npcDefense.ts index 6f65c0061..a5dcda78c 100644 --- a/src/overlords/defense/npcDefense.ts +++ b/src/overlords/defense/npcDefense.ts @@ -78,7 +78,7 @@ export class DefenseNPCOverlord extends Overlord { } init() { - const amount = this.room && (this.room.invaders.length > 0 || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0; + const amount = this.room && (this.room.invaders.length > 0 || this.room.invaderCore || RoomIntel.isInvasionLikely(this.room)) ? 1 : 0; this.wishlist(amount, CombatSetups.broodlings.default, {reassignIdle: true}); } diff --git a/src/overlords/mining/miner.ts b/src/overlords/mining/miner.ts index b384991a9..ed865112c 100644 --- a/src/overlords/mining/miner.ts +++ b/src/overlords/mining/miner.ts @@ -570,7 +570,7 @@ export class MiningOverlord extends Overlord { break; case ERR_NOT_OWNER: if (Game.time % 20 == 0) { - log.alert(`${miner.print}: room is reserved by hostiles!`); + log.alert(`${miner.print}: room "${miner.room.name}" is reserved by hostiles!`); } break; default: diff --git a/src/overlords/scouting/randomWalker.ts b/src/overlords/scouting/randomWalker.ts index 367255489..05daf6efa 100644 --- a/src/overlords/scouting/randomWalker.ts +++ b/src/overlords/scouting/randomWalker.ts @@ -3,6 +3,7 @@ import {Roles, Setups} from '../../creepSetups/setups'; import {OverlordPriority} from '../../priorities/priorities_overlords'; import {profile} from '../../profiler/decorator'; import {Tasks} from '../../tasks/Tasks'; +import {isRoomAvailable} from '../../utilities/utils'; import {Zerg} from '../../zerg/Zerg'; import {Overlord} from '../Overlord'; @@ -40,7 +41,7 @@ export class RandomWalkerScoutOverlord extends Overlord { // Pick a new room const neighboringRooms = _.values(Game.map.describeExits(scout.pos.roomName)) as string[]; const roomName = _.sample(neighboringRooms); - if (Game.map.isRoomAvailable(roomName)) { + if (isRoomAvailable(roomName)) { scout.task = Tasks.goToRoom(roomName); } } diff --git a/src/roomPlanner/RoadPlanner.ts b/src/roomPlanner/RoadPlanner.ts index d8dc5a6a4..7ab2104fc 100644 --- a/src/roomPlanner/RoadPlanner.ts +++ b/src/roomPlanner/RoadPlanner.ts @@ -398,14 +398,14 @@ export class RoadPlanner { /* Clean up leftover road coverage locations from remotes that aren't mined or old structures */ private cleanRoadCoverage() { const colonyDestinations = this.colony.destinations.map(dest => `${dest.pos.roomName}:${dest.pos.x}:${dest.pos.y}`); - console.log(`Colony ${this.colony.print} has destinations of ${JSON.stringify(colonyDestinations)}`); + log.debug(`Colony ${this.colony.print} has destinations of ${JSON.stringify(colonyDestinations)}`); for (const roadCoverageKey of Object.keys(this.memory.roadCoverages)) { // console.log(`Colony ${this.colony.name} Road coverage of ${roadCoverageKey}`); if (colonyDestinations.includes(roadCoverageKey)) { // console.log(`Colony has destination of ${roadCoverageKey}`); } else { - console.log(`Colony does not have destination of ${roadCoverageKey}, deleting.`); + log.warning(`Colony does not have destination of ${roadCoverageKey}, deleting.`); delete this.memory.roadCoverages[roadCoverageKey]; } } diff --git a/src/strategy/ExpansionPlanner.ts b/src/strategy/ExpansionPlanner.ts index 2b0ea4cc4..9fb8b8886 100644 --- a/src/strategy/ExpansionPlanner.ts +++ b/src/strategy/ExpansionPlanner.ts @@ -6,7 +6,7 @@ import {Autonomy, getAutonomyLevel, Mem} from '../memory/Memory'; import {Pathing} from '../movement/Pathing'; import {profile} from '../profiler/decorator'; import {Cartographer} from '../utilities/Cartographer'; -import {maxBy} from '../utilities/utils'; +import {isRoomAvailable, maxBy} from '../utilities/utils'; import {MAX_OWNED_ROOMS, SHARD3_MAX_OWNED_ROOMS} from '../~settings'; import {MIN_EXPANSION_DISTANCE} from './ExpansionEvaluator'; @@ -123,7 +123,7 @@ export class ExpansionPlanner implements IExpansionPlanner { } } // Update best choices - if (score > bestScore && Game.map.isRoomAvailable(roomName)) { + if (score > bestScore && isRoomAvailable(roomName)) { bestScore = score; bestRoom = roomName; } diff --git a/src/utilities/utils.ts b/src/utilities/utils.ts index 241913c3a..f8a2643e8 100644 --- a/src/utilities/utils.ts +++ b/src/utilities/utils.ts @@ -352,3 +352,10 @@ export function rotatedMatrix(matrix: T[][], clockwiseTurns: 0 | 1 | 2 | 3): export function cyclicListPermutation(list: T[], offset: number): T[] { return list.slice(offset).concat(list.slice(0, offset)); } + +export function isRoomAvailable(roomName: string) { + const roomStatus = Game.map.getRoomStatus(roomName); + const expiration = roomStatus.timestamp; + // TODO: cache result and only recheck after expiration + return roomStatus.status === 'normal'; +}