Skip to content

Commit

Permalink
Remove all remaining references to Game.map.isRoomAvailable(); add Ro…
Browse files Browse the repository at this point in the history
…omIntel.isRoomAccessible() method which determines if a room is in the same zone type as you
  • Loading branch information
bencbartlett committed Feb 4, 2024
1 parent bad7307 commit 0e23a85
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Overseer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,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 && RoomIntel.isRoomAccessible(roomName);
});
}

Expand Down
8 changes: 8 additions & 0 deletions src/intel/RoomIntel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,14 @@ export class RoomIntel {
}
}

/**
* Mimics the functionality of Game.map.isRoomAvailable(), but returns false if the room is in a different
* type of zone than you are in, such as if you are in a novice zone and the room is outside of it.
*/
static isRoomAccessible(roomName: string): boolean {
return RoomIntel.getRoomStatus(roomName).status == RoomIntel.getMyZoneStatus();
}

/**
* Returns the type of zone that your empire is in
*/
Expand Down
3 changes: 2 additions & 1 deletion src/overlords/scouting/randomWalker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Colony} from '../../Colony';
import {Roles, Setups} from '../../creepSetups/setups';
import {RoomIntel} from '../../intel/RoomIntel';
import {OverlordPriority} from '../../priorities/priorities_overlords';
import {profile} from '../../profiler/decorator';
import {Tasks} from '../../tasks/Tasks';
Expand Down Expand Up @@ -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 (RoomIntel.isRoomAccessible(roomName)) {
scout.task = Tasks.goToRoom(roomName);
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/strategy/ExpansionPlanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {assimilationLocked} from '../assimilation/decorator';
import {Colony, getAllColonies} from '../Colony';
import {log} from '../console/log';
import {DirectiveColonize} from '../directives/colony/colonize';
import {RoomIntel} from '../intel/RoomIntel';
import {Autonomy, getAutonomyLevel, Mem} from '../memory/Memory';
import {Pathing} from '../movement/Pathing';
import {profile} from '../profiler/decorator';
Expand Down Expand Up @@ -123,7 +124,7 @@ export class ExpansionPlanner implements IExpansionPlanner {
}
}
// Update best choices
if (score > bestScore && Game.map.isRoomAvailable(roomName)) {
if (score > bestScore && RoomIntel.isRoomAccessible(roomName)) {
bestScore = score;
bestRoom = roomName;
}
Expand Down

0 comments on commit 0e23a85

Please sign in to comment.