How can I know which rampart/wall has the lowest amount of hitpoints?
-
the tittle
-
let min = Number.MAX_SAFE_INTEGER; let target; Game.rooms.ROOM_NAME.find(FIND_STRUCTURES).forEach((s) => { if(s.structureType == STRUCTURE_WALL || s.structureType == STRUCTURE_RAMPART){ if(s.hits < min){ min = s.hits; target = s; } } });
-
thanks!
-
Here's another solution using _.min():
let ramparts = Game.rooms['ROOMNAME'].find(FIND_STRUCTURES, {filter: {structureType: STRUCTURE_RAMPART}}); let lowestRampart = _.min(ramparts, r => r.hits);
-
@tehfiend That's easier, thanks!