-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathhelper.friendFoeRecognition.js
24 lines (23 loc) · 1.12 KB
/
helper.friendFoeRecognition.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
module.exports = {
findHostiles: function(room, options) {
let filter = (c) => true;
if(options && options.filter) filter = options.filter;
return room.find(FIND_HOSTILE_CREEPS, { filter: (c) => !FriendList.friends.includes(c.owner.username) && filter(c) });
},
findClosestHostileByRange: function(position, options) {
let filter = (c) => true;
if(options && options.filter) filter = options.filter;
return position.findClosestByRange(FIND_HOSTILE_CREEPS, { filter: (c) => !FriendList.friends.includes(c.owner.username) && filter(c) });
},
findAllies: function(room) {
let filter = (c) => true;
if(options && options.filter) filter = options.filter;
return room.find(FIND_HOSTILE_CREEPS, { filter: (c) => FriendList.friends.includes(c.owner.username) && filter(c) });
},
isHostile: function(ownedThing) {
if(!ownedThing.owner) return false;
return !ownedThing.my && !FriendList.friends.includes(ownedThing.owner.username);
}
};
const profiler = require("screeps-profiler");
profiler.registerObject(module.exports, 'ff');