change to 1 based so i can use ||

This commit is contained in:
Tyrel Souza 2016-06-29 20:56:10 -04:00
parent 560bec5fc8
commit acf5e8e70a

View File

@ -2,13 +2,13 @@ var battle = require("battle")
var roleGuard = {
getLastFlag: function(){
return 1; // TODO. calculate me.
return 2; // TODO. calculate me.
},
run: function(creep){
console.log(creep, "running Guard")
if (creep.memory.patrolDestination == undefined){
creep.memory.patrolDestination = 0
}
// Reset creep to 1
creep.memory.patrolDestination = creep.memory.patrolDestination || 1;
var target = battle.findEnemy(creep);
if(target != creep.room.controller && creep.hits > creep.hitsMax - 500 /* no more attack */) {
console.log("\t", creep, "attacking:",target)
@ -22,7 +22,7 @@ var roleGuard = {
}
if (creep.memory.patrolDestination > this.getLastFlag()){
creep.memory.patrolDestination = 0;
creep.memory.patrolDestination = 1;
}
destinationFlag = Game.flags["patrol_" + creep.memory.patrolDestination];
console.log("\tMoving to Patrol leg:", creep.memory.patrolDestination);