The getRoomData method should be able to do the following
[x] If roomData[roomName] is not defined, it should gather all data that it has been asked to get.
[x] If roomData[roomName] is defined, it should check that all of the Data Options that it has been asked to get have been retrieved.
[x] If roomData[roomName] is defined, but not all of the options have been retrieved, it should preserve the results currently in roomData, and fill out only the new data requests.
Ideally this will allow us to retrieve only the data we need at any given time.
E.g.
const roomData: RoomData
_.forEach(creeps, (creep: Creep) => {
roomData = getRoomData(roomData, creep, { hostiles: true });
if(roomData.hostiles.allHostiles.length === 0) {
return;
}
// We do not get here if there were no hostiles, so we don't waste CPU getting ramparts
roomData = getRoomData(roomData, creep, { openRamparts: true });
// roomData should now contain the definitions for { hostiles, openRamparts }
// from here we would go to an openRampart and handle hostiles as normal
The getRoomData method should be able to do the following
roomData[roomName]
is not defined, it should gather all data that it has been asked to get.roomData[roomName]
is defined, it should check that all of the Data Options that it has been asked to get have been retrieved.roomData[roomName]
is defined, but not all of the options have been retrieved, it should preserve the results currently in roomData, and fill out only the new data requests.Ideally this will allow us to retrieve only the data we need at any given time. E.g.