From acf5e8e70a565619112b512ca7daf506b4153866 Mon Sep 17 00:00:00 2001 From: Tyrel Souza Date: Wed, 29 Jun 2016 20:56:10 -0400 Subject: [PATCH] change to 1 based so i can use || --- role.guard.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/role.guard.js b/role.guard.js index 8a2c26c..4d4d637 100644 --- a/role.guard.js +++ b/role.guard.js @@ -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);