Skip to content

Commit

Permalink
Merge pull request #430 from duckymirror/update-deps
Browse files Browse the repository at this point in the history
GitConsensus Merge
  • Loading branch information
gitconsensus[bot] authored Mar 16, 2020
2 parents 9856815 + efd5f93 commit f6868c5
Show file tree
Hide file tree
Showing 50 changed files with 478 additions and 466 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/quorum
docker:
- image: circleci/node:6.11.1
- image: circleci/node:12
steps:
- checkout
- restore_cache:
Expand Down
71 changes: 35 additions & 36 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
'use strict'

let fs = require('fs')
let gulp = require('gulp')
let screeps = require('gulp-screeps')
let rename = require('gulp-rename')
let insert = require('gulp-insert')
let clean = require('gulp-clean')
let minimist = require('minimist')
let git = require('git-rev-sync')
const fs = require('fs')
const gulp = require('gulp')
const screeps = require('gulp-screeps')
const rename = require('gulp-rename')
const insert = require('gulp-insert')
const del = require('del')
const minimist = require('minimist')
const git = require('git-rev-sync')

let args = minimist(process.argv.slice(2))
let commitdate = git.date()
const args = minimist(process.argv.slice(2))
const commitdate = git.date()

gulp.task('clean', () => {
return gulp.src('dist/', { read: false }).pipe(clean())
return del('dist/*')
})

