From f77066d205485949a7e19cc342128cb4092b2e11 Mon Sep 17 00:00:00 2001 From: Yuhang Li <18326007+WilliamYuhangLee@users.noreply.github.com> Date: Fri, 5 Apr 2019 09:18:15 -0400 Subject: [PATCH] Hotfix for type check of primitive data types --- prototype.creep.js | 2 +- prototype.spawn.js | 4 ++-- role.builder.js | 2 +- role.claimer.js | 6 +++--- role.collector.js | 2 +- role.harvester.js | 3 ++- role.repairer.js | 2 +- role.upgrader.js | 6 +++--- 8 files changed, 14 insertions(+), 13 deletions(-) diff --git a/prototype.creep.js b/prototype.creep.js index fecf18f..9cd7f8d 100644 --- a/prototype.creep.js +++ b/prototype.creep.js @@ -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); } diff --git a/prototype.spawn.js b/prototype.spawn.js index 138a783..cf9ecea 100644 --- a/prototype.spawn.js +++ b/prototype.spawn.js @@ -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 */ diff --git a/role.builder.js b/role.builder.js index efd5f3b..2716707 100644 --- a/role.builder.js +++ b/role.builder.js @@ -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]; diff --git a/role.claimer.js b/role.claimer.js index 2d6e488..200a01d 100644 --- a/role.claimer.js +++ b/role.claimer.js @@ -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 = { @@ -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; @@ -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]; diff --git a/role.collector.js b/role.collector.js index 4491a03..01e30eb 100644 --- a/role.collector.js +++ b/role.collector.js @@ -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; diff --git a/role.harvester.js b/role.harvester.js index 42d3f67..cc87b96 100644 --- a/role.harvester.js +++ b/role.harvester.js @@ -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 }}); @@ -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]; diff --git a/role.repairer.js b/role.repairer.js index caf1966..d951c54 100644 --- a/role.repairer.js +++ b/role.repairer.js @@ -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]; diff --git a/role.upgrader.js b/role.upgrader.js index 06f1dc7..ba9c6d6 100644 --- a/role.upgrader.js +++ b/role.upgrader.js @@ -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 = { @@ -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; @@ -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];