diff --git a/src/extends/room/intel.js b/src/extends/room/intel.js index 2514c8c..d1bc612 100644 --- a/src/extends/room/intel.js +++ b/src/extends/room/intel.js @@ -239,7 +239,7 @@ Room.requestIntel = function (roomname) { Game.rooms[roomname].saveIntel() return } - if (!Game.map.isRoomAvailable(roomname)) { + if (!qlib.map.isRoomAvailableForCreeps(roomname)) { return } if (!qlib.map.reachableFromEmpire(roomname, 'manhattan')) { @@ -279,7 +279,7 @@ Room.getScoutTarget = function (creep) { let testRoom for (testRoom of targetRooms) { // Filter out invalid rooms - if (!Game.map.isRoomAvailable(testRoom)) { + if (!qlib.map.isRoomAvailableForCreeps(testRoom)) { continue } @@ -311,7 +311,7 @@ Room.getScoutTarget = function (creep) { let oldest = 0 let testRoom for (testRoom of adjacent) { - if (!Game.map.isRoomAvailable(testRoom)) { + if (Game.map.getRoomStatus(testRoom) !== 'closed') { continue } const roominfo = Room.getIntel(testRoom) diff --git a/src/extends/room/meta.js b/src/extends/room/meta.js index b1c93f6..85069a1 100644 --- a/src/extends/room/meta.js +++ b/src/extends/room/meta.js @@ -164,7 +164,7 @@ Room.isHallway = function (name) { } Room.isClaimable = function (name) { - if (!Game.map.isRoomAvailable(name)) { + if (!qlib.map.isRoomAvailableForCreeps(name)) { return false } const coords = Room.getCoordinates(name) diff --git a/src/lib/map.js b/src/lib/map.js index 0f34977..9ed9bc4 100644 --- a/src/lib/map.js +++ b/src/lib/map.js @@ -89,7 +89,7 @@ const PATH_WEIGHT_HOSTILE = 10 const PATH_WEIGHT_HOSTILE_RESERVATION = 5 module.exports.getRoomScore = function (toRoom, fromRoom, opts = {}) { - if (!Game.map.isRoomAvailable(toRoom)) { + if (!qlib.map.isRoomAvailableForCreeps(toRoom)) { return Infinity } if (!module.exports.reachableFromEmpire(toRoom)) { @@ -123,3 +123,12 @@ module.exports.getRoomScore = function (toRoom, fromRoom, opts = {}) { } return scores.WEIGHT_NEUTRAL ? scores.WEIGHT_NEUTRAL : PATH_WEIGHT_NEUTRAL } + +// Checks whether this room is available and our creeps can probably enter it +module.exports.isRoomAvailableForCreeps = function (roomName) { + const ourZone = Game.map.getRoomStatus(Object.values(Game.creeps)[0].room.name).status + // Room is available if it's in the same zone with us ('normal', 'novice' or 'respawn'), + // as trespassing between these is not possible. + // Check againt 'closed' status is also coverd as out creeps can't be in closed areas. + return ourZone === Game.map.getRoomStatus(roomName).status +}