screeps/helpers.js

16 lines
492 B
JavaScript
Raw Normal View History

2016-06-29 17:21:09 +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);
});
2016-06-30 01:26:39 +00:00
},
getLastFlag: function(flagName){
2016-06-30 01:53:45 +00:00
return _(Object.keys(Game.flags))
.filter((f) => f.startsWith(flagName))
.map((f) => f.slice(flagName.length))
.max();
2016-06-30 01:26:39 +00:00
},
2016-06-29 17:21:09 +00:00
};
module.exports = helpers;