2016-06-30 14:37:58 +00:00
|
|
|
var helpers = {
|
|
|
|
generateName: function(role){
|
|
|
|
return role + '_xxxxxxxx'.replace(/[xy]/g, function(c) {
|
|
|
|
var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
|
|
|
|
return v.toString(16);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
getLastFlag: function(flagName){
|
|
|
|
return _(Object.keys(Game.flags))
|
|
|
|
.filter((f) => f.startsWith(flagName))
|
|
|
|
.map((f) => f.slice(flagName.length))
|
|
|
|
.max();
|
|
|
|
},
|
2016-06-30 14:59:43 +00:00
|
|
|
findDamagedStructure: function(searcher){
|
|
|
|
var targets = searcher.room.find(FIND_STRUCTURES, {
|
|
|
|
filter: function(s){
|
|
|
|
if(s.id == searcher.id){
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (s.hits < s.hitsMax){
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
return searcher.pos.findClosestByPath(targets);
|
|
|
|
}
|
|
|
|
|
2016-06-30 14:37:58 +00:00
|
|
|
};
|
|
|
|
|
2016-06-30 14:59:43 +00:00
|
|
|
module.exports = helpers;
|