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