Skip to content

Commit

Permalink
Hotfix for type check of primitive data types
Browse files Browse the repository at this point in the history
  • Loading branch information
WilliamYuhangLee committed Apr 5, 2019
1 parent 90ea08d commit f77066d
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion prototype.creep.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ module.exports = function () {
Object.assign(opts, second);
}
return oldMoveTo.apply(this, [first, opts]);
} else if (first instanceof Number && second instanceof Number) {
} else if (typeof first === "number" && typeof second === "number") {
if (third instanceof Object) {
Object.assign(opts, third);
}
Expand Down
4 changes: 2 additions & 2 deletions prototype.spawn.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/**
* Spawn a creep of the given role at this spawn.
*
* @param {String} roleName: the name of the creep's role
* @param {string} roleName: the name of the creep's role
* @param {Object} [opts] an Object with additional options for the spawning process
* @param {String} [opts] a String parameter that serves specific purposes for each role
* @param {string} [opts] a string parameter that serves specific purposes for each role
*
* @returns {Number} the result of the spawning process
*/
Expand Down
2 changes: 1 addition & 1 deletion role.builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function run(creep) {
/**
* Clear out the creep's storage from Memory
*
* @param {String} creepName
* @param {string} creepName
*/
function clear(creepName) {
delete Memory.creeps[creepName];
Expand Down
6 changes: 3 additions & 3 deletions role.claimer.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const roleName = "claimer";
*
* @param {StructureSpawn} spawn: where the new creep is spawned
* @param {Object} [opts] an Object with additional options for the spawning process
* @param {String} [opts] the name of target room or flag
* @param {string} [opts] the name of target room or flag
*/
function spawn(spawn, opts) {
let args = {
Expand All @@ -18,7 +18,7 @@ function spawn(spawn, opts) {
if (opts) {
if (opts instanceof Object) {
_.merge(args, opts);
} else if (opts instanceof String && (Game.map.isRoomAvailable(opts) || Game.flags[opts])) {
} else if (typeof opts === "string" && (Game.map.isRoomAvailable(opts) || Game.flags[opts])) {
args.memory.target = opts;
} else {
return ERR_INVALID_ARGS;
Expand Down Expand Up @@ -69,7 +69,7 @@ function run(creep) {
/**
* Clear out the creep's storage from Memory
*
* @param {String} creepName
* @param {string} creepName
*/
function clear(creepName) {
delete Memory.creeps[creepName];
Expand Down
2 changes: 1 addition & 1 deletion role.collector.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function run(creep) {
/**
* Clear out the creep's storage from Memory
*
* @param {String} creepName
* @param {string} creepName
*/
function clear(creepName) {
let targetID = Memory.creeps[creepName].targetID;
Expand Down
3 changes: 2 additions & 1 deletion role.harvester.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const roleName = "harvester";
* Spawn a creep as a harvester from the designated spawn.
*
* @param {StructureSpawn} spawn
* @param {string} homeName: name of the new creep's home Room
*/
function spawn(spawn) {
return spawn.spawnCreep(body, modules.util.genName(roleName), { memory: { role: roleName }});
Expand Down Expand Up @@ -40,7 +41,7 @@ function run(creep) {
/**
* Clear out the creep's storage from Memory
*
* @param {String} creepName
* @param {string} creepName
*/
function clear(creepName) {
delete Memory.creeps[creepName];
Expand Down
2 changes: 1 addition & 1 deletion role.repairer.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function run(creep) {
/**
* Clear out the creep's storage from Memory
*
* @param {String} creepName
* @param {string} creepName
*/
function clear(creepName) {
delete Memory.creeps[creepName];
Expand Down
6 changes: 3 additions & 3 deletions role.upgrader.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const roleName = "upgrader";
*
* @param {StructureSpawn} spawn
* @param {Object} [opts] an Object with additional options for the spawning process
* @param {String} [opts] the name of the new creep's home Room
* @param {string} [opts] the name of the new creep's home Room
*/
function spawn(spawn, opts) {
let args = {
Expand All @@ -18,7 +18,7 @@ function spawn(spawn, opts) {
if (opts) {
if (opts instanceof Object) {
_.merge(args, opts);
} else if (opts instanceof String && Game.map.isRoomAvailable(opts)) {
} else if (typeof opts === "string" && Game.map.isRoomAvailable(opts)) {
args.memory.home = opts;
} else {
return ERR_INVALID_ARGS;
Expand Down Expand Up @@ -57,7 +57,7 @@ function run(creep) {
/**
* Clear out the creep's storage from Memory
*
* @param {String} creepName
* @param {string} creepName
*/
function clear(creepName) {
delete Memory.creeps[creepName];
Expand Down

0 comments on commit f77066d

Please sign in to comment.