Skip to content

Commit

Permalink
check if commue.storage exists (#747)
Browse files Browse the repository at this point in the history
  • Loading branch information
realacesu authored Dec 7, 2023
1 parent 913ce3e commit 877c631
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/room/room.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ export class RoomManager {
this.roomVisualsManager.run()
}

private test() {}
private test() { }

/**
* Debug
Expand Down Expand Up @@ -362,7 +362,7 @@ export class RoomManager {
findRemoteSourceFastFillerPaths(
commune: Room,
packedRemoteSourceHarvestPositions: string[],
weightCoords: {[packedCoord: string]: number},
weightCoords: { [packedCoord: string]: number },
pathsThrough: Set<string>,
) {
const anchor = commune.roomManager.anchor
Expand All @@ -378,7 +378,7 @@ export class RoomManager {
typeWeights: remoteTypeWeights,
plainCost: defaultRoadPlanningPlainCost,
weightCoords: {
[this.room.name]:weightCoords
[this.room.name]: weightCoords
},
weightCommuneStructurePlans: true,
weightRemoteStructurePlans: {
Expand All @@ -405,7 +405,7 @@ export class RoomManager {
findRemoteSourceHubPaths(
commune: Room,
packedRemoteSourceHarvestPositions: string[],
weightCoords: {[packedCoord: string]: number},
weightCoords: { [packedCoord: string]: number },
pathsThrough: Set<string>,
) {
const stampAnchors = commune.roomManager.stampAnchors
Expand All @@ -415,7 +415,7 @@ export class RoomManager {

// See if there is a storage adjacent to the hub. If so, set the goalPos as the hub pos

if (getRange(commune.storage.pos, stampAnchors.hub[0]) === 1) {
if (commune.storage && getRange(commune.storage.pos, stampAnchors.hub[0]) === 1) {

goalPos = commune.storage.pos
}
Expand All @@ -432,7 +432,7 @@ export class RoomManager {
typeWeights: remoteTypeWeights,
plainCost: defaultRoadPlanningPlainCost,
weightCoords: {
[this.room.name]:weightCoords
[this.room.name]: weightCoords
},
weightCommuneStructurePlans: true,
weightRemoteStructurePlans: {
Expand Down Expand Up @@ -490,7 +490,7 @@ export class RoomManager {
findRemoteControllerPath(
commune: Room,
packedRemoteControllerPositions: string,
weightCoords: {[packedCoord: string]: number},
weightCoords: { [packedCoord: string]: number },
pathsThrough: Set<string>,
) {
const anchor = commune.roomManager.anchor
Expand All @@ -503,7 +503,7 @@ export class RoomManager {
typeWeights: remoteTypeWeights,
plainCost: defaultRoadPlanningPlainCost,
weightCoords: {
[this.room.name]:weightCoords
[this.room.name]: weightCoords
},
weightCommuneStructurePlans: true,
weightRemoteStructurePlans: {
Expand Down Expand Up @@ -1122,9 +1122,9 @@ export class RoomManager {
const enemyAttackers = this.notMyCreeps.enemy.filter(function (creep) {
return (
creep.parts.attack +
creep.parts.ranged_attack +
creep.parts.work +
creep.parts.heal >
creep.parts.ranged_attack +
creep.parts.work +
creep.parts.heal >
0
)
})
Expand Down Expand Up @@ -1435,14 +1435,14 @@ export class RoomManager {

if (
adjacentStructuresByType[STRUCTURE_CONTAINER] +
adjacentStructuresByType[STRUCTURE_LINK] ===
adjacentStructuresByType[STRUCTURE_LINK] ===
0
)
continue

if (
adjacentStructuresByType[STRUCTURE_SPAWN] +
adjacentStructuresByType[STRUCTURE_EXTENSION] ===
adjacentStructuresByType[STRUCTURE_EXTENSION] ===
0
)
continue
Expand Down

0 comments on commit 877c631

Please sign in to comment.