Skip to content

Instantly share code, notes, and snippets.

@fractaloop
Forked from ho0ber/battle.js
Created July 2, 2016 22:18
Show Gist options
  • Save fractaloop/75a9bb2a3662818b2563c3cb1f09e57f to your computer and use it in GitHub Desktop.
Save fractaloop/75a9bb2a3662818b2563c3cb1f09e57f to your computer and use it in GitHub Desktop.
Battle whitelist for screeps
// usernames are all lowercase, we compare with to lower
var USERNAME_WHITELIST = ['chrisinajar', 'ho0ber', 'fractaloop', 'n7-anthony', 'overra', 'tyrel', 'fervens'];
module.exports = {
findEnemy: findEnemy
};
/*
var target = findEnemy(creep);
*/
function findEnemy (creep) {
var targets = creep.room.find(FIND_HOSTILE_CREEPS, {
filter: (c) => {
return (USERNAME_WHITELIST.indexOf(c.owner.username.toLowerCase()) === -1);
}
});
return creep.pos.findClosestByPath(targets);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment