Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Darkosto committed Jan 22, 2021
1 parent 72381ee commit 8cb0c77
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 105 deletions.
30 changes: 13 additions & 17 deletions role.scout.js
Original file line number Diff line number Diff line change
@@ -1,34 +1,31 @@
// Creep to move into next area and capture

var role_scout = {

run: function(creep) {

run: function (creep) {
var home = Game.room(W8N3);
var away = Game.room(W7N3);

//if (creep.)
creep.say('Testing');
//console.log('hi!')


creep.moveTo(Game.flags.Room2);
creep.say("Testing");
//console.log('hi!')

creep.claimController('a2db077296e87b8');

//if (creep.room)
creep.moveTo(Game.flags.Room2);

/*
creep.claimController("a2db077296e87b8");

//if (creep.room)

/*
a2db077296e87b8
*/
}
};
},
};
module.exports = role_scout;
/*
/*
if(creep.room.name == 'W7N7');
// creep.memory.role = 'harvester'
creep.say('Switching Jobs');
Expand Down Expand Up @@ -64,4 +61,3 @@ module.exports = role_scout;
return C.OK;
}
*/

88 changes: 51 additions & 37 deletions role.worker.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var role_worker = {

/** @param {Creep} creep **/
run: function(creep) {
/*
/** @param {Creep} creep **/
run: function (creep) {
/*
console.log(creep.store[RESOURCE_ENERGY], creep.store.getCapacity());
if (creep.store[RESOURCE_ENERGY] < creep.store.getCapacity()) {
var sources = creep.room.find(FIND_SOURCES_ACTIVE);
Expand All @@ -12,43 +11,58 @@ var role_worker = {
}
}
*/
console.log(creep.store[RESOURCE_ENERGY], creep.store.getCapacity());
if (creep.memory.working && creep.store[RESOURCE_ENERGY] == 0) {
creep.memory.working = false;
creep.say('collecting!');
}

if (!creep.memory.working && creep.store[RESOURCE_ENERGY] == 50) {
creep.memory.working = true;
creep.say('Energizing!');
}

console.log(creep.store[RESOURCE_ENERGY], creep.store.getCapacity());
if (creep.memory.working && creep.store[RESOURCE_ENERGY] == 0) {
creep.memory.working = false;
creep.say("collecting!");
}

if (!creep.memory.working && creep.store[RESOURCE_ENERGY] == 50) {
creep.memory.working = true;
creep.say("Energizing!");
}

if (creep.memory.working) {
var targets = creep.room.find(FIND_MY_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_CONTROLLER) && structure.progress < structure.progressTotal;
//structure.structureType == STRUCTURE_EXTENSION
//structure.structureType == STRUCTURE_CONTAINER ||
//structure.structureType == STRUCTURE_SPAWN ||
//structure.structureType == STRUCTURE_TOWER
}
});
console.log(targets)
if (creep.memory.working) {
var targets = creep.room.find(FIND_MY_STRUCTURES, {
filter: (structure) => {
return (
structure.structureType == STRUCTURE_CONTROLLER &&
structure.progress < structure.progressTotal
);
//structure.structureType == STRUCTURE_EXTENSION
//structure.structureType == STRUCTURE_CONTAINER ||
//structure.structureType == STRUCTURE_SPAWN ||
//structure.structureType == STRUCTURE_TOWER
},
});
console.log(targets);

if (targets.length > 0) {
if (creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0]);
}
}
} else {
var sources = creep.room.find(FIND_SOURCES_ACTIVE);
if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0], {visualizePathStyle: {stroke: 'white'}});
}
if (targets.length > 0) {
if (creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0], {
visualizePathStyle: {
stroke: "green",
strokeWidth: "0.3",
opacity: "1.0",
lineStyle: "dotted",
},
});
}
}
} else {
var sources = creep.room.find(FIND_SOURCES_ACTIVE);
if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0], {
visualizePathStyle: {
stroke: "blue",
strokeWidth: "0.3",
opacity: "1.0",
lineStyle: "dotted",
},
});
}
}
},
};

module.exports = role_worker;
module.exports = role_worker;
89 changes: 38 additions & 51 deletions role.worker2.js
Original file line number Diff line number Diff line change
@@ -1,56 +1,43 @@
var role_worker_midpoint = {

/** @param {Creep} creep **/
run: function(creep) {


// Carries energy to midpoint
// Structure ID: 4d6a22924d8cba1
console.log(creep.store[RESOURCE_ENERGY], creep.store.getCapacity());
if (creep.memory.midpointing && creep.store[RESOURCE_ENERGY] == 0) {
creep.memory.midpointing = false;
creep.say('collecting!');
console.log('HELP')
}

if (!creep.memory.midpointing && creep.store[RESOURCE_ENERGY] == 50) {
creep.memory.midpointing = true;
creep.say('test!');
console.log('PLS')
}


if (creep.memory.midpointing) {


var targets = creep.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (structure.structureType == STRUCTURE_STORAGE ||
structure.structureType == STRUCTURE_EXTENSION) && structure.energy < structure.energyCapacity;
//structure.structureType == STRUCTURE_SPAWN ||
//structure.structureType == STRUCTURE_TOWER)
}
});

if(targets.length > 0) {
if(creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0]);
}
}
creep.say('charging');
console.log(STRUCTURE_CONTAINER);



} else {

var sources = creep.room.find(FIND_SOURCES_ACTIVE);
if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}

/** @param {Creep} creep **/
run: function (creep) {
// Carries energy to midpoint
// Structure ID: 4d6a22924d8cba1
console.log(creep.store[RESOURCE_ENERGY], creep.store.getCapacity());
if (creep.memory.midpointing && creep.store[RESOURCE_ENERGY] == 0) {
creep.memory.midpointing = false;
creep.say("collecting!");
}
if (!creep.memory.midpointing && creep.store[RESOURCE_ENERGY] == 50) {
creep.memory.midpointing = true;
creep.say("Energizing!");
}
if (creep.memory.midpointing) {
var targets = creep.room.find(FIND_STRUCTURES, {
filter: (structure) => {
return (
(structure.structureType == STRUCTURE_STORAGE ||
structure.structureType == STRUCTURE_EXTENSION ||
structure.structureType == STRUCTURE_SPAWN) &&
structure.energy < structure.energyCapacity
);
//structure.structureType == STRUCTURE_TOWER)
},
});
if (targets.length > 0) {
if (creep.transfer(targets[0], RESOURCE_ENERGY) == ERR_NOT_IN_RANGE) {
creep.moveTo(targets[0]);
}
}
creep.say("charging");
console.log(STRUCTURE_CONTAINER);
} else {
var sources = creep.room.find(FIND_SOURCES_ACTIVE);
if (creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
creep.moveTo(sources[0]);
}
}
},
};

module.exports = role_worker_midpoint;
module.exports = role_worker_midpoint;

0 comments on commit 8cb0c77

Please sign in to comment.