gulp.task('copy', ['clean'], () => {
let src
src = gulp.src('src/**/*.js')
gulp.task('copy', gulp.series('clean', () => {
const src = gulp.src('src/**/*.js')
return src.pipe(rename((path) => {
let parts = path.dirname.match(/[^/\\]+/g)
const parts = path.dirname.match(/[^/\\]+/g)
let name = ''
for (let i in parts) {
for (const i in parts) {
if (parts[i] !== '.') {
name += parts[i] + '_'
}
Expand All @@ -38,20 +37,20 @@ gulp.task('copy', ['clean'], () => {
}
return contents
})).pipe(gulp.dest('dist/'))
})
}))

function deploy () {
let config = require('./.screeps.json')
let opts = config[args.server || 'main']
let options = {}
const config = require('./.screeps.json')
const opts = config[args.server || 'main']
const options = {}
if (!opts) {
let err = new Error(`No configuration exists for server "${args.server || 'main'}`)
const err = new Error(`No configuration exists for server "${args.server || 'main'}`)
err.showStack = false
throw err
}

// allow overrides from passed arguments
for (let i in args) { // jshint ignore:line
for (const i in args) { // jshint ignore:line
opts[i] = args[i]
}

Expand All @@ -76,11 +75,21 @@ function deploy () {
return gulp.src('dist/*.js').pipe(screeps(options))
}

gulp.task('deploy', ['copy'], () => {
gulp.task('deploy', gulp.series('copy', () => {
return deploy()
}))

gulp.task('ci-version', (cb) => {
const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'))
const seconds = (commitdate.getHours() * 3600) + (commitdate.getMinutes() * 60) + commitdate.getSeconds()
const year = commitdate.getFullYear()
const month = commitdate.getMonth() + 1
const day = commitdate.getDate()
pkg.version = `${year}.${month}.${day}-${seconds}`
fs.writeFile('package.json', JSON.stringify(pkg, null, 2), cb)
})

gulp.task('ci-config', ['ci-version'], (cb) => {
gulp.task('ci-config', gulp.series('ci-version', (cb) => {
fs.writeFile('.screeps.json', JSON.stringify({
main: {
ptr: !!process.env.SCREEPS_PTR,
Expand All @@ -91,16 +100,6 @@ gulp.task('ci-config', ['ci-version'], (cb) => {
port: process.env.SCREEPS_PORT
}
}), cb)
})

gulp.task('ci-version', (cb) => {
let pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'))
let seconds = (commitdate.getHours() * 3600) + (commitdate.getMinutes() * 60) + commitdate.getSeconds()
let year = commitdate.getFullYear()
let month = commitdate.getMonth() + 1
let day = commitdate.getDate()
pkg.version = `${year}.${month}.${day}-${seconds}`
fs.writeFile('package.json', JSON.stringify(pkg, null, 2), cb)
})
}))

gulp.task('default', ['clean', 'copy', 'deploy'])
gulp.task('default', gulp.series('deploy'))
24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@
"main": "dist/main.js",
"repository": "ScreepsQuorum/screeps-quorum",
"scripts": {
"test": "standard && ava test",
"testci": "standard && ava test --tap | tap-xunit > test-results.xml",
"watch": "ava test --watch",
"test": "standard && npx ava",
"testci": "standard && npx ava --tap | tap-xunit > test-results.xml",
"watch": "npx ava --watch",
"deploy": "gulp",
"ci-config": "gulp ci-config",
"2npm": "npm publish"
},
"dependencies": {},
"devDependencies": {
"ava": "^0.22.0",
"git-rev-sync": "^1.9.1",
"gulp": "^3.9.1",
"gulp-clean": "^0.3.2",
"ava": "^3.5.0",
"del": "^5.1.0",
"git-rev-sync": "^2.0.0",
"gulp": "^4.0.2",
"gulp-insert": "^0.5.0",
"gulp-rename": "^1.2.2",
"gulp-screeps": "^1.0.6",
"minimist": "^1.2.0",
"standard": "^10.0.3",
"tap-xunit": "^1.7.0"
"gulp-rename": "^2.0.0",
"gulp-screeps": "^1.0.8",
"minimist": "^1.2.5",
"standard": "^14.3.2",
"tap-xunit": "^2.4.1"
},
"screeps_bot": true,
"standard": {
Expand Down
8 changes: 4 additions & 4 deletions src/extends/creep.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'

Creep.getRole = function (roleName) {
let Role = require('roles_' + roleName)
const Role = require('roles_' + roleName)
return new Role()
}

Expand All @@ -11,7 +11,7 @@ Creep.getRoleFromName = function (creepname) {

Creep.prototype.getRole = function () {
// If the creep role isn't in memory grab it based off of the name
let roleType = this.memory.role ? this.memory.role : this.name.split('_', 1)[0]
const roleType = this.memory.role ? this.memory.role : this.name.split('_', 1)[0]
return Creep.getRole(roleType)
}

Expand All @@ -29,9 +29,9 @@ Creep.getCost = function (parts) {
}

Creep.buildFromTemplate = function (template, energy) {
let parts = []
const parts = []
while (energy > 0 && parts.length < 50) {
let next = template[parts.length % template.length]
const next = template[parts.length % template.length]
if (BODYPART_COST[next] > energy) {
break
}
Expand Down
46 changes: 24 additions & 22 deletions src/extends/creep/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,35 +40,37 @@ Creep.prototype.recharge = function () {
return true
}
// Create a bigger scope for this variable ( used here and in the filter in containers )
let carryCap = this.carryCapacity
const carryCap = this.carryCapacity

// Check for qualifying dropped energy.
const resources = this.room.find(FIND_DROPPED_RESOURCES, {filter: function (resource) {
if (resource.resourceType !== RESOURCE_ENERGY || resource.amount < carryCap) {
return false
}
const resources = this.room.find(FIND_DROPPED_RESOURCES, {
filter: function (resource) {
if (resource.resourceType !== RESOURCE_ENERGY || resource.amount < carryCap) {
return false
}

// Is resource on top of container?
const structures = resource.pos.lookFor(LOOK_STRUCTURES)
for (let structure of structures) {
if (structure.structureType === STRUCTURE_CONTAINER) {
// Is resource on top of container?
const structures = resource.pos.lookFor(LOOK_STRUCTURES)
for (const structure of structures) {
if (structure.structureType === STRUCTURE_CONTAINER) {
return true
}
}

// Is the resource near the room storage?
if (resource.room.storage && resource.room.storage.pos.getRangeTo(resource) <= 2) {
return true
}
}

// Is the resource near the room storage?
if (resource.room.storage && resource.room.storage.pos.getRangeTo(resource) <= 2) {
return true
}
// Is the resource on top of the suicide booth?
const suicideBooth = resource.room.getSuicideBooth()
if (suicideBooth && resource.pos.getRangeTo(suicideBooth) === 0) {
return true
}

// Is the resource on top of the suicide booth?
const suicideBooth = resource.room.getSuicideBooth()
if (suicideBooth && resource.pos.getRangeTo(suicideBooth) === 0) {
return true
return false
}

return false
}})
})

if (resources.length > 0) {
const resource = this.pos.findClosestByRange(resources)
Expand Down Expand Up @@ -146,7 +148,7 @@ Creep.prototype.recycle = function () {
if (this.pos.getRangeTo(suicideBooth) > 0) {
this.travelTo(suicideBooth)
} else {
let spawn = this.pos.findClosestByRange(this.room.structures[STRUCTURE_SPAWN])
const spawn = this.pos.findClosestByRange(this.room.structures[STRUCTURE_SPAWN])
spawn.recycleCreep(this)
}
}
Expand Down
22 changes: 11 additions & 11 deletions src/extends/creep/movement.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ const defaultMaxOpsPerRoom = 1500
const struckThreshold = 2
const struckRerouteThreshold = 4
const travelToDefaults = {
'reusePath': 1500,
'moveToOverride': true,
'ignoreStuck': false,
'ignoreHostileCities': true,
'ignoreHostileReservations': false,
'avoidHostileRooms': false
reusePath: 1500,
moveToOverride: true,
ignoreStuck: false,
ignoreHostileCities: true,
ignoreHostileReservations: false,
avoidHostileRooms: false
}

Creep.prototype.travelTo = function (pos, opts = {}) {
Expand Down Expand Up @@ -40,10 +40,10 @@ Creep.prototype.travelTo = function (pos, opts = {}) {
moveToOpts.avoidHostileRooms = true
} else {
if (moveToOpts.ignoreHostileCities) {
moveToOpts.scores['WEIGHT_HOSTILE'] = Infinity
moveToOpts.scores.WEIGHT_HOSTILE = Infinity
}
if (moveToOpts.ignoreHostileReservations) {
moveToOpts.scores['WEIGHT_HOSTILE_RESERVATION'] = Infinity
moveToOpts.scores.WEIGHT_HOSTILE_RESERVATION = Infinity
}
}
}
Expand Down Expand Up @@ -106,9 +106,9 @@ Creep.prototype.travelTo = function (pos, opts = {}) {
if (Number.isInteger(worldRoute)) {
return worldRoute
}
for (let pathPiece of worldRoute) {
if (moveToOpts.allowedRooms.indexOf(pathPiece['room']) < 0) {
moveToOpts.allowedRooms.push(pathPiece['room'])
for (const pathPiece of worldRoute) {
if (moveToOpts.allowedRooms.indexOf(pathPiece.room) < 0) {
moveToOpts.allowedRooms.push(pathPiece.room)
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/extends/mineral.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Mineral.getEmpireRatio = function () {
return this.mineralRatio
}
const rooms = Room.getCities()
let resources = {}
const resources = {}
let max = 0
for (let room of rooms) {
for (const room of rooms) {
const roomIntel = Room.getIntel(room)
if (!roomIntel[INTEL_MINERAL]) {
continue
Expand All @@ -26,8 +26,8 @@ Mineral.getEmpireRatio = function () {
max = resources[resourceType]
}
}
let ratio = {}
for (let resourceType of MINERALS_EXTRACTABLE) {
const ratio = {}
for (const resourceType of MINERALS_EXTRACTABLE) {
if (!resources[resourceType]) {
ratio[resourceType] = 0
} else {
Expand Down
10 changes: 5 additions & 5 deletions src/extends/room/alchemy.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Room.prototype.getVatLabs = function () {
return false
}

let vats = []
const vats = []
for (const lab of labs) {
if (feeders[0].id === lab.id || feeders[1].id === lab.id) {
continue
Expand Down Expand Up @@ -77,10 +77,10 @@ Room.prototype.getNextReaction = function () {

// Has Catalyst
if (this.storage.store[RESOURCE_CATALYST] && this.storage.store[RESOURCE_CATALYST] > 1000) {
if (storageByType['tier2'] && storageByType['tier2'].length > 0) {
if (storageByType.tier2 && storageByType.tier2.length > 0) {
let need = 0
let resource = false
for (const option of storageByType['tier2']) {
for (const option of storageByType.tier2) {
if (this.storage.store[option] < 1000) {
continue
}
Expand All @@ -99,10 +99,10 @@ Room.prototype.getNextReaction = function () {

// Has OH
if (this.storage.store[RESOURCE_HYDROXIDE] && this.storage.store[RESOURCE_HYDROXIDE] > 1000) {
if (storageByType['tier1'] && storageByType['tier1'].length > 0) {
if (storageByType.tier1 && storageByType.tier1.length > 0) {
let need = 0
let resource = false
for (const option of storageByType['tier1']) {
for (const option of storageByType.tier1) {
if (this.storage.store[option] < 1000) {
continue
}
Expand Down
Loading

0 comments on commit f6868c5

Please sign in to comment.