Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

den-kozlov
Copy link

No description provided.

Copy link
Contributor

@duckymirror duckymirror left a 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 Show resolved Hide resolved
src/lib/map.js Outdated Show resolved Hide resolved
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
Copy link
Contributor

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.

Copy link
Author

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.

Copy link
Contributor

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 😉

Copy link
Contributor

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.

Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Our own implementation of depricated function
// Checks whether this room is available and our creeps can probably enter it

@@ -239,7 +239,7 @@ Room.requestIntel = function (roomname) {
Game.rooms[roomname].saveIntel()
return
}
if (!Game.map.isRoomAvailable(roomname)) {
if (!qlib.map.isRoomAvailable(roomname)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!qlib.map.isRoomAvailable(roomname)) {
if (Game.map.getRoomStatus(roomname) !== 'closed') {

We can request intel from rooms outside our novice / respawn area

@tedivm
Copy link
Contributor

tedivm commented Oct 7, 2020

Apologies for the gitconsensus stuff not working- I'll make sure to look at that in the next few days.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants