-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
own implementation of isRoomAvailable #437
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for taking your time to contribute! I've noticed a few minor things, but all in all this looks good!
src/lib/map.js
Outdated
|
||
// Our own implementation of depricated function | ||
module.exports.isRoomAvailable = function (roomName) { | ||
const homeRoomStatus = Game.map.getRoomStatus(_.values(Game.spawns)[0].room.name).status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line throws an exception when there are no spawns left. The empire is only dead when all creeps are dead too. I'd check for Game.creeps
as a fallback when there are no Game.spawns
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So there's no point in checking spawns then. The check can be done against creeps object as they are in the same zone. This can be replaced with 'normal' constant, but it will hurt people using Novice and Respawn zones.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right after spawning there are no creeps yet though 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No guarantee of a spawn either if using auto
mode on private servers 😉 May want to use _.keys(Game.rooms)[0]
instead since that will always exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
An observer could have been used to observe a room outside the zone
src/lib/map.js
Outdated
@@ -123,3 +123,12 @@ module.exports.getRoomScore = function (toRoom, fromRoom, opts = {}) { | |||
} | |||
return scores.WEIGHT_NEUTRAL ? scores.WEIGHT_NEUTRAL : PATH_WEIGHT_NEUTRAL | |||
} | |||
|
|||
// Our own implementation of depricated function |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Our own implementation of depricated function | |
// Checks whether this room is available and our creeps can probably enter it |
src/extends/room/intel.js
Outdated
@@ -239,7 +239,7 @@ Room.requestIntel = function (roomname) { | |||
Game.rooms[roomname].saveIntel() | |||
return | |||
} | |||
if (!Game.map.isRoomAvailable(roomname)) { | |||
if (!qlib.map.isRoomAvailable(roomname)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!qlib.map.isRoomAvailable(roomname)) { | |
if (Game.map.getRoomStatus(roomname) !== 'closed') { |
We can request intel from rooms outside our novice / respawn area
Apologies for the gitconsensus stuff not working- I'll make sure to look at that in the next few days. |
No description provided.