diff --git a/role.guard.js b/role.guard.js index 9ff9405..37fa6b3 100644 --- a/role.guard.js +++ b/role.guard.js @@ -2,8 +2,14 @@ var battle = require('battle') var roleGuard = { getLastFlag: function(){ - - return 4; // TODO. calculate me. + let patrolFlags = _.filter(Game.flags, function(flag){ + return flag.name.indexOf("patrol_") == 0; + }); + let flagNumbers = _.map(patrolFlags, function(flag){ + return parseInt(flag.name.substring("patrol_".length, flag.name.length)); + }); + let max = Math.max.apply(Math, flagNumbers); + return max; }, run: function(creep){ console.log(creep, 'running Guard